Overview
Matrices in Giac are represented as vectors of vectors. Thematrice type is an alias for vecteur, where each element is itself a vecteur representing a row.
Type Definition
vecteur where each element is a vecteur (row vector).
Matrix Properties
ckmatrix
Check if a structure is a valid matrix.Matrix to validate
Allow nested vectors
Check for undefined values
true if a is a valid matrix
is_squarematrix
Check if a matrix is square.Matrix to check
true if matrix has equal rows and columns
Matrix Dimensions
Input matrix
Number of rows (mrows) or columns (mcols)
Matrix Construction
midn
Create an identity matrix.Size of the identity matrix
n×n identity matrix
_idn
Example:
mranm
Generate a random matrix.Number of rows
Number of columns
Random element generator function
n×m random matrix
_ranm
makefreematrice
Create a matrix with modifiable rows.Input matrix
Matrix with independent row vectors (safe for in-place modification)
Matrix Operations
mtran
Transpose a matrix.Matrix to transpose
Expected number of columns in result
Transposed matrix
_tran
mmult
Matrix multiplication.First matrix
Second matrix
Product matrix a × b
mmult assumes dimensions are compatible. Use mmultck for dimension checking.Matrix-Vector Operations
Matrix
Vector
Result of matrix-vector multiplication
mtrace
Compute matrix trace.Square matrix
Sum of diagonal elements
_trace
Determinant and Inverse
mdet
Compute matrix determinant.Square matrix
Determinant of a
_det
minv
Compute matrix inverse.Square matrix to invert
Convert to internal representation
Algorithm selection (if unsure, use 1)
Inverse matrix a⁻¹
Returns empty matrix if a is singular.
Eigenvalues and Eigenvectors
megvl
Compute eigenvalues.Square matrix
Vector of eigenvalues
_egvl
megv
Compute eigenvectors.Square matrix
Matrix of eigenvectors
_egv
egv
Full eigenvalue decomposition.Input square matrix
Output eigenvector matrix
Output eigenvalues (or Jordan form if jordan=true)
Return Jordan form instead of diagonal
Use rational Jordan form
Only compute eigenvalues
true if successful
Characteristic Polynomial
mpcar
Compute characteristic polynomial.Square matrix
Output parameter for additional computation
Whether to compute B parameter
Coefficients of characteristic polynomial
_pcar
Kernel and Image
mker
Compute kernel (null space) of a matrix.Input matrix
Algorithm selection
Basis vectors for the kernel
_ker
mimage
Compute image (column space) of a matrix.Input matrix
Basis vectors for the column space
_image
Matrix Decompositions
mlu
LU decomposition.Input matrix
Permutation vector
Lower triangular matrix
Upper triangular matrix
true if decomposition successful
_lu
QR Decomposition
Giac Command:_qr
Cholesky Decomposition
Giac Command:_cholesky
SVD (Singular Value Decomposition)
Giac Command:_svd
LDL Decomposition
Input/output matrix
Permutation vector
Matrix type indicator
Set to true if matrix is singular
Maximum computation time
true if decomposition successful
_ldl
Jordan Form
mjordan
Compute Jordan normal form.Square matrix
Use rational Jordan form
Jordan normal form decomposition
_jordan, _rat_jordan
Special Matrix Operations
matpow
Matrix power.Base matrix
Exponent
Matrix power mⁿ
_matpow
Hessenberg Form
_hessenberg
Gram-Schmidt Orthogonalization
Input matrix with column vectors
Normalize the output vectors
R matrix from QR decomposition
Orthogonalized matrix
LLL Algorithm
Input lattice basis
LLL-reduced basis
_lll
Integer Matrix Operations
Smith Normal Form
_ismith
Hermite Normal Form
_ihermite
See Also
- Vector Operations - Vector data structures and operations
- Gaussian Elimination - Row reduction algorithms
