|
Cytnx v0.7.4
|
linear algebra related functions. More...
Functions | |
| cytnx::UniTensor | Add (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise add | |
| template<class T > | |
| cytnx::UniTensor | Add (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Add (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Sub (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise subtract | |
| template<class T > | |
| cytnx::UniTensor | Sub (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Sub (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Mul (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise subtract | |
| template<class T > | |
| cytnx::UniTensor | Mul (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Mul (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Div (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise divide | |
| template<class T > | |
| cytnx::UniTensor | Div (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Div (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Mod (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise modulo | |
| template<class T > | |
| cytnx::UniTensor | Mod (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Mod (const cytnx::UniTensor &Lt, const T &rc) |
| std::vector< cytnx::UniTensor > | Svd (const cytnx::UniTensor &Tin, const bool &is_U=true, const bool &is_vT=true) |
| std::vector< cytnx::UniTensor > | Svd_truncate (const cytnx::UniTensor &Tin, const cytnx_uint64 &keepdim, const double &err=0, const bool &is_U=true, const bool &is_vT=true, const bool &return_err=false) |
| std::vector< cytnx::UniTensor > | Hosvd (const cytnx::UniTensor &Tin, const std::vector< cytnx_uint64 > &mode, const bool &is_core=true, const bool &is_Ls=false, const std::vector< cytnx_int64 > &trucate_dim=std::vector< cytnx_int64 >()) |
| cytnx::UniTensor | ExpH (const cytnx::UniTensor &Tin, const double &a=1, const double &b=0) |
| cytnx::UniTensor | ExpM (const cytnx::UniTensor &Tin, const double &a=1, const double &b=0) |
| cytnx::UniTensor | Trace (const cytnx::UniTensor &Tin, const cytnx_int64 &a=0, const cytnx_int64 &b=1, const bool &by_label=false) |
| std::vector< cytnx::UniTensor > | Qr (const cytnx::UniTensor &Tin, const bool &is_tau=false) |
| std::vector< cytnx::UniTensor > | Qdr (const cytnx::UniTensor &Tin, const bool &is_tau=false) |
| UniTensor | Pow (const UniTensor &Tin, const double &p) |
| take power p on all the elements in UniTensor. | |
| void | Pow_ (UniTensor &Tin, const double &p) |
| inplace perform power on all the elements in UniTensor. | |
| Tensor | Add (const Tensor &Lt, const Tensor &Rt) |
| template<class T > | |
| Tensor | Add (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Add (const Tensor &Lt, const T &rc) |
| void | iAdd (Tensor &Lt, const Tensor &Rt) |
| Tensor | Sub (const Tensor &Lt, const Tensor &Rt) |
| element-wise subtract | |
| template<class T > | |
| Tensor | Sub (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Sub (const Tensor &Lt, const T &rc) |
| void | iSub (Tensor &Lt, const Tensor &Rt) |
| Tensor | Mul (const Tensor &Lt, const Tensor &Rt) |
| element-wise subtract | |
| template<class T > | |
| Tensor | Mul (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Mul (const Tensor &Lt, const T &rc) |
| void | iMul (Tensor &Lt, const Tensor &Rt) |
| Tensor | Div (const Tensor &Lt, const Tensor &Rt) |
| element-wise divide | |
| template<class T > | |
| Tensor | Div (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Div (const Tensor &Lt, const T &rc) |
| void | iDiv (Tensor &Lt, const Tensor &Rt) |
| Tensor | Mod (const Tensor &Lt, const Tensor &Rt) |
| element-wise divide | |
| template<class T > | |
| Tensor | Mod (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Mod (const Tensor &Lt, const T &rc) |
| Tensor | Cpr (const Tensor &Lt, const Tensor &Rt) |
| element-wise compare | |
| template<class T > | |
| Tensor | Cpr (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Cpr (const Tensor &Lt, const T &rc) |
| Tensor | Norm (const Tensor &Tl) |
| calculate the norm of a tensor. | |
| Tensor | Det (const Tensor &Tl) |
| calculate the determinant of a tensor. | |
| std::vector< Tensor > | Svd (const Tensor &Tin, const bool &is_U=true, const bool &is_vT=true) |
| Perform Singular-Value decomposition on a rank-2 Tensor. | |
| std::vector< Tensor > | Svd_truncate (const Tensor &Tin, const cytnx_uint64 &keepdim, const double &err=0, const bool &is_U=true, const bool &is_vT=true, const bool &return_err=false) |
| std::vector< Tensor > | Hosvd (const Tensor &Tin, const std::vector< cytnx_uint64 > &mode, const bool &is_core=true, const bool &is_Ls=false, const std::vector< cytnx_int64 > &trucate_dim=std::vector< cytnx_int64 >()) |
| std::vector< Tensor > | Qr (const Tensor &Tin, const bool &is_tau=false) |
| Perform QR decomposition on a rank-2 Tensor. | |
| std::vector< Tensor > | Qdr (const Tensor &Tin, const bool &is_tau=false) |
| Perform QDR decomposition on a rank-2 Tensor. | |
| std::vector< Tensor > | Eigh (const Tensor &Tin, const bool &is_V=true, const bool &row_v=false) |
| eigen-value decomposition for Hermitian matrix | |
| std::vector< Tensor > | Eig (const Tensor &Tin, const bool &is_V=true, const bool &row_v=false) |
| eigen-value decomposition for generic square matrix | |
| Tensor | Trace (const Tensor &Tn, const cytnx_uint64 &axisA=0, const cytnx_uint64 &axisB=1) |
| perform trace over index. | |
| Tensor | Min (const Tensor &Tn) |
| get the minimum element. | |
| Tensor | Max (const Tensor &Tn) |
| get the maximum element. | |
| Tensor | Sum (const Tensor &Tn) |
| get the sum of all the elements. | |
| Tensor | Matmul (const Tensor &TL, const Tensor &TR) |
| perform matrix multiplication on two tensors. | |
| Tensor | Matmul_dg (const Tensor &Tl, const Tensor &Tr) |
| perform matrix multiplication on two Tensors with one rank-1 and the other rank-2 where the rank-1 represent the diagonal elements of the specific tensor. | |
| Tensor | InvM (const Tensor &Tin) |
| Matrix inverse. | |
| void | InvM_ (Tensor &Tin) |
| inplace perform Matrix inverse. | |
| Tensor | Inv (const Tensor &Tin, const double &clip) |
| Element-wise inverse with clip. | |
| void | Inv_ (Tensor &Tin, const double &clip) |
| inplace perform Element-wise inverse with clip. | |
| Tensor | Conj (const Tensor &Tin) |
| Conjugate all the element in Tensor. | |
| void | Conj_ (Tensor &Tin) |
| inplace perform Conjugate on all the element in Tensor. | |
| Tensor | Exp (const Tensor &Tin) |
| Exponential all the element in Tensor. | |
| Tensor | Expf (const Tensor &Tin) |
| Exponential all the element in Tensor. | |
| void | Exp_ (Tensor &Tin) |
| inplace perform Exponential on all the element in Tensor. | |
| void | Expf_ (Tensor &Tin) |
| inplace perform Exponential on all the element in Tensor. | |
| Tensor | Pow (const Tensor &Tin, const double &p) |
| take power p on all the elements in Tensor. | |
| void | Pow_ (Tensor &Tin, const double &p) |
| inplace perform power on all the elements in Tensor. | |
| Tensor | Abs (const Tensor &Tin) |
| Elementwise absolute value. | |
| void | Abs_ (Tensor &Tin) |
| inplace perform elementwiase absolute value. | |
| Tensor | Diag (const Tensor &Tin) |
| return a diagonal tensor with diagonal elements provided as Tin. | |
| Tensor | Tensordot (const Tensor &Tl, const Tensor &Tr, const std::vector< cytnx_uint64 > &idxl, const std::vector< cytnx_uint64 > &idxr, const bool &cacheL=false, const bool &cacheR=false) |
| perform tensor dot by sum out the indices assigned of two Tensors. | |
| Tensor | Tensordot_dg (const Tensor &Tl, const Tensor &Tr, const std::vector< cytnx_uint64 > &idxl, const std::vector< cytnx_uint64 > &idxr, const bool &diag_L) |
| perform tensor dot by sum out the indices assigned of two Tensors, with either one of them to be a rank-2 diagonal tensor represented by a rank-2 tensor. | |
| Tensor | Outer (const Tensor &Tl, const Tensor &Tr) |
| perform outer produces of two rank-1 Tensor. | |
| Tensor | Kron (const Tensor &Tl, const Tensor &Tr, const bool &Tl_pad_left=false, const bool &Tr_pad_left=false) |
| perform kronecker produces of two Tensor. | |
| Tensor | Vectordot (const Tensor &Tl, const Tensor &Tr, const bool &is_conj=false) |
| perform inner product of vectors | |
| Tensor | Dot (const Tensor &Tl, const Tensor &Tr) |
| dot product of two arrays. | |
| std::vector< Tensor > | Tridiag (const Tensor &Diag, const Tensor &Sub_diag, const bool &is_V=true, const bool &is_row=false) |
| perform diagonalization of symmetric tri-diagnoal matrix. | |
| Tensor | ExpH (const Tensor &in, const cytnx_double &a=1, const cytnx_double &b=0) |
| perform matrix exponential for Hermitian matrix | |
| Tensor | ExpM (const Tensor &in, const cytnx_double &a=1, const cytnx_double &b=0) |
| perform matrix exponential for generic matrix | |
| std::vector< Tensor > | Lanczos_ER (LinOp *Hop, const cytnx_uint64 &k=1, const bool &is_V=true, const cytnx_uint64 &maxiter=10000, const double &CvgCrit=1.0e-14, const bool &is_row=false, const Tensor &Tin=Tensor(), const cytnx_uint32 &max_krydim=4, const bool &verbose=false) |
| perform Lanczos for hermitian/symmetric matrices or linear function. | |
| std::vector< Tensor > | Lanczos_Gnd (LinOp *Hop, const double &CvgCrit=1.0e-14, const bool &is_V=true, const Tensor &Tin=Tensor(), const bool &verbose=false, const unsigned int &Maxiter=100000) |
| perform Lanczos for hermitian/symmetric matrices or linear function to get ground state and lowest eigen value | |
| std::vector< UniTensor > | Lanczos_Gnd_Ut (LinOp *Hop, const UniTensor &Tin, const double &CvgCrit=1.0e-14, const bool &is_V=true, const bool &verbose=false, const unsigned int &Maxiter=100000) |
| perform Lanczos for hermitian/symmetric matrices or linear function to get ground state and lowest eigen value | |
| std::vector< Tensor > | Lstsq (const Tensor &A, const Tensor &b, const float &rcond=-1) |
| Return the least-squares solution to a linear matrix equation. | |
linear algebra related functions.
| void cytnx::linalg::Abs_ | ( | Tensor & | Tin | ) |
inplace perform elementwiase absolute value.
| Tin,the | input Tensor. |
description: on return, the elements in Tin will be modified to it's absolute value. Note that if the input tensor is complex, it will be modified to real type.
| cytnx::UniTensor cytnx::linalg::Add | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise add
| cytnx::UniTensor cytnx::linalg::Add | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Add | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| void cytnx::linalg::Conj_ | ( | Tensor & | Tin | ) |
| cytnx::UniTensor cytnx::linalg::Div | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise divide
| cytnx::UniTensor cytnx::linalg::Div | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Div | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
dot product of two arrays.
description:
[Note] performance tune: This function have better performance when two arrays with same types, and are one of following type: cytnx_double, cytnx_float, cytnx_complex64 or cytnx_complex128.
[Python] In Python API, operator@ is overloaded as a shorthand of linalg::Dot.
| void cytnx::linalg::Exp_ | ( | Tensor & | Tin | ) |
inplace perform Exponential on all the element in Tensor.
| Tin,the | input Tensor. |
description:
| void cytnx::linalg::Expf_ | ( | Tensor & | Tin | ) |
inplace perform Exponential on all the element in Tensor.
| Tin,the | input Tensor. |
description:
| cytnx::UniTensor cytnx::linalg::ExpH | ( | const cytnx::UniTensor & | Tin, |
| const double & | a = 1, |
||
| const double & | b = 0 |
||
| ) |
| Tensor cytnx::linalg::ExpH | ( | const Tensor & | in, |
| const cytnx_double & | a = 1, |
||
| const cytnx_double & | b = 0 |
||
| ) |
| cytnx::UniTensor cytnx::linalg::ExpM | ( | const cytnx::UniTensor & | Tin, |
| const double & | a = 1, |
||
| const double & | b = 0 |
||
| ) |
| Tensor cytnx::linalg::ExpM | ( | const Tensor & | in, |
| const cytnx_double & | a = 1, |
||
| const cytnx_double & | b = 0 |
||
| ) |
| std::vector< cytnx::UniTensor > cytnx::linalg::Hosvd | ( | const cytnx::UniTensor & | Tin, |
| const std::vector< cytnx_uint64 > & | mode, | ||
| const bool & | is_core = true, |
||
| const bool & | is_Ls = false, |
||
| const std::vector< cytnx_int64 > & | trucate_dim = std::vector< cytnx_int64 >() |
||
| ) |
| std::vector< Tensor > cytnx::linalg::Hosvd | ( | const Tensor & | Tin, |
| const std::vector< cytnx_uint64 > & | mode, | ||
| const bool & | is_core = true, |
||
| const bool & | is_Ls = false, |
||
| const std::vector< cytnx_int64 > & | trucate_dim = std::vector< cytnx_int64 >() |
||
| ) |
Element-wise inverse with clip.
description: Performs Elementwise inverse with clip. if A[i] < clip, then 1/A[i] = 0 will be set.
[Note] For complex type Tensors, the square norm is used to determine the clip.
| void cytnx::linalg::Inv_ | ( | Tensor & | Tin, |
| const double & | clip | ||
| ) |
inplace perform Element-wise inverse with clip.
description:
[Note] For complex type Tensors, the square norm is used to determine the clip.
| void cytnx::linalg::InvM_ | ( | Tensor & | Tin | ) |
inplace perform Matrix inverse.
description: on return, the Tin will be modified to it's inverse.
[Note] the Tin should be a rank-2 Tensor.
| Tensor cytnx::linalg::Kron | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const bool & | Tl_pad_left = false, |
||
| const bool & | Tr_pad_left = false |
||
| ) |
perform kronecker produces of two Tensor.
| Tl | rank-n Tensor #1 |
| Tr | rank-m Tensor #2 |
| Tl_pad_left | The padding scheme for Tl if Tl.rank != Tr.rank |
| Tr_pad_left | The padding scheme for Tr if Tl.rank != Tr.rank |
description: The function assume two tensor has the same rank. In case where two tensors have different ranks, the small one will be extend by adding redundant dimension to the beginning of axis (T<x>_pad_right=true) or by adding redundant dim to the last axis (if T<x>_pad_left=false [default]). if the Tensor #1 has shape=(i1,j1,k1,l1...), and Tensor #2 has shape=(i2,j2,k2,l2...); then the return Tensor will have shape=(i1*i2,j1*j2,k1*k2...)
[Note] two tensor should on same device.
| std::vector< Tensor > cytnx::linalg::Lanczos_ER | ( | LinOp * | Hop, |
| const cytnx_uint64 & | k = 1, |
||
| const bool & | is_V = true, |
||
| const cytnx_uint64 & | maxiter = 10000, |
||
| const double & | CvgCrit = 1.0e-14, |
||
| const bool & | is_row = false, |
||
| const Tensor & | Tin = Tensor(), |
||
| const cytnx_uint32 & | max_krydim = 4, |
||
| const bool & | verbose = false |
||
| ) |
perform Lanczos for hermitian/symmetric matrices or linear function.
| Hop | the Linear Operator defined by LinOp class or it's inheritance (see LinOp). |
| k | the number of lowest k eigen values. |
| is_V | if set to true, the eigen vectors will be returned. |
| maxiter | the maximum interation steps for each k. |
| CvgCrit | the convergence criterion of the energy. |
| is_row | whether the return eigen vectors should be in row-major form. |
| Tin | the initial vector, this should be rank-1 |
| max_krydim | the maximum krylov subspace dimension for each iteration. |
| verbose | print out iteration info. |
#description: This function calculate the eigen value problem using explicitly restarted Lanczos.
#Performance tune: For small linear dimension, try to reduce max_krydim.
#[Note] To use, define a linear operator with LinOp class either by assign a custom function or create a class that inherit LinOp (see LinOp for further details)
| std::vector< Tensor > cytnx::linalg::Lanczos_Gnd | ( | LinOp * | Hop, |
| const double & | CvgCrit = 1.0e-14, |
||
| const bool & | is_V = true, |
||
| const Tensor & | Tin = Tensor(), |
||
| const bool & | verbose = false, |
||
| const unsigned int & | Maxiter = 100000 |
||
| ) |
perform Lanczos for hermitian/symmetric matrices or linear function to get ground state and lowest eigen value
| Hop | the Linear Operator defined by LinOp class or it's inheritance (see LinOp). |
| CvgCrit | the convergence criterion of the energy. |
| is_V | if set to true, the eigen vectors will be returned. |
| Tin | the initial vector, this should be rank-1 |
| verbose | print out iteration info. |
| maxiter | the maximum interation steps for each k. |
#description: This function calculate the eigen value problem using naive Lanczos to get ground state and lowest eigen value.
#[Note] To use, define a linear operator with LinOp class either by assign a custom function or create a class that inherit LinOp (see LinOp for further details)
| std::vector< UniTensor > cytnx::linalg::Lanczos_Gnd_Ut | ( | LinOp * | Hop, |
| const UniTensor & | Tin, | ||
| const double & | CvgCrit = 1.0e-14, |
||
| const bool & | is_V = true, |
||
| const bool & | verbose = false, |
||
| const unsigned int & | Maxiter = 100000 |
||
| ) |
perform Lanczos for hermitian/symmetric matrices or linear function to get ground state and lowest eigen value
| Hop | the Linear Operator defined by LinOp class or it's inheritance (see LinOp). |
| CvgCrit | the convergence criterion of the energy. |
| is_V | if set to true, the eigen vectors will be returned. |
| Tin | the initial vector, this should be a UniTensor. |
| verbose | print out iteration info. |
| maxiter | the maximum interation steps for each k. |
#description: This function calculate the eigen value problem using naive Lanczos to get ground state and lowest eigen value.
#[Note] To use, define a linear operator with LinOp class either by assign a custom function or create a class that inherit LinOp (see LinOp for further details)
| std::vector< Tensor > cytnx::linalg::Lstsq | ( | const Tensor & | A, |
| const Tensor & | b, | ||
| const float & | rcond = -1 |
||
| ) |
Return the least-squares solution to a linear matrix equation.
| A | “Coefficient” matrix, must be two-dimensional. |
| b | Ordinate or “dependent variable” values, must be two-dimensional, the least-squares solution is calculated for each of the K columns of b. |
| rcond | Cut-off ratio for small singular values of a. For the purposes of rank determination, singular values are treated as zero if they are smaller than rcond times the largest singular value of A, If it is negative, the machine precision is used. |
1. the first tensor is least-squares solutions in the K columns. 2. the second tensor is the sums of squared residuals: Squared Euclidean 2-norm for each column in b - a @ x. If the rank of a is < N or M <= N, this is a zero Tensor. 3. the third tensor is the rank of matrix A. 4. the forth tensor is singular values of A.#description: Computes the vector x that approximatively solves the equation A @ x = b. The equation may be under-, well-, or over-determined independent columns. If a is square and of full rank, then x (but for round-off error) is the “exact” solution of the equation. Else, x minimizes the Euclidean 2-norm || b - a x ||.
[Ke]
perform matrix multiplication on two tensors.
[Note] the TL and TR should be both rank-2 Tensor.
get the maximum element.
[Note] For complex TN, only real part is compared.
get the minimum element.
[Note] For complex TN, only real part is compared.
| cytnx::UniTensor cytnx::linalg::Mod | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise modulo
| cytnx::UniTensor cytnx::linalg::Mod | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Mod | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Mul | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise subtract
| cytnx::UniTensor cytnx::linalg::Mul | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Mul | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| void cytnx::linalg::Pow_ | ( | Tensor & | Tin, |
| const double & | p | ||
| ) |
| void cytnx::linalg::Pow_ | ( | UniTensor & | Tin, |
| const double & | p | ||
| ) |
| std::vector< cytnx::UniTensor > cytnx::linalg::Qdr | ( | const cytnx::UniTensor & | Tin, |
| const bool & | is_tau = false |
||
| ) |
Perform QDR decomposition on a rank-2 Tensor.
| Tin | a Tensor , it should be a rank-2 tensor (matrix) |
| is_tau | if return the tau that contains the Householder reflectors that generate q along with r. The tau array contains scaling factors for the reflectors |
1. the first tensor is the orthomormal matrix [Q], a 2-d tensor (matrix) 2. the second tensor is the diagonal matrix [D], a 1-d tensor (matrix). 3. the third tensor is the right-upper triangular matrix [R], a 2-d tensor (matrix). 4. the forth tensor is the Householder reflectors [H], a 1-d tensor (matrix). It only return when is_tau=true.
| std::vector< cytnx::UniTensor > cytnx::linalg::Qr | ( | const cytnx::UniTensor & | Tin, |
| const bool & | is_tau = false |
||
| ) |
Perform QR decomposition on a rank-2 Tensor.
| Tin | a Tensor , it should be a rank-2 tensor (matrix) |
| is_tau | if return the tau that contains the Householder reflectors that generate q along with r. The tau array contains scaling factors for the reflectors |
1. the first tensor is the orthomormal matrix [Q], a 2-d tensor (matrix) 2. the second tensor is the right-upper triangular matrix [R], a 2-d tensor (matrix). 3. the third tensor is the Householder reflectors [H], a 1-d tensor (matrix). It only return when is_tau=true.
| cytnx::UniTensor cytnx::linalg::Sub | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise subtract
| cytnx::UniTensor cytnx::linalg::Sub | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Sub | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| std::vector< cytnx::UniTensor > cytnx::linalg::Svd | ( | const cytnx::UniTensor & | Tin, |
| const bool & | is_U = true, |
||
| const bool & | is_vT = true |
||
| ) |
| std::vector< Tensor > cytnx::linalg::Svd | ( | const Tensor & | Tin, |
| const bool & | is_U = true, |
||
| const bool & | is_vT = true |
||
| ) |
Perform Singular-Value decomposition on a rank-2 Tensor.
| Tin | a Tensor , it should be a rank-2 tensor (matrix) |
| is_U | if return a left uniform matrix. |
| is_vT | if return a right uniform matrix. |
1. the first tensor is a 1-d tensor contanin the singular values 2. the second tensor is the left uniform matrix [U], a 2-d tensor (matrix). It only return when is_U=true. 3. the third tensor is the right uniform matrix [vT], a 2-d tensor (matrix). It only return when is_vT=true.
| std::vector< cytnx::UniTensor > cytnx::linalg::Svd_truncate | ( | const cytnx::UniTensor & | Tin, |
| const cytnx_uint64 & | keepdim, | ||
| const double & | err = 0, |
||
| const bool & | is_U = true, |
||
| const bool & | is_vT = true, |
||
| const bool & | return_err = false |
||
| ) |
| std::vector< Tensor > cytnx::linalg::Svd_truncate | ( | const Tensor & | Tin, |
| const cytnx_uint64 & | keepdim, | ||
| const double & | err = 0, |
||
| const bool & | is_U = true, |
||
| const bool & | is_vT = true, |
||
| const bool & | return_err = false |
||
| ) |
| Tensor cytnx::linalg::Tensordot | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const std::vector< cytnx_uint64 > & | idxl, | ||
| const std::vector< cytnx_uint64 > & | idxr, | ||
| const bool & | cacheL = false, |
||
| const bool & | cacheR = false |
||
| ) |
perform tensor dot by sum out the indices assigned of two Tensors.
| Tl | Tensor #1 |
| Tr | Tensor #2 |
| idxl | the indices of rank of Tensor #1 that is going to sum with Tensor #2 |
| idxr | the indices of rank of Tensor #2 that is going to sum with Tensor #1 |
| cacheL | cache Tensor #1 (See user-guide for details) |
| cacheR | cache Tensor #2 (See user-guide for details) |
[Note]
| Tensor cytnx::linalg::Tensordot_dg | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const std::vector< cytnx_uint64 > & | idxl, | ||
| const std::vector< cytnx_uint64 > & | idxr, | ||
| const bool & | diag_L | ||
| ) |
perform tensor dot by sum out the indices assigned of two Tensors, with either one of them to be a rank-2 diagonal tensor represented by a rank-2 tensor.
| Tl | Tensor #1 |
| Tr | Tensor #2 |
| idxl | the indices of rank of Tensor #1 that is going to sum with Tensor #2 |
| idxr | the indices of rank of Tensor #2 that is going to sum with Tensor #1 |
| diag_L | if Tl(true)/Tr(false) is a diagnal matrix, represented by a rank-1 tensor. |
[Note]
| cytnx::UniTensor cytnx::linalg::Trace | ( | const cytnx::UniTensor & | Tin, |
| const cytnx_int64 & | a = 0, |
||
| const cytnx_int64 & | b = 1, |
||
| const bool & | by_label = false |
||
| ) |
| Tensor cytnx::linalg::Trace | ( | const Tensor & | Tn, |
| const cytnx_uint64 & | axisA = 0, |
||
| const cytnx_uint64 & | axisB = 1 |
||
| ) |
perform trace over index.
[Note] the Tn should be at-least rank-2 Tensor.
| std::vector< Tensor > cytnx::linalg::Tridiag | ( | const Tensor & | Diag, |
| const Tensor & | Sub_diag, | ||
| const bool & | is_V = true, |
||
| const bool & | is_row = false |
||
| ) |
perform diagonalization of symmetric tri-diagnoal matrix.
| Diag | Tensor #1 |
| Sub_diag | Tensor #2 |
| is_V | if calculate the eigen value. |
| k | Return k lowest eigen vector if is_V=True |
description: two Tensors must be Rank-1, with length of Diag = L and Sub_diag length = L-1.
[Note] performance tune: This function have better performance when two vectors with same types, and are one of following type: cytnx_double, cytnx_float. In general all real type can be use as input, which will be promote to floating point type for calculation.
| Tensor cytnx::linalg::Vectordot | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const bool & | is_conj = false |
||
| ) |
perform inner product of vectors
| Tl | Tensor #1 |
| Tr | Tensor #2 |
| if | the Tl should be conjugated (only work for complex. For real Tensor, no function), default: false |
description: two Tensors must be Rank-1, with same length.
[Note] performance tune: This function have better performance when two vectors with same types, and are one of following type: cytnx_double, cytnx_float, cytnx_complex64 or cytnx_complex128.