permutation | R Documentation |
Row and/or column permutes a (sparse) matrix.
permutation.spam(A, P=NULL, Q=NULL, ind=FALSE, check=TRUE)
A |
sparse matrix |
P |
vector giving the row permutation. |
Q |
vector giving the column permutation. |
ind |
are the indices given. See examples. |
check |
Should rudimentary checks be performed. |
If P and Q are permutation matrices, the result is
PAQ. However, it is also possible to specify the indices
and to perform in a very efficient way
A[rowind, colind]
, see examples.
A row permutation is much faster than a colum permutation. For very large matrices, a double transpose might be faster.
The spam option spam.checkpivot
determines if the permutation
is verified.
A permuted matrix.
Reinhard Furrer
ordering
, spam.options
.
A <- spam(1:12,3)
P <- c(3,1,2)
Q <- c(2,3,1,4)
permutation(A,P,Q)-A[order(P),order(Q)]
permutation(A,P,Q,ind=TRUE)-A[P,Q]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.