vecindex {lazy.mat}R Documentation

Returns the index to convert vec(Mat) to vec(t(Mat)) and vice versa.

Description

Returns the index to convert vec(Mat) to vec(t(Mat)) and vice versa.

Usage

vecindex(nr, nc = nr)

Arguments

nr

# of rows

nc

# of columns

Details

Let A be nr x nc.
To create vec(t(A)) from vec(A), use
index=vecindex( nr,nc ) # same order as A matrix
vec(t(A)) == vec(A)[index]

To create vec(A) from vec(t(A)), use
index=vecindex( nc,nr ) # reverse order
vec(A) == vec(t(A))[index]



Can be used with character matrix.

Value

vector of index

Examples

A <- demomat(3,2)
vecA <- vec(A); vectA <- vec(t(A))
i1 <- vecindex(3,2)
vectA-vecA[i1]
i2 <- vecindex(2,3)
vecA-vectA[i2]


[Package lazy.mat version 0.1.3 Index]