Description
Utility functions not te be used directly by the user.Usage
makeSparse(X)
ij2r(i,j,N)
indexSymmat2vec(i,j,N)
indexVec2Symmat(k,N)
Arguments
X
A matrix to be turned into a sparse matrix.
N
number of columns of a matrix
j
column index of a matrix
Details
makeSparse
turns a matrix into a sparse matrix using
sparseMatrix
of the Matrix
package.
ij2r
, indexSymmat2vec
and
indexVec2Symmat
are index functions.
Let Q[i,j]
be a quadratic matrix of dimesnion N and
q=Q[1,1],Q[1,2],...,Q[1,N],Q[2,1],..Q[N,N]
the row major
vectorization of the matrix.
Then Q[i,j]<-q[ij2r(r)]
.
Let S[i,j]
be a symmetric matrix of dimension N and
s=S[1,1],S[1,2],...,S[1,N],S[2,3],..,S[N-1,N],S[N,N]
the row major
vecotorization of the upper triangular part of S.
Then s[indexSymmat2vec(i,j,N)]<-S[i,j]
and
S[indexVec2Symmat(r,N)]<-s[r]
.