Binary operators
next -
skip -
up -
start
The package supports binary operations
X = A + B // matrix addition
X = A - B // matrix subtraction
X = A * B // matrix multiplication
X = A.i() * B // equation solve (square matrix A)
X = A | B // concatenate horizontally (concatenate the rows)
X = A & B // concatenate vertically (concatenate the columns)
X = SP(A, B) // elementwise product of A and B (Schur product)
Notes:
- If you are doing repeated multiplication. For example A*B*C, use
brackets to force the order of evaluation to minimize the number of
operations. If C is a column vector and A is not a vector,
then it will usually reduce the number of operations to use A*(B*C).
- In the equation solve example case the inverse is not explicitly
calculated. An LU decomposition of A is performed and this is
applied to B. This is more efficient than calculating the inverse and
then multiplying.
See also multiple matrix solving.
- The package does not (yet?) recognise B*A.i() as an equation
solve and the inverse of A would be calculated.
It is probably better to use (A.t().i()*B.t()).t().
- Horizontal or vertical concatenation returns a result of type Matrix,
RowVector or ColumnVector.
- If A is m x p, B is m x q, then A | B is m x
(p+q) with the k-th row being the elements of the k-th row of A
followed by the elements of the k-th row of B.
- If A is p x n, B is q x n, then A & B is (p+q)
x n with the k-th column being the elements of the k-th column of A
followed by the elements of the k-th column of B.
- For complicated concatenations of matrices, consider instead using
submatrices.