You're not reading the latest revision of this page, which is
here.
Matrix Variables
How to create matrix variables
1. tex like syntax
To make a simple matrix variable you can use
\begin{variables}
...
\matrix{A}{
1 & 2 \\ %1st row of 2x2 matrix
3 & 4 %2nd row of 2x2 matrix
}
...
\end{variables}
|
you can also use number or function variables for the cells
\begin{variables}
\randint{a}{-5}{5}
\randint{b}{-5}{5}
\function[normalize]{c}{a+b}
\function[normalize]{d}{a-b}
\matrix{B}{
a & b \\ %1st row of 2x2 matrix
c & d %2nd row of 2x2 matrix
}
...
\end{variables}
|
2. python like syntax
The python like syntax is created to make create more complex matrices.
It supports matrix functions such as addition, multiplication, inverse and so on.
2.1 creating a simple matrix
a matrix in the python like syntax is a collection of row vectors with same number of columns, separated by semicolon.
\begin{variables}
...
\matrix{C}{[ [1;2] ; [3;4] ]} % 2x2 Matrix
...
\end{variables}
|
you can also create row vector variables and use it in your matrix
\begin{variables}
...
\randint{a}{-5}{5}
\randint{b}{-5}{5}
\rowVector{row1}{[a;b]}
\matrix{C}{[ row1 ; [3;4] ]} % 2x2 Matrix
...
\end{variables}
|
2.1 Matrix Operations
Supported Matrix Operations are:
- Scalar multiplication
- Matrix multiplication
- Addition and substraction
- Inverse
- Transpose
- Adjoint
- Determinant
- Trace
An exception will be thrown if the matrix is not suitable for the operations (e.g inverse on not invertible matrices, unsuitable format on matrix multiplication)
The operations trace and determinant will result in a 1x1 matrix. You can also use them in a function variable
\begin{variables}
...
\matrix{C}{[[1;2];[3;4]} % 2x2 Matrix
\matrix{D}{2*C} % Scalar multiplication
\matrix{E}{C*D} % Matrix multiplication
\matrix{F}{D+E-C} % addition and substraction
\matrix{G}{inv(C)} % inverse of matrix, will throw exception if matrix is not invertible
\matrix{H}{transpose(C)} % adjoint of matrix
\matrix{I}{adjoint(C)} % adjoint of matrix
\matrix{J}{det(C)} % determinant of C, result is 1x1 matrix
\matrix{K}{trace(C)} % trace of C, result is 1x1 matrix
\function{fj}{det(C)} % determinant of C but as a function
\function{fk}{trace(C)} % trace of C but as a function
...
\end{variables}
|
Indexing and Slicing