22#ifndef linear_algebrad_h
23#define linear_algebrad_h
25#include "square_matrix.h"
27#include "row_vector.h"
28#include "diagonal_matrix.h"
29#include "symmetric_matrix.h"
30#include "band_matrix.h"
42 FMATVEC_EXPORT
int svd(Matrix<General, Ref, Ref, double> &A, Matrix<General, Ref, Ref, double> &S, SquareMatrix<Ref, double> &U, SquareMatrix<Ref, double> &VT,
int Rueckgabe);
50 FMATVEC_EXPORT Vector<Ref, std::complex<double>>
eigval(
const SquareMatrix<Ref, double> &A);
60 FMATVEC_EXPORT
int eigvec(
const SquareMatrix<Ref, double> &A, SquareMatrix<Ref, std::complex<double>> &V, Vector<Ref, std::complex<double>> &w);
72 FMATVEC_EXPORT
int eigvec(
const Matrix<Symmetric, Ref, Ref, double> &A,
const Matrix<Symmetric, Ref, Ref, double> &B, SquareMatrix<Ref, double> &eigenvectors, Vector<Ref, double> &eigenvalues);
80 FMATVEC_EXPORT Vector<Ref, double>
eigval(
const Matrix<Symmetric, Ref, Ref, double> &A);
93 FMATVEC_EXPORT Vector<Ref, double>
eigvalSel(
const Matrix<Symmetric, Ref, Ref, double> &A,
int il,
int iu,
double abstol = 0);
127 FMATVEC_EXPORT Matrix<General, Ref, Ref, double>
slvLU(
const SquareMatrix<Ref, double> &A,
const Matrix<General, Ref, Ref, double> &X);
128 FMATVEC_EXPORT Matrix<General, Var, Var, double>
slvLU(
const SquareMatrix<Var, double> &A,
const Matrix<General, Var, Var, double> &X,
int & info);
139 FMATVEC_EXPORT Vector<Ref, double>
slvLU(
const SquareMatrix<Ref, double> &A,
const Vector<Ref, double> &x);
151 FMATVEC_EXPORT Vector<Ref, double>
slvLU(
const SquareMatrix<Ref, double> &A,
const Vector<Ref, double> &x,
int & info);
152 FMATVEC_EXPORT Vector<Var, double>
slvLU(
const SquareMatrix<Var, double> &A,
const Vector<Var, double> &x,
int & info);
164 FMATVEC_EXPORT Matrix<General, Ref, Ref, double>
slvLUFac(
const SquareMatrix<Ref, double> &A,
const Matrix<General, Ref, Ref, double> &X,
const Vector<Ref, int> &ipiv);
165 FMATVEC_EXPORT Matrix<General, Var, Var, double>
slvLUFac(
const SquareMatrix<Var, double> &A,
const Matrix<General, Var, Var, double> &X,
const Vector<Var, int> &ipiv);
177 FMATVEC_EXPORT Vector<Ref, double>
slvLUFac(
const SquareMatrix<Ref, double> &A,
const Vector<Ref, double> &x,
const Vector<Ref, int> &ipiv);
178 FMATVEC_EXPORT Vector<Var, double>
slvLUFac(
const SquareMatrix<Var, double> &A,
const Vector<Var, double> &x,
const Vector<Var, int> &ipiv);
189 FMATVEC_EXPORT Matrix<General, Ref, Ref, double>
slvLL(
const Matrix<Symmetric, Ref, Ref, double> &A,
const Matrix<General, Ref, Ref, double> &X);
200 FMATVEC_EXPORT Vector<Ref, double>
slvLL(
const Matrix<Symmetric, Ref, Ref, double> &A,
const Vector<Ref, double> &x);
211 FMATVEC_EXPORT Matrix<General, Ref, Ref, double>
slvQR(
const SquareMatrix<Ref, double> &A,
const Matrix<General, Ref, Ref, double> &X);
222 FMATVEC_EXPORT Vector<Ref, double>
slvQR(
const SquareMatrix<Ref, double> &A,
const Vector<Ref, double> &x);
233 FMATVEC_EXPORT Vector<Ref, double>
slvQRLQ(
const Matrix<General, Ref, Ref, double> &A,
const Vector<Ref, double> &b);
244 FMATVEC_EXPORT Matrix<General, Ref, Ref, double>
slvQRLQ(
const Matrix<General, Ref, Ref, double> &A,
const Matrix<General, Ref, Ref, double> &B);
253 FMATVEC_EXPORT SquareMatrix<Ref, double>
inv(
const SquareMatrix<Ref, double> &A);
262 FMATVEC_EXPORT Matrix<Symmetric, Ref, Ref, double>
inv(
const Matrix<Symmetric, Ref, Ref, double> &A);
271 FMATVEC_EXPORT Matrix<Diagonal, Ref, Ref, double>
inv(
const Matrix<Diagonal, Ref, Ref, double> &A);
281 FMATVEC_EXPORT Matrix<General, Ref, Ref, double>
facLU(
const Matrix<General, Ref, Ref, double> &A, Vector<Ref, int> &ipiv);
291 FMATVEC_EXPORT SquareMatrix<Ref, double>
facLU(
const SquareMatrix<Ref, double> &A, Vector<Ref, int> &ipiv);
293 FMATVEC_EXPORT SquareMatrix<Var, double>
facLU(
const SquareMatrix<Var, double> &A, Vector<Var, int> &ipiv);
306 FMATVEC_EXPORT
int facLU(
double *A,
int pivot[],
int n);
315 FMATVEC_EXPORT Matrix<Symmetric, Ref, Ref, double>
facLL(
const Matrix<Symmetric, Ref, Ref, double> &A);
323 FMATVEC_EXPORT
double nrm1(
const Vector<Ref, double> &x);
331 FMATVEC_EXPORT
double nrm2(
const Vector<Ref, double> &x);
339 FMATVEC_EXPORT
double nrmInf(
const Vector<Ref, double> &x);
348 FMATVEC_EXPORT
double nrm1(
const Matrix<General, Ref, Ref, double> &A);
356 FMATVEC_EXPORT
double nrm2(
const Matrix<General, Ref, Ref, double> &A);
365 FMATVEC_EXPORT
double nrmInf(
const Matrix<General, Ref, Ref, double> &A);
374 FMATVEC_EXPORT
double nrmInf(
const Matrix<Symmetric, Ref, Ref, double> &A);
382 FMATVEC_EXPORT
double nrmFro(
const Matrix<General, Ref, Ref, double> &A);
390 FMATVEC_EXPORT
double rho(
const SquareMatrix<Ref, double> &A);
398 FMATVEC_EXPORT
double rho(
const Matrix<Symmetric, Ref, Ref, double> &A);
400 FMATVEC_EXPORT Vector<Ref, double> slvLLFac(
const Matrix<Symmetric, Ref, Ref, double> &A,
const Vector<Ref, double> &x);
402 FMATVEC_EXPORT Matrix<General, Ref, Ref, double> slvLLFac(
const Matrix<Symmetric, Ref, Ref, double> &A,
const Matrix<General, Ref, Ref, double> &X);
404 FMATVEC_EXPORT Matrix<General, Ref, Ref, double> slvLS(
const Matrix<General, Ref, Ref, double> &A,
const Matrix<General, Ref, Ref, double> &B,
double rcond = -1);
406 FMATVEC_EXPORT Vector<Ref, double> slvLS(
const Matrix<General, Ref, Ref, double> &A,
const Vector<Ref, double> &b,
double rcond = -1);
439 info =
facLU(LU(), ipiv, size);
451 SquareMatrix<Fixed<size>,
double>
facLU(
const SquareMatrix<Fixed<size>,
double> &A, Vector<Fixed<size>,
int> &ipiv) {
452 SquareMatrix<Fixed<size>,
double> LU = A;
453 facLU(LU(), ipiv(), size);
458 Vector<Fixed<size>,
double>
slvLUFac(
const SquareMatrix<Fixed<size>,
double> &ALU,
const Vector<Fixed<size>,
double> &b,
const Vector<Fixed<size>,
int> &ipiv,
int &info) {
459 Vector<Fixed<size>,
double> x;
460 Vector<Fixed<size>,
double> y = b;
465 template <
int size,
int nrrhs>
466 Matrix<General, Fixed<size>, Fixed<nrrhs>,
double>
slvLUFac(
const SquareMatrix<Fixed<size>,
double> &ALU,
const Matrix<General, Fixed<size>, Fixed<nrrhs>,
double> &B,
const Vector<Fixed<size>,
int> &ipiv,
int &info) {
467 Matrix<General, Fixed<size>, Fixed<nrrhs>,
double> X;
468 Vector<Fixed<size>,
double> x;
470 for(
int c=0; c<nrrhs; c++) {
471 Vector<Fixed<size>,
double> y = B.col(c);
481 Matrix<General, Fixed<size>, Var,
double>
slvLUFac(
const SquareMatrix<Fixed<size>,
double> &ALU,
const Matrix<General, Fixed<size>, Var,
double> &B,
const Vector<Fixed<size>,
int> &ipiv,
int &info) {
482 Matrix<General, Fixed<size>, Var,
double> X(size,B.cols());
483 Vector<Fixed<size>,
double> x;
485 for(
int c=0; c<B.cols(); c++) {
486 Vector<Fixed<size>,
double> y = B.col(c);
Namespace fmatvec.
Definition: _memory.cc:28
int svd(Matrix< General, Ref, Ref, double > &A, Matrix< General, Ref, Ref, double > &S, SquareMatrix< Ref, double > &U, SquareMatrix< Ref, double > &VT, int Rueckgabe)
Definition: linear_algebra_double.cc:779
int eigvec(const SquareMatrix< Ref, double > &A, SquareMatrix< Ref, std::complex< double > > &V, Vector< Ref, std::complex< double > > &w)
Eigenvectors and Eigenvalues.
Definition: linear_algebra_double.cc:715
double rho(const SquareMatrix< Ref, double > &A)
Spectral radius.
Definition: linear_algebra_double.cc:840
double nrm1(const Vector< Ref, double > &x)
1-norm
Definition: linear_algebra_double.cc:578
Vector< Ref, std::complex< double > > eigval(const SquareMatrix< Ref, double > &A)
Eigenvalues.
Definition: linear_algebra_double.cc:695
int Doolittle_LU_with_Pivoting_Solve(const double *A, double B[], const int pivot[], double x[], int n)
solve linear system with LU decomposed matrix
Definition: linear_algebra_double.cc:169
Vector< Ref, double > eigvalSel(const Matrix< Symmetric, Ref, Ref, double > &A, int il, int iu, double abstol)
Eigenvalues.
Definition: linear_algebra_double.cc:820
SquareMatrix< Ref, double > inv(const SquareMatrix< Ref, double > &A)
Inverse.
Definition: linear_algebra_double.cc:382
Matrix< General, Ref, Ref, double > slvQR(const SquareMatrix< Ref, double > &A, const Matrix< General, Ref, Ref, double > &X)
Systems of linear equations.
Definition: linear_algebra_double.cc:150
Vector< Ref, double > slvLL(const Matrix< Symmetric, Ref, Ref, double > &A, const Vector< Ref, double > &x)
System of linear equations.
Definition: linear_algebra_double.cc:603
double nrmFro(const Matrix< General, Ref, Ref, double > &A)
Frobenius-norm.
Definition: linear_algebra_double.cc:892
Vector< Ref, double > slvQRLQ(const Matrix< General, Ref, Ref, double > &A, const Vector< Ref, double > &b)
System of overdetermined or underdetermined linear equations.
Definition: linear_algebra_double.cc:340
Matrix< General, Ref, Ref, double > facLU(const Matrix< General, Ref, Ref, double > &A, Vector< Ref, int > &ipiv)
LU decomposition.
Definition: linear_algebra_double.cc:441
Matrix< General, Ref, Ref, double > slvLUFac(const SquareMatrix< Ref, double > &A, const Matrix< General, Ref, Ref, double > &X, const Vector< Ref, int > &ipiv)
Systems of linear equations.
Definition: linear_algebra_double.cc:103
Vector< Ref, std::complex< double > > slvLU(const SquareMatrix< Ref, std::complex< double > > &A, const Vector< Ref, std::complex< double > > &x)
System of linear equations.
Definition: linear_algebra_complex.cc:47
Matrix< Symmetric, Ref, Ref, double > facLL(const Matrix< Symmetric, Ref, Ref, double > &A)
LL decomposition.
Definition: linear_algebra_double.cc:559