Solve Sb=x

DESCRIPTION:

Solves Sb=x for b, where S is a sparse matrix obtained from an object of class spatial.neighbor.

USAGE:

spatial.solve(neighbor, x, transpose=F, rho=0, product=F,  
              weights=NULL, region.id=NULL, absThreshold=0,  
              relThreshold=0, diagPivoting=0, shareMemory=F) 

REQUIRED ARGUMENTS:

neighbor
an object of class "spatial.neighbor" containing the sparse matrix representation of the spatial neighbor matrix (or matrices, see function spatial.neighbor).
x
the right hand side for which a solution is desired. Alternatively, x can be a matrix. In this case, a solution is obtained for each column in x.

OPTIONAL ARGUMENTS:

transpose
with the default arguments, S is taken as I minus the sum over i of rho[i] * A[i]. Here I is an identity matrix, rho[i] is a scalar, and A[i] is the i-th weight matrix in neighbor. If transpose is TRUE, then the transpose of this matrix is used for A.
rho
a scalar (or vector) of constants used in defining the matrix S (see argument transpose).
product
let B=I minus the sum of rho[i]*A[i] as described in argument transpose. When product is FALSE, S=B. When product is TRUE, S is t(B)%*%B.
weights
if provided, the inverse weights are included along the diagonal matrix W and incorporated into the model for S as follows: Let R be I minus the sum of rho[i]*A[i]. Then product | transpose | S ---------------------------------- F | F | `R %*% W' F | T | `t(R) %*% W' T | F | `t(R) %*% W %*% R' T | T | `R %*% W %*% t(R)'
region.id
a vector with length equal to the number of regions in the spatial lattice. If variables row.id and col.id of argument neighbor are not integer valued variables with sequential values from 1 to the number or regions in the lattice, then argument region.id must be specified and is used to obtain a sequential coding of the lattice regions.
absThreshold
the pivot threshold (between zero and 1). Values near 1 result in complete pivoting, while values near zero result in a strict Markowitz solution. In general, you should choose a value as close to zero as roundoff error will permit. A value of 0.001 has been recommended by Kundert (1988) in some cases.
relThreshold
the absolute magnitude an element must have to be considered as a pivot candidate, except as a last resort. This should be set to a small fraction of the smallest (absolute) diagonal element.
diagPivoting
if TRUE, pivot selection should be confined to the diagonal if possible.
shareMemory
if TRUE, the in-memory representation of the sparse matrix will be shared by other routines. If memory is shared, it needs to be released later. One way to release the memory is to call .C("destroy_sparse_matrix") after the in-memory representation of the matrix is no long needed. Most users should use the default value, FALSE.

VALUE:

a matrix (or vector), b, solving the linear system Sb=x.

DETAILS:

This routine uses the sparse matrix code of Kenneth Kundert and Alberto Sangiovanni-Vincentelli (1988). The University of California, Berkeley, holds the copyright for these routines.

REFERENCES:

Kundert, Kenneth S. and Sangiovanni-Vincentelli, Alberto (1988). A Sparse Linear Equation Solver. Department of EE and CS, University of California, Berkeley.

SEE ALSO:

, , , .

EXAMPLES:

x <- 1:4 
row.id <- c(1,1,2,2,3) 
col.id <- c(1,3,1,3,4) 
alpha <- 0.3 
neighbor <- spatial.neighbor(row.id=row.id, col.id=col.id, symmetric=T) 
a <- solve(diag(attr(neighbor, "nregion"))-alpha* 
        spatial.weights(neighbor), x) 
b <- spatial.solve(neighbor, x, rho=alpha)$result 
print(max(abs(a-b)) < 1e-14)