Overview
Giac provides comprehensive row reduction algorithms for solving linear systems, computing reduced row echelon form (RREF), and related operations. The core function ismrref with various algorithm options.
Algorithm Types
Standard Gauss-Jordan elimination
Automatic algorithm selection (recommended)
Bareiss algorithm (fraction-free)
Modular algorithm
p-adic algorithm
Lagrange interpolation
Core Row Reduction
mrref
Compute reduced row echelon form with extensive options.Parameters
Input matrix
Output reduced matrix
Output vector of pivot positions
Output determinant (if computing)
Starting row (0-indexed)
Ending row (exclusive)
Starting column (0-indexed)
Ending column (exclusive)
- 0: Reduction below diagonal only
- non-zero: Full reduction (above and below diagonal)
For rows < this value, search for pivot in the row instead of column (no row swaps)
Convert to rational fractions internally
Algorithm selection (see matrix_algorithms enum)
- 0: RREF computation
- 1: Determinant computation
- 2: LU decomposition
- 3: LU without permutation
- 0: Failure
- 1: Success
- 2: Success with inversion (no need to remove identity)
Simple Usage
_rref
modrref
Modular row reduction.Modulo value for arithmetic
Check if modulo is prime
true if reduction successful
Specialized Row Reduction
smallmodrref
Efficient integer modular RREF for small moduli.Number of threads for parallel computation
Input/output integer matrix
Modulo value (must be < 2^31)
Enable block algorithm optimization
doublerref
Floating-point RREF.Input/output double-precision matrix
Tolerance for zero detection
Linear Combinations
linear_combination
Compute linear combination of two vectors.Coefficient for first vector
First vector
Coefficient for second vector
Second vector
Scaling factor
Inverse of c (for optimization)
Output result vector
Tolerance: values with ||v|| < eps are replaced by 0
Starting index for operation
modlinear_combination
Modular linear combination.First vector (modified in place)
Coefficient for second vector
Second vector
Modulo value
Starting index
Ending index (0 means end of vector)
System Solving
p-adic Linear System Solving
padic_linsolve
Solve a linear system using p-adic methods.Coefficient matrix (integer entries)
Right-hand side vector (integer entries)
Output solution vector
Prime for p-adic computation
Determinant mod p
Auxiliary parameter
Rational reconstruction parameter
Maximum number of attempts
- 0: No invertible element found
- -1: Determinant is zero (no solution)
- 1: Success
_padic_linsolve
padic_linsolve_prepare
Prepare for solving non-Cramer systems.Output: row indices for maximal rank submatrix
Output: column indices for maximal rank submatrix
Output: maximal rank submatrix
Output: inverse of asub mod p
Output: compatibility conditions
Output: kernel basis
Rank of matrix, or -1 on failure
padic_linsolve_solve
Solve using prepared system.Indefinite System Solving
System matrix (LDL factorization)
Right-hand side
Output solution
Number of positive eigenvalues
Number of negative eigenvalues
Number of zero eigenvalues
true if solve successful
Utility Functions
mdividebypivot
Divide matrix rows by their pivot elements.Matrix to modify (in-place)
- -1: Divide last column
- -2: Do not divide last column
- ≥0: Stop dividing at this column
add_identity
Append identity matrix to the right.Matrix to augment (modified in-place)
remove_identity
Remove identity matrix from augmented result.Augmented matrix (modified in-place)
true if identity was found and removed
Quadratic Forms (gauss.h)
gauss
Gaussian reduction of quadratic forms.Quadratic form (symbolic expression)
Vector of variables
Output diagonal coefficients
Output transformation matrix
Output change of variables
Reduced quadratic form data
_gauss
quad
Find matrix of a quadratic form.Output: form degree (2 if purely quadratic, 0/1/3 if contains terms of other degrees)
Symbolic quadratic expression
Variables
Matrix representation of quadratic form
q2a and a2q
Convert between quadratic forms and matrices._q2a, _a2q
Conic Sections
conique_reduite
Reduce a conic equation to standard form.- 0: Not a conic
- Less than 0: Not a proper conic
- 2: Parabola
- 3: Ellipse
- 4: Hyperbola
_conique_reduite
See Also
- Vector Operations - Vector arithmetic and utilities
- Matrix Operations - Higher-level matrix operations
