permutation {spam} | R Documentation |
Permute a Matrix
Description
Row and/or column permutes a (sparse) matrix.
Usage
permutation.spam(A, P=NULL, Q=NULL, ind=FALSE, check=TRUE)
Arguments
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. |
Details
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.
Value
A permuted matrix.
Author(s)
Reinhard Furrer
See Also
Examples
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]
[Package spam version 2.10-0 Index]