|
Contents | Previous | Next | Subchapters |
| Syntax |
matrix.row(row flag)matrix.col(column flag)matrix.blk(row flag, column flag)
|
| See Also | base , vector indices |
x = { [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]}
rowflag = {true, false, true}
x.row(rowflag)
O-Matrix will respond
{
[ 1 , 2 , 3 , 4 ]
[ 9 , 10 , 11 , 12 ]
}
If you continue by entering
colflag = [false, true, false, true]
x.col(colflag)
O-Matrix will respond
{
[ 2 , 4 ]
[ 6 , 8 ]
[ 10 , 12 ]
}
If you then enter
x.blk(rowflag, colflag)
O-Matrix will respond
{
[ 2 , 4 ]
[ 10 , 12 ]
}
You can also use logical row and column vectors to assign
a value to a submatrix.
The result has the type that corresponds to coercion
between the type of the original matrix and the
type of the submatrix.
If you continue the previous example by entering
x.blk(rowflag, colflag) = {[0, -1.1], [-1.1, 0]}
print type(x), x
O-Matrix will respond
real {
[ 1 , 0 , 3 , -1.1 ]
[ 5 , 6 , 7 , 8 ]
[ 9 , -1.1 , 11 , 0 ]
}
If you then enter
x.row(rowflag) = {[4, 3, 2, 1], [12, 11, 10, 9]}
x
O-Matrix will respond
{
[ 4 , 3 , 2 , 1 ]
[ 5 , 6 , 7 , 8 ]
[ 12 , 11 , 10 , 9 ]
}
If you continue by entering
x.col(colflag) = [{11, 6, 3}, {9, 8, 1}]
print x
O-Matrix will respond
{
[ 4 , 11 , 2 , 9 ]
[ 5 , 6 , 7 , 8 ]
[ 12 , 3 , 10 , 1 ]
}
x = seq(4)
y = seq(5)'
z = x * y
z.blk(x <= 3, y >= 3)
O-Matrix will respond
{
[ 3 , 4 , 5 ]
[ 6 , 8 , 10 ]
[ 9 , 12 , 15 ]
}