rowops {cmna} | R Documentation |
Elementary row operations
Description
These are elementary operations for a matrix. They do not presume a square matrix and will work on any matrix. They use R's internal row addressing to function.
Usage
swaprows(m, row1, row2)
replacerow(m, row1, row2, k)
scalerow(m, row, k)
Arguments
m |
a matrix |
row1 |
a source row |
row2 |
a destination row |
k |
a scaling factor |
row |
a row to modify |
Details
replacerow
replaces one row with the sum of itself and the
multiple of another row. swaprows
swap two rows in the
matrix. scalerow
scales all enteries in a row by a constant.
Value
the modified matrix
See Also
Other linear:
choleskymatrix()
,
detmatrix()
,
gdls()
,
invmatrix()
,
iterativematrix
,
lumatrix()
,
refmatrix()
,
tridiagmatrix()
,
vecnorm()
Examples
n <- 5
A <- matrix(sample.int(10, n^2, TRUE) - 1, n)
A <- swaprows(A, 2, 4)
A <- replacerow(A, 1, 3, 2)
A <- scalerow(A, 5, 10)
[Package cmna version 1.0.5 Index]