Contents Previous Next Subchapters

Accessing A Single Row Or Column
Syntax matrix.row(row index)
matrix.col(column index)
See Also base , matrix element , and sequential rows or columns

Description
References a row or column of a matrix, where row index and column index are integer scalars. (If either of the indices is real, or double-precision, it is interpreted as an integer using the same convention as in the int function. )

Tutorial
If you enter
     x = {[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]}
     x.row(2)
O-Matrix will respond
     [ 5 , 6 , 7 , 8 ]
If you continue the example above by entering
     x.col(3)
O-Matrix will respond
     {
     3
     7
     11
     }
You can also use .row to assign a row and .col to assign a column. Continuing the previous example, if you type
     x.row(2) = fill(3.3, 1, 4)
     print type(x), x
O-Matrix will respond
     real {
     [ 1 , 2 , 3 , 4 ]
     [ 3.3 , 3.3 , 3.3 , 3.3 ]
     [ 9 , 10 , 11 , 12 ]
     }
Note that the result has the type corresponding to coercion between the type of the original matrix and the new row or column.