|
Macaulay2 Engine
|
Templated DMat<R> linear algebra: LU, rank, determinant, solve, inverse, nullSpace. More...
#include "util.hpp"#include "exceptions.hpp"#include "dmat.hpp"#include "aring-RR.hpp"#include "aring-CC.hpp"#include "aring-RRR.hpp"#include "aring-CCC.hpp"#include "aring-zzp.hpp"#include "aring-m2-gf.hpp"#include "aring-zzp-ffpack.hpp"#include "aring-zz-gmp.hpp"#include "aring-qq.hpp"#include "aring-zz-flint.hpp"#include "aring-zzp-flint.hpp"#include "aring-gf-flint-big.hpp"#include "aring-gf-flint.hpp"#include "lapack.hpp"#include "mat-arith.hpp"#include "dmat-lu.hpp"#include "dmat-qq-interface-flint.hpp"#include "eigen.hpp"#include <M2/gc-include.h>#include <flint/flint.h>#include <flint/fmpq_mat.h>#include <flint/fmpz.h>#include <flint/fmpz_mat.h>#include <flint/fq_nmod_mat.h>#include <flint/nmod_mat.h>#include <iostream>#include <algorithm>Go to the source code of this file.
Namespaces | |
| namespace | MatrixOps |
Macros | |
| #define | DMatZZpFFPACK DMat<ZZpFFPACK> |
Typedefs | |
| typedef DMat< M2::ARingZZp > | DMatZZp |
| typedef DMat< M2::ARingGFM2 > | DMatGFM2 |
| typedef M2::ARingZZpFFPACK | ZZpFFPACK |
| typedef DMat< M2::ARingZZGMP > | DMatZZGMP |
| typedef DMat< M2::ARingZZ > | DMatZZ |
| typedef DMat< M2::ARingQQ > | DMatQQ |
| typedef DMat< M2::ARingQQFlint > | DMatQQFlint |
| typedef DMat< M2::ARingZZpFlint > | DMatZZpFlint |
| typedef DMat< M2::ARingGFFlintBig > | DMatGFFlintBig |
| typedef DMat< M2::ARingGFFlint > | DMatGFFlint |
| typedef DMat< M2::ARingRRR > | DMatRRR |
| typedef DMat< M2::ARingCCC > | DMatCCC |
| typedef DMat< M2::ARingRR > | DMatRR |
| typedef DMat< M2::ARingCC > | DMatCC |
Functions | |
| template<typename Mat> | |
| size_t | MatrixOps::rank (const Mat &A) |
| the rank of a matrix | |
| template<typename Mat> | |
| void | MatrixOps::determinant (const Mat &A, typename Mat::ElementType &result_det) |
| the determinant of a square matrix | |
| template<typename Mat> | |
| bool | MatrixOps::inverse (const Mat &A, Mat &result_inv) |
| the inverse of a square matrix | |
| template<typename Mat> | |
| size_t | MatrixOps::rowReducedEchelonForm (const Mat &A, Mat &result_rref) |
| the row reduced echelon form of a matrix over a field, or ZZ. | |
| template<typename Mat> | |
| void | MatrixOps::mult (const Mat &A, const Mat &B, Mat &result_product) |
| the product of two matrices | |
| template<typename Mat> | |
| size_t | MatrixOps::nullSpace (const Mat &A, Mat &result_nullspace) |
| the null space of a matrix | |
| template<typename Mat> | |
| bool | MatrixOps::solveLinear (const Mat &A, const Mat &B, Mat &X) |
| solve AX=B, return true if the system has a solution. | |
| template<typename Mat> | |
| bool | MatrixOps::solveInvertible (const Mat &A, const Mat &B, Mat &X) |
| solve AX=B, where A is a square (invertible) matrix. | |
| template<typename Mat> | |
| M2_arrayintOrNull | MatrixOps::rankProfile (const Mat &A, bool row_profile) |
| Returns either the row or column rank profile of A. | |
| template<typename Mat> | |
| void | MatrixOps::addMultipleTo (Mat &C, const Mat &A, const Mat &B) |
| Set C += A*B. | |
| template<typename Mat> | |
| void | MatrixOps::subtractMultipleTo (Mat &C, const Mat &A, const Mat &B) |
| Set C -= A*B. | |
| template<typename Mat> | |
| M2_arrayintOrNull | MatrixOps::LU (const Mat &A, Mat &L, Mat &U) |
| template<typename Mat> | |
| M2_arrayintOrNull | MatrixOps::LUincremental (std::vector< size_t > &P, Mat &LU, const Mat &v, int i) |
| template<typename Mat> | |
| void | MatrixOps::triangularSolve (Mat &Lv, Mat &x, int m, int strategy) |
| template<typename Mat, typename Mat2> | |
| bool | MatrixOps::eigenvalues (const Mat &A, Mat2 &eigenvals) |
| template<typename Mat, typename Mat2> | |
| bool | MatrixOps::eigenvaluesHermitian (const Mat &A, Mat2 &eigenvals) |
| template<typename Mat, typename Mat2, typename Mat3> | |
| bool | MatrixOps::eigenvectors (const Mat &A, Mat2 &eigenvals, Mat3 &eigenvecs) |
| template<typename Mat, typename Mat2, typename Mat3> | |
| bool | MatrixOps::eigenvectorsHermitian (const Mat &A, Mat2 &eigenvals, Mat3 &eigenvecs) |
| template<typename Mat> | |
| bool | MatrixOps::leastSquares (const Mat &A, const Mat &B, Mat &X, bool assume_full_rank) |
| template<typename Mat, typename Mat2> | |
| bool | MatrixOps::SVD (const Mat &A, Mat2 &Sigma, Mat &U, Mat &Vt, int strategy) |
| template<typename Mat, typename Mat2, typename Mat3> | |
| bool | MatrixOps::QR (const Mat &A, Mat2 &Q, Mat3 &R, bool return_QR) |
| template<typename T> | |
| void | MatrixOps::clean (gmp_RR epsilon, T &mat) |
| template<typename T> | |
| void | MatrixOps::increase_norm (gmp_RRmutable nm, const T &mat) |
| template<typename RT> | |
| void | MatrixOps::mult (const DMat< RT > &A, const DMat< RT > &B, DMat< RT > &result_product) |
| template<typename RT> | |
| void | MatrixOps::addMultipleTo (DMat< RT > &C, const DMat< RT > &A, const DMat< RT > &B) |
| template<typename RT> | |
| void | MatrixOps::subtractMultipleTo (DMat< RT > &C, const DMat< RT > &A, const DMat< RT > &B) |
| template<typename RT> | |
| void | MatrixOps::determinant (const DMat< RT > &A, typename RT::ElementType &result) |
| template<typename RT> | |
| M2_arrayintOrNull | MatrixOps::LU (const DMat< RT > &A, DMat< RT > &L, DMat< RT > &U) |
| template<typename RT> | |
| void | MatrixOps::triangularSolve (DMat< RT > &Lv, DMat< RT > &x, int m, int strategy) |
| template<typename RT> | |
| M2_arrayintOrNull | MatrixOps::LUincremental (std::vector< size_t > &P, DMat< RT > &LU, const DMat< RT > &v, int m) |
| template<typename RT> | |
| size_t | MatrixOps::rank (const DMat< RT > &A) |
| template<typename RT> | |
| M2_arrayintOrNull | MatrixOps::rankProfile (const DMat< RT > &A, bool row_profile) |
| template<typename RT> | |
| bool | MatrixOps::inverse (const DMat< RT > &A, DMat< RT > &result_inv) |
| template<typename RT> | |
| size_t | MatrixOps::nullSpace (const DMat< RT > &A, DMat< RT > &result_nullspace) |
| template<typename RT> | |
| bool | MatrixOps::solveLinear (const DMat< RT > &A, const DMat< RT > &B, DMat< RT > &X) |
| template<typename RT> | |
| bool | MatrixOps::solveInvertible (const DMat< RT > &A, const DMat< RT > &B, DMat< RT > &X) |
| void | MatrixOps::mult (const DMatZZpFFPACK &A, const DMatZZpFFPACK &B, DMatZZpFFPACK &C) |
| void | MatrixOps::addMultipleTo (DMatZZpFFPACK &C, const DMatZZpFFPACK &A, const DMatZZpFFPACK &B) |
| void | MatrixOps::subtractMultipleTo (DMatZZpFFPACK &C, const DMatZZpFFPACK &A, const DMatZZpFFPACK &B) |
| M2_arrayintOrNull | MatrixOps::LU (const DMatZZGMP &A, DMatZZGMP &L, DMatZZGMP &U) |
| M2_arrayintOrNull | MatrixOps::rankProfile (const DMatZZGMP &A, bool row_profile) |
| bool | MatrixOps::inverse (const DMatZZGMP &A, DMatZZGMP &result_inv) |
| size_t | MatrixOps::nullSpace (const DMatZZGMP &A, DMatZZGMP &result_nullspace) |
| bool | MatrixOps::solveLinear (const DMatZZGMP &A, const DMatZZGMP &B, DMatZZGMP &X) |
| bool | MatrixOps::solveInvertible (const DMatZZGMP &A, const DMatZZGMP &B, DMatZZGMP &X) |
| void | MatrixOps::mult (const DMatZZGMP &A, const DMatZZGMP &B, DMatZZGMP &result_product) |
| void | MatrixOps::addMultipleTo (DMatZZGMP &C, const DMatZZGMP &A, const DMatZZGMP &B) |
| void | MatrixOps::subtractMultipleTo (DMatZZGMP &C, const DMatZZGMP &A, const DMatZZGMP &B) |
| size_t | MatrixOps::rank (const DMatZZGMP &A) |
| void | MatrixOps::determinant (const DMatZZGMP &A, M2::ARingZZGMP::ElementType &result_det) |
| size_t | MatrixOps::rank (const DMatZZ &A) |
| void | MatrixOps::determinant (const DMatZZ &A, M2::ARingZZ::ElementType &result_det) |
| bool | MatrixOps::inverse (const DMatZZ &A, DMatZZ &result_inv) |
| void | MatrixOps::mult (const DMatZZ &A, const DMatZZ &B, DMatZZ &result_product) |
| size_t | MatrixOps::nullSpace (const DMatZZ &A, DMatZZ &result_nullspace) |
| bool | MatrixOps::solveLinear (const DMatZZ &A, const DMatZZ &B, DMatZZ &X) |
| M2_arrayintOrNull | MatrixOps::rankProfile (const DMatZZ &A, bool row_profile) |
| void | MatrixOps::addMultipleTo (DMatZZ &C, const DMatZZ &A, const DMatZZ &B) |
| void | MatrixOps::subtractMultipleTo (DMatZZ &C, const DMatZZ &A, const DMatZZ &B) |
| void | MatrixOps::addMultipleTo (DMatZZpFlint &C, const DMatZZpFlint &A, const DMatZZpFlint &B) |
| void | MatrixOps::subtractMultipleTo (DMatZZpFlint &C, const DMatZZpFlint &A, const DMatZZpFlint &B) |
| void | MatrixOps::mult (const DMatZZpFlint &A, const DMatZZpFlint &B, DMatZZpFlint &result_product) |
| size_t | MatrixOps::rowReducedEchelonForm (const DMatZZpFlint &A, DMatZZpFlint &result_rref) |
| void | MatrixOps::addMultipleTo (DMatGFFlintBig &C, const DMatGFFlintBig &A, const DMatGFFlintBig &B) |
| void | MatrixOps::subtractMultipleTo (DMatGFFlintBig &C, const DMatGFFlintBig &A, const DMatGFFlintBig &B) |
| void | MatrixOps::mult (const DMatGFFlintBig &A, const DMatGFFlintBig &B, DMatGFFlintBig &result_product) |
| size_t | MatrixOps::rowReducedEchelonForm (const DMatGFFlintBig &A, DMatGFFlintBig &result_rref) |
| void | MatrixOps::addMultipleTo (DMatGFFlint &C, const DMatGFFlint &A, const DMatGFFlint &B) |
| void | MatrixOps::subtractMultipleTo (DMatGFFlint &C, const DMatGFFlint &A, const DMatGFFlint &B) |
| void | MatrixOps::mult (const DMatGFFlint &A, const DMatGFFlint &B, DMatGFFlint &result_product) |
| size_t | MatrixOps::rowReducedEchelonForm (const DMatGFFlint &A, DMatGFFlint &result_rref) |
| void | MatrixOps::mult (const DMatQQ &A, const DMatQQ &B, DMatQQ &result_product) |
| void | MatrixOps::addMultipleTo (DMatQQ &C, const DMatQQ &A, const DMatQQ &B) |
| void | MatrixOps::subtractMultipleTo (DMatQQ &C, const DMatQQ &A, const DMatQQ &B) |
| size_t | MatrixOps::rowReducedEchelonForm (const DMatQQ &A, DMatQQ &result_rref) |
| size_t | MatrixOps::rank (const DMatQQFlint &A) |
| void | MatrixOps::determinant (const DMatQQFlint &A, M2::ARingQQFlint::ElementType &result_det) |
| bool | MatrixOps::inverse (const DMatQQFlint &A, DMatQQFlint &result_inv) |
| size_t | MatrixOps::rowReducedEchelonForm (const DMatQQFlint &A, DMatQQFlint &result_rref) |
| size_t | MatrixOps::nullSpace (const DMatQQFlint &A, DMatQQFlint &result_nullspace) |
| bool | MatrixOps::solveLinear (const DMatQQFlint &A, const DMatQQFlint &B, DMatQQFlint &X) |
| M2_arrayintOrNull | MatrixOps::rankProfile (const DMatQQFlint &A, bool row_profile) |
| void | MatrixOps::addMultipleTo (DMatQQFlint &C, const DMatQQFlint &A, const DMatQQFlint &B) |
| void | MatrixOps::subtractMultipleTo (DMatQQFlint &C, const DMatQQFlint &A, const DMatQQFlint &B) |
| void | MatrixOps::mult (const DMatQQFlint &A, const DMatQQFlint &B, DMatQQFlint &result_product) |
| bool | MatrixOps::eigenvaluesHermitian (const DMatRR &A, DMatRR &eigenvals) |
| bool | MatrixOps::eigenvalues (const DMatRR &A, DMatCC &eigenvals) |
| bool | MatrixOps::eigenvectorsHermitian (const DMatRR &A, DMatRR &eigenvals, DMatRR &eigenvecs) |
| bool | MatrixOps::eigenvectors (const DMatRR &A, DMatCC &eigenvals, DMatCC &eigenvecs) |
| bool | MatrixOps::leastSquares (const DMatRR &A, const DMatRR &B, DMatRR &X, bool assume_full_rank) |
| bool | MatrixOps::SVD (const DMatRR &A, DMatRR &Sigma, DMatRR &U, DMatRR &Vt, int strategy) |
| bool | MatrixOps::QR (const DMatRR &A, DMatRR &Q, DMatRR &R, bool return_QR) |
| bool | MatrixOps::QR (const DMatCC &A, DMatCC &Q, DMatCC &R, bool return_QR) |
| void | MatrixOps::clean (gmp_RR epsilon, DMatRR &mat) |
| void | MatrixOps::increase_norm (gmp_RRmutable norm, const DMatRR &mat) |
| bool | MatrixOps::eigenvaluesHermitian (const DMatCC &A, DMatRR &eigenvals) |
| bool | MatrixOps::eigenvalues (const DMatCC &A, DMatCC &eigenvals) |
| bool | MatrixOps::eigenvectorsHermitian (const DMatCC &A, DMatRR &eigenvals, DMatCC &eigenvecs) |
| bool | MatrixOps::eigenvectors (const DMatCC &A, DMatCC &eigenvals, DMatCC &eigenvecs) |
| bool | MatrixOps::leastSquares (const DMatCC &A, const DMatCC &B, DMatCC &X, bool assume_full_rank) |
| bool | MatrixOps::SVD (const DMatCC &A, DMatRR &Sigma, DMatCC &U, DMatCC &Vt, int strategy) |
| void | MatrixOps::clean (gmp_RR epsilon, DMatCC &mat) |
| void | MatrixOps::increase_norm (gmp_RRmutable norm, const DMatCC &mat) |
| bool | MatrixOps::eigenvaluesHermitian (const DMatRRR &A, DMatRRR &eigenvals) |
| bool | MatrixOps::eigenvalues (const DMatRRR &A, DMatCCC &eigenvals) |
| bool | MatrixOps::eigenvectorsHermitian (const DMatRRR &A, DMatRRR &eigenvals, DMatRRR &eigenvecs) |
| bool | MatrixOps::eigenvectors (const DMatRRR &A, DMatCCC &eigenvals, DMatCCC &eigenvecs) |
| bool | MatrixOps::leastSquares (const DMatRRR &A, const DMatRRR &B, DMatRRR &X, bool assume_full_rank) |
| bool | MatrixOps::SVD (const DMatRRR &A, DMatRRR &Sigma, DMatRRR &U, DMatRRR &Vt, int strategy) |
| void | MatrixOps::clean (gmp_RR epsilon, DMatRRR &mat) |
| void | MatrixOps::increase_norm (gmp_RRmutable norm, const DMatRRR &mat) |
| bool | MatrixOps::eigenvaluesHermitian (const DMatCCC &A, DMatRRR &eigenvals) |
| bool | MatrixOps::eigenvalues (const DMatCCC &A, DMatCCC &eigenvals) |
| bool | MatrixOps::eigenvectorsHermitian (const DMatCCC &A, DMatRRR &eigenvals, DMatCCC &eigenvecs) |
| bool | MatrixOps::eigenvectors (const DMatCCC &A, DMatCCC &eigenvals, DMatCCC &eigenvecs) |
| bool | MatrixOps::leastSquares (const DMatCCC &A, const DMatCCC &B, DMatCCC &X, bool assume_full_rank) |
| bool | MatrixOps::SVD (const DMatCCC &A, DMatRRR &Sigma, DMatCCC &U, DMatCCC &Vt, int strategy) |
| void | MatrixOps::clean (gmp_RR epsilon, DMatCCC &mat) |
| void | MatrixOps::increase_norm (gmp_RRmutable norm, const DMatCCC &mat) |
Templated DMat<R> linear algebra: LU, rank, determinant, solve, inverse, nullSpace.
Declares the dense linear-algebra surface as free function templates over RT (the aring coefficient type) so a single generic body covers every supported ring; specialisations route to the fastest available back end at compile time. FFLAS-FFPACK handles small Z/p (DMatZZpFFPACK); FLINT covers everything else over finite, integer, and rational coefficients — nmod_mat for DMatZZpFlint, fmpz_mat for DMatZZ / DMatZZGMP, fmpq_mat for DMatQQFlint, and fq_zech_mat / fq_nmod_mat for DMatGFFlint / DMatGFFlintBig. LAPACK is the default path for hardware- precision RR / CC (DMatRR / DMatCC via lapack.hpp), with the Eigen3-backed EigenM2 namespace in eigen.hpp as the #ifdef NO_LAPACK fallback. Arbitrary-precision RR / CC (DMatRRR / DMatCCC) always go through Eigen3 with <unsupported/Eigen/MPRealSupport>. Z/p with small p (DMatZZp) and the M2-native GF (DMatGFM2) ride the generic templates. The header pulls in every aring it specialises on and defines the full DMat* alias inventory (DMatZZp, DMatZZpFFPACK, DMatZZpFlint, DMatGFM2, DMatGFFlint, DMatGFFlintBig, DMatZZGMP, DMatZZ, DMatQQ, DMatQQFlint, DMatRR, DMatCC, DMatRRR, DMatCCC).
This file is what MutableMatrix (mat.hpp) forwards into for the heavy operations and is the natural complement to the arithmetic primitives in mat-arith.hpp and the elementary row / column operations in mat-elem-ops.hpp.
Definition in file mat-linalg.hpp.