20 #ifndef TENSOR_LINALG_H
21 #define TENSOR_LINALG_H
23 #include <tensor/tensor.h>
24 #include <tensor/sparse.h>
35 const RTensor
solve(
const RTensor &A,
const RTensor &B);
36 const CTensor
solve(
const CTensor &A,
const CTensor &B);
38 const RTensor
solve_with_svd(
const RTensor &A,
const RTensor &B,
double tol = 0.0);
39 const CTensor
solve_with_svd(
const CTensor &A,
const CTensor &B,
double tol = 0.0);
41 extern bool accurate_svd;
43 #define SVD_ECONOMIC true
44 RTensor
svd(RTensor A, RTensor *pU = 0, RTensor *pVT = 0,
bool economic = 0);
45 RTensor
svd(CTensor A, CTensor *pU = 0, CTensor *pVT = 0,
bool economic = 0);
48 const CTensor
eig(
const RTensor &A, CTensor *R = 0, CTensor *L = 0);
51 const CTensor
eig(
const CTensor &A, CTensor *R = 0, CTensor *L = 0);
54 size_t iter = 0,
double tol = 1e-11);
56 size_t iter = 0,
double tol = 1e-11);
58 size_t iter = 0,
double tol = 1e-11);
60 size_t iter = 0,
double tol = 1e-11);
62 RTensor
eig_sym(
const RTensor &A, RTensor *pR = 0);
63 RTensor
eig_sym(
const CTensor &A, CTensor *pR = 0);
65 const RTensor
expm(
const RTensor &A,
unsigned int order = 7);
66 const CTensor
expm(
const CTensor &A,
unsigned int order = 7);
81 CTensor
eigs(
const CTensor &A,
int eig_type,
size_t neig,
82 CTensor *vectors = NULL,
83 const tensor::cdouble *initial_guess = NULL);
86 CTensor
eigs(
const CSparse &A,
int eig_type,
size_t neig,
87 CTensor *vectors = NULL,
88 const tensor::cdouble *initial_guess = NULL);
91 RTensor
eigs(
const RTensor &A,
int eig_type,
size_t neig,
92 RTensor *vectors = NULL,
93 const double *initial_guess = NULL);
96 RTensor
eigs(
const RSparse &A,
int eig_type,
size_t neig,
97 RTensor *vectors = NULL,
98 const double *initial_guess = NULL);
101 RTensor
eigs_sym(
const RTensor &A,
int eig_type,
size_t neig,
102 RTensor *vectors = NULL,
103 const double *initial_guess = NULL);
106 RTensor
eigs_sym(
const CTensor &A,
int eig_type,
size_t neig,
107 CTensor *vectors = NULL,
108 const tensor::cdouble *initial_guess = NULL);
111 RTensor
eigs_sym(
const RSparse &A,
int eig_type,
size_t neig,
112 RTensor *vectors = NULL,
113 const double *initial_guess = NULL);
116 RTensor
eigs_sym(
const CSparse &A,
int eig_type,
size_t neig,
117 CTensor *vectors = NULL,
118 const tensor::cdouble *initial_guess = NULL);
123 #endif // !TENSOR_LINALG_H
const CTensor eig(const RTensor &A, CTensor *R=0, CTensor *L=0)
Eigenvalue decomposition of a real matrix.
double eig_power_left(const RTensor &A, RTensor *vector, size_t iter=0, double tol=1e-11)
Left eigenvalue and eigenvector with the largest absolute value, computed using the power method...
const RTensor expm(const RTensor &A, unsigned int order=7)
Compute the exponential of a real matrix.
Real Tensor with elements of type "double".
CTensor eigs(const CTensor &A, int eig_type, size_t neig, CTensor *vectors=NULL, const tensor::cdouble *initial_guess=NULL)
Find out a few eigenvalues and eigenvectors of a complex nonsymmetric matrix.
RTensor eig_sym(const RTensor &A, RTensor *pR=0)
Eigenvalue decomposition of a real matrix.
Complex Tensor with elements of type "cdouble".
RTensor eigs_sym(const RTensor &A, int eig_type, size_t neig, RTensor *vectors=NULL, const double *initial_guess=NULL)
Find out a few eigenvalues and eigenvectors of a symmetric real matrix.
const RTensor solve(const RTensor &A, const RTensor &B)
Solve a real linear system of equations by Gauss-Seidel method.
double eig_power_right(const RTensor &A, RTensor *vector, size_t iter=0, double tol=1e-11)
Right eigenvalue and eigenvector with the largest absolute value, computed using the power method...
EigType
Type of eigenvalues that eigs and Arpack compute.
const RTensor solve_with_svd(const RTensor &A, const RTensor &B, double tol=0.0)
Solution of a linear system of equations using Penrose's pseudoinvese.
RTensor svd(RTensor A, RTensor *pU=0, RTensor *pVT=0, bool economic=0)
Singular value decomposition of a real matrix.