The exact return type is typename GenericVector::persistent_type .
Either a functor class satisfying the extended requirements for binary operations, or an untyped template of such a class wrapped into BuildBinary or BuildBinaryIt (preferably expressed via the convenience typedef from namespace polymake::operations.
This assertion is checked only in the DIMENSION_CHECKS compilation mode.
The exact return type is ListMatrix< SparseVector< typename GenericVector::element_type > > .
The exact return type is typename GenericMatrix::persistent_type .
Either a functor class satisfying the extended requirements for unary operations, or an untyped template of such a class wrapped into BuildUnary or BuildUnaryIt (preferably expressed via the convenience typedef from namespace polymake::operations.

### Prerequisits

    #include <linalg.h>
    using namespace polymake;

There is a very limited set of basic functions operating on all template vector and matrix classes. They are defined as template functions accepting any exact numerical type (first of all, Rational), and as floating-point specializations doing some rudimentary rounding error checking.

The main focus of our interest lies on the exact computations; if you need high-quality numerical solutions for floating-point input, you are definitely wrong here!

### Linear algebra

typename GenericMatrix::element_type det(const GenericMatrix&);
Calculate the determinant using the Gauss elimination method. The matrix must be square.
typename GenericMatrix::persistent_type inv(const GenericMatrix&) throw (degenerate_matrix);
Calculate the inverse matrix using the Gauss elimination method. The matrix must be square.
Vector lin_solve(const GenericMatrix& A, const GenericVector& B) throw (degenerate_matrix, infeasible);
Solve the linear equation system A∗X=B.
template <typename Iterator> Set<int> basis_vectors(Iterator v);
Scan the sequence of vectors, find the basis vectors, return their indices (ordinal numbers in the sequence, starting with 0).
Set<int> basis_rows(const GenericMatrix&); Set<int> basis_cols(const GenericMatrix&); std::pair< Set<int>, Set<int> > basis(const GenericMatrix&); std::pair< Set<int>, Set<int> > basis_affine(const GenericMatrix&);
Find a basis minor of the matrix, return its row indices, column indices, or both (first contains the rows, second - columns).
The affine version ignores the first column. It is designed for matrices containing homogeneous coordinates.
int rank(const GenericMatrix&);
Find the rank of a matrix.
Matrix null_space(const GenericMatrix& A); Matrix null_space(const GenericVector& V); Matrix null_space_oriented(const GenericVector& V, int req_sign);
Find the linear subspace orthogonal to the rows of A or to V. The rows of the resulting matrix are basis vectors of the subspace. The result has always the same column dimension as A (or V.dim()), even if it has 0 rows.
The result of the oriented variant satisfies an additional restriction: sign( det(Result / V) )==req_sign .
template <typename VectorIterator, typename RowBasisOutputIterator, typename ColBasisOutputIterator, typename ElementType> void null_space (VectorIterator v, RowBasisOutputIterator row_basis_consumer, ColBasisOutputIterator col_basis_consumer, ListMatrix< SparseVector<ElementType> >& H);
Allows for incremental computation of the orthogonal subspace. H holds the basis to start with; it gets reduced in the course of iterating over v. v must be end-sensitive.
row_basis_consumer and col_basis_consumer should be output iterators consuming the row and column indices of the basis of the subspace spanned by v.
Vector proj(const GenericVector& u, const GenericVector& v);
Compute a projection of u to v.
template <typename Iterator> void orthogonalize(Iterator v); template <typename Iterator> void orthogonalize_affine(Iterator v);
Apply the Gram-Schmidt orthogonalization to the vector sequence. v must be end-sensitive.
The affine variant keeps the first coordinate untouched and does not involve it in the computations. It is designed for vectors containing homogeneous coordinates of hyperplanes, which should be made affinely orthogonal to each other.
template <typename Iterator, typename OutputIterator> void orthogonalize (Iterator v, OutputIterator sqr_consumer); template <typename Iterator, typename OutputIterator> void orthogonalize_affine (Iterator v, OutputIterator sqr_consumer);
Specialized versions of the Gram-Schmidt orthogonalization. sqr_consumer consumes the squares of the orthogonalized vectors.

## Exception types

They are all derived from std::runtime_error. The exceptions are raised in the following cases:

degenerate_matrix
A matrix has zero determinant.
infeasible
A linear equation system or linear problem are infeasible.
unbounded
A linear problem is unbounded.
not_pointed
A H-polyhedron (that is, given by inequalities) contains at least one affine line, and therefore cannot be unambiguously described as a vertex set. Currently polymake cannot handle such polyhedra.