Using the C Math Library | ![]() ![]() |
Selecting a Matrix
Use a matrix index to select a matrix. A matrix index works just like a vector index, except the result is a matrix rather than a vector. For example, let B
be the index matrix:
1 2 3 2
mlfAssign(&X, mlfIndexRef(A, "(?)", B));
1 2 3 2
Note that the example matrix A
was chosen so thatmlfIndexRef(A,"(?)", X)
equals X
for all types of one-dimensional indexing. This is not generally the case. For example, if A
were changed to mlfAssign(&A, mlfMagic(mlfScalar(3)));
8 1 6 3 5 7 4 9 2
and B
remains the same, then mlfIndexRef(A, "(?)", B)
would equal
8 3 4 3
Note
In both cases, size(A(B)) is equal to size(B) . This is a fundamental property of one-dimensional indexing.
|
![]() | Selecting a Vector | Selecting the Entire Matrix As a Column Vector | ![]() |