acb_mat.h – matrices over the complex numbers¶
An acb_mat_t
represents a dense matrix over the complex numbers,
implemented as an array of entries of type acb_struct
.
The dimension (number of rows and columns) of a matrix is fixed at initialization, and the user must ensure that inputs and outputs to an operation have compatible dimensions. The number of rows or columns in a matrix can be zero.
Types, macros and constants¶
-
acb_mat_struct
¶
-
acb_mat_t
¶ Contains a pointer to a flat array of the entries (entries), an array of pointers to the start of each row (rows), and the number of rows (r) and columns (c).
An acb_mat_t is defined as an array of length one of type acb_mat_struct, permitting an acb_mat_t to be passed by reference.
-
acb_mat_entry
(mat, i, j)¶ Macro giving a pointer to the entry at row i and column j.
-
acb_mat_nrows
(mat)¶ Returns the number of rows of the matrix.
-
acb_mat_ncols
(mat)¶ Returns the number of columns of the matrix.
Memory management¶
Conversions¶
-
void
acb_mat_set_fmpz_mat
(acb_mat_t dest, const fmpz_mat_t src)¶
-
void
acb_mat_set_round_fmpz_mat
(acb_mat_t dest, const fmpz_mat_t src, slong prec)¶
-
void
acb_mat_set_fmpq_mat
(acb_mat_t dest, const fmpq_mat_t src, slong prec)¶
Random generation¶
Input and output¶
Comparisons¶
-
int
acb_mat_equal
(const acb_mat_t mat1, const acb_mat_t mat2)¶ Returns nonzero iff the matrices have the same dimensions and identical entries.
-
int
acb_mat_overlaps
(const acb_mat_t mat1, const acb_mat_t mat2)¶ Returns nonzero iff the matrices have the same dimensions and each entry in mat1 overlaps with the corresponding entry in mat2.
-
int
acb_mat_contains_fmpz_mat
(const acb_mat_t mat1, const fmpz_mat_t mat2)¶
-
int
acb_mat_contains_fmpq_mat
(const acb_mat_t mat1, const fmpq_mat_t mat2)¶ Returns nonzero iff the matrices have the same dimensions and each entry in mat2 is contained in the corresponding entry in mat1.
-
int
acb_mat_eq
(const acb_mat_t mat1, const acb_mat_t mat2)¶ Returns nonzero iff mat1 and mat2 certainly represent the same matrix.
-
int
acb_mat_ne
(const acb_mat_t mat1, const acb_mat_t mat2)¶ Returns nonzero iff mat1 and mat2 certainly do not represent the same matrix.
-
int
acb_mat_is_real
(const acb_mat_t mat)¶ Returns nonzero iff all entries in mat have zero imaginary part.
Special matrices¶
Transpose¶
Norms¶
-
void
acb_mat_bound_inf_norm
(mag_t b, const acb_mat_t A)¶ Sets b to an upper bound for the infinity norm (i.e. the largest absolute value row sum) of A.
Arithmetic¶
-
void
acb_mat_neg
(acb_mat_t dest, const acb_mat_t src)¶ Sets dest to the exact negation of src. The operands must have the same dimensions.
-
void
acb_mat_add
(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec)¶ Sets res to the sum of mat1 and mat2. The operands must have the same dimensions.
-
void
acb_mat_sub
(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec)¶ Sets res to the difference of mat1 and mat2. The operands must have the same dimensions.
-
void
acb_mat_mul
(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec)¶ Sets res to the matrix product of mat1 and mat2. The operands must have compatible dimensions for matrix multiplication.
-
void
acb_mat_mul_entrywise
(acb_mat_t res, const acb_mat_t mat1, const acb_mat_t mat2, slong prec)¶ Sets res to the entrywise product of mat1 and mat2. The operands must have the same dimensions.
Scalar arithmetic¶
-
void
acb_mat_scalar_mul_2exp_si
(acb_mat_t B, const acb_mat_t A, slong c)¶ Sets B to A multiplied by \(2^c\).
-
void
acb_mat_scalar_addmul_acb
(acb_mat_t B, const acb_mat_t A, const acb_t c, slong prec)¶ Sets B to \(B + A \times c\).
Gaussian elimination and solving¶
-
int
acb_mat_lu
(slong * perm, acb_mat_t LU, const acb_mat_t A, slong prec)¶ Given an \(n \times n\) matrix \(A\), computes an LU decomposition \(PLU = A\) using Gaussian elimination with partial pivoting. The input and output matrices can be the same, performing the decomposition in-place.
Entry \(i\) in the permutation vector perm is set to the row index in the input matrix corresponding to row \(i\) in the output matrix.
The algorithm succeeds and returns nonzero if it can find \(n\) invertible (i.e. not containing zero) pivot entries. This guarantees that the matrix is invertible.
The algorithm fails and returns zero, leaving the entries in \(P\) and \(LU\) undefined, if it cannot find \(n\) invertible pivot elements. In this case, either the matrix is singular, the input matrix was computed to insufficient precision, or the LU decomposition was attempted at insufficient precision.
-
void
acb_mat_solve_lu_precomp
(acb_mat_t X, const slong * perm, const acb_mat_t LU, const acb_mat_t B, slong prec)¶ Solves \(AX = B\) given the precomputed nonsingular LU decomposition \(A = PLU\). The matrices \(X\) and \(B\) are allowed to be aliased with each other, but \(X\) is not allowed to be aliased with \(LU\).
-
int
acb_mat_solve
(acb_mat_t X, const acb_mat_t A, const acb_mat_t B, slong prec)¶ Solves \(AX = B\) where \(A\) is a nonsingular \(n \times n\) matrix and \(X\) and \(B\) are \(n \times m\) matrices, using LU decomposition.
If \(m > 0\) and \(A\) cannot be inverted numerically (indicating either that \(A\) is singular or that the precision is insufficient), the values in the output matrix are left undefined and zero is returned. A nonzero return value guarantees that \(A\) is invertible and that the exact solution matrix is contained in the output.
-
int
acb_mat_inv
(acb_mat_t X, const acb_mat_t A, slong prec)¶ Sets \(X = A^{-1}\) where \(A\) is a square matrix, computed by solving the system \(AX = I\).
If \(A\) cannot be inverted numerically (indicating either that \(A\) is singular or that the precision is insufficient), the values in the output matrix are left undefined and zero is returned. A nonzero return value guarantees that the matrix is invertible and that the exact inverse is contained in the output.
-
void
acb_mat_det
(acb_t det, const acb_mat_t A, slong prec)¶ Computes the determinant of the matrix, using Gaussian elimination with partial pivoting. If at some point an invertible pivot element cannot be found, the elimination is stopped and the magnitude of the determinant of the remaining submatrix is bounded using Hadamard’s inequality.
Characteristic polynomial¶
-
void
acb_mat_charpoly
(acb_poly_t cp, const acb_mat_t mat, slong prec)¶ Sets cp to the characteristic polynomial of mat which must be a square matrix. If the matrix has n rows, the underscore method requires space for \(n + 1\) output coefficients. Employs a division-free algorithm using \(O(n^4)\) operations.
Special functions¶
-
void
acb_mat_exp_taylor_sum
(acb_mat_t S, const acb_mat_t A, slong N, slong prec)¶ Sets S to the truncated exponential Taylor series \(S = \sum_{k=0}^{N-1} A^k / k!\). See
arb_mat_exp_taylor_sum()
for implementation notes.
-
void
acb_mat_exp
(acb_mat_t B, const acb_mat_t A, slong prec)¶ Sets B to the exponential of the matrix A, defined by the Taylor series
\[\exp(A) = \sum_{k=0}^{\infty} \frac{A^k}{k!}.\]The function is evaluated as \(\exp(A/2^r)^{2^r}\), where \(r\) is chosen to give rapid convergence of the Taylor series. Error bounds are computed as for
arb_mat_exp()
.