vecvecindex {lazy.mat} | R Documentation |
Returns the index to convert vec(Mat) to vec(t(Mat)) and vice versa.
vecvecindex(nr, nc = nr)
nr |
# of rows |
nc |
# of columns |
Let A be nr x nc.
To create vec(t(A)) from vec(A), use
index=vecvecindex( nr,nc ) # same order as A matrix
vec(t(A)) == vec(A)[index]
To create vec(A) from vec(t(A)), use
index=vecvecindex( nc,nr ) # reverse order
vec(A) == vec(t(A))[index]
Can be used with character matrix.
Commutation matrix can be created by this index.
See lazy.mat::Kmat
function.
vector of index
A <- demomat(3,2) vecA <- vec(A); vectA <- vec(t(A)) i1 <- vecvecindex(3,2) vectA-vecA[i1] i2 <- vecvecindex(2,3) vecA-vectA[i2]