https://github.com/cran/fields
Raw File
Tip revision: beb6c9118b4f355fc630943f00274a7df8714fe1 authored by Doug Nychka on 26 April 2007, 00:00:00 UTC
version 3.5
Tip revision: beb6c91
Krig.make.W.R
Krig.make.W<- function( out, verbose=FALSE){

   if( verbose) { cat( "W", fill=TRUE) ; print( out$W)}
    
   if( out$nondiag.W) {
#
# create W from scratch or grab it from passed object

        if( is.null(out$W)){
         if( verbose){ print( out$wght.function.name)}
         W<- do.call( out$wght.function.name, 
                        c( list( x=out$xM), out$args.wght))
#
# possibly adjust W based on diagional weight terms 
#          
         W<- sqrt( out$weightsM)* t( sqrt(out$weightsM)*W) }
        else{ 
          W<-  out$W}
#
# symmetric square root
      eigen( W, symmetric=TRUE)-> temp
      W2<- temp$vectors%*% diag( sqrt( temp$values))%*% t( temp$vectors)
     return( list( W=W, W2=W2)) }
   
   else{
#
#  If W is diagonal include  as a vector. 
#  Subsequent multiplies use %d*% to handle the diagonal and nondiagonal cases
#  together   e.g.  W%d*%yM will worrk for both diag and nondiag W's. 
#
      return(
             list( W= out$weightsM, W2=sqrt(out$weightsM))
             )}

   
}
back to top