Sb=x
Sb=x
for
b
, where
S
is a sparse matrix obtained from
an object of class
spatial.neighbor
.
spatial.solve(neighbor, x, transpose=F, rho=0, product=F, weights=NULL, region.id=NULL, absThreshold=0, relThreshold=0, diagPivoting=0, shareMemory=F)
"spatial.neighbor"
containing the sparse matrix
representation of the spatial neighbor matrix (or matrices, see function
spatial.neighbor
).
x
can
be a matrix. In this case, a solution is obtained for each column in
x
.
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
.
S
(see
argument
transpose
).
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.
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)'
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.
TRUE
, pivot selection should be confined to the diagonal if possible.
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
.
b
, solving the linear system
Sb=x
.
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.
Kundert, Kenneth S. and Sangiovanni-Vincentelli, Alberto (1988). A Sparse Linear Equation Solver. Department of EE and CS, University of California, Berkeley.
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)