6#include "densematrix.hh"
19 HDNUM_ERROR(
"need square and nonempty matrix");
21 HDNUM_ERROR(
"permutation vector incompatible with matrix");
40 if (A[
k][
k]==0) HDNUM_ERROR(
"matrix is singular");
68 HDNUM_ERROR(
"need square and nonempty matrix");
70 HDNUM_ERROR(
"permutation vector incompatible with matrix");
92 if (A[
k][
k]==0) HDNUM_ERROR(
"matrix is singular");
110 HDNUM_ERROR(
"need square and nonempty matrix");
112 HDNUM_ERROR(
"permutation vector incompatible with matrix");
123 for (std::size_t s=
k; s<A.
colsize(); ++s)
134 A[
k][
j] = A[
p[
k]][
j];
141 A[
i][
k] = A[
i][
q[
k]];
145 if (std::abs(A[
k][
k])==0) HDNUM_ERROR(
"matrix is singular");
162 if (b.size()!=
p.size())
163 HDNUM_ERROR(
"permutation vector incompatible with rhs");
165 for (std::size_t
k=0;
k<b.size()-1; ++
k)
166 if (
p[
k]!=
k) std::swap(b[
k],b[
p[
k]]);
173 if (
z.size()!=
q.size())
174 HDNUM_ERROR(
"permutation vector incompatible with z");
176 for (
int k=
z.size()-2;
k>=0; --
k)
177 if (
q[
k]!=std::size_t(
k)) std::swap(
z[
k],
z[
q[
k]]);
185 HDNUM_ERROR(
"need nonempty matrix");
187 HDNUM_ERROR(
"scaling vector incompatible with matrix");
195 if (std::abs(s[
k])==0) HDNUM_ERROR(
"row sum is zero");
205 if (s.size()!=b.size())
206 HDNUM_ERROR(
"s and b incompatible");
209 for (std::size_t
k=0;
k<b.size(); ++
k)
218 HDNUM_ERROR(
"need square and nonempty matrix");
220 HDNUM_ERROR(
"right hand side incompatible with matrix");
225 for (std::size_t
j=0;
j<
i;
j++)
236 HDNUM_ERROR(
"need square and nonempty matrix");
238 HDNUM_ERROR(
"right hand side incompatible with matrix");
254 HDNUM_ERROR(
"need square and nonempty matrix");
256 HDNUM_ERROR(
"right hand side incompatible with matrix");
Class with mathematical matrix operations.
Definition densematrix.hh:33
size_t rowsize() const
get number of rows of the matrix
Definition densematrix.hh:136
size_t colsize() const
get number of columns of the matrix
Definition densematrix.hh:153
void permute_forward(const Vector< std::size_t > &p, Vector< T > &b)
apply permutations to a right hand side vector
Definition lr.hh:160
T abs(const T &t)
our own abs class that works also for multiprecision types
Definition lr.hh:55
void linsolve(DenseMatrix< T > &A, Vector< T > &x, Vector< T > &b)
a complete solver; Note A, x and b are modified!
Definition lr.hh:251
void lr_fullpivot(DenseMatrix< T > &A, Vector< std::size_t > &p, Vector< std::size_t > &q)
lr decomposition of A with full pivoting
Definition lr.hh:107
void permute_backward(const Vector< std::size_t > &q, Vector< T > &z)
apply permutations to a solution vector
Definition lr.hh:171
void apply_equilibrate(Vector< T > &s, Vector< T > &b)
apply row equilibration to right hand side vector
Definition lr.hh:203
void lr(DenseMatrix< T > &A, Vector< std::size_t > &p)
compute lr decomposition of A with first nonzero pivoting
Definition lr.hh:16
void solveR(const DenseMatrix< T > &A, Vector< T > &x, const Vector< T > &b)
Assume R = upper triangle of A and solve R x = b.
Definition lr.hh:233
void lr_partialpivot(DenseMatrix< T > &A, Vector< std::size_t > &p)
lr decomposition of A with column pivoting
Definition lr.hh:65
void solveL(const DenseMatrix< T > &A, Vector< T > &x, const Vector< T > &b)
Assume L = lower triangle of A with l_ii=1, solve L x = b.
Definition lr.hh:215
void row_equilibrate(DenseMatrix< T > &A, Vector< T > &s)
perform a row equilibration of a matrix; return scaling for later use
Definition lr.hh:182