Cytnx v0.9.1
Loading...
Searching...
No Matches
linalg.hpp
Go to the documentation of this file.
1#ifndef _linalg_H_
2#define _linalg_H_
3
4#include "Type.hpp"
5#include "cytnx_error.hpp"
6#include "Tensor.hpp"
7#include "Storage.hpp"
8#include "UniTensor.hpp"
9#include "Scalar.hpp"
10#include "LinOp.hpp"
11#include <functional>
12
13namespace cytnx {
14
25
35 template <class T>
37
47 template <class T>
49
60
70 template <class T>
72
82 template <class T>
84
95
105 template <class T>
107
117 template <class T>
119
130
140 template <class T>
142
152 template <class T>
154
165
175 template <class T>
177
187 template <class T>
189
190
202 namespace linalg {
203
204 // Add:
205 //==================================================
228
261 template <class T>
262 cytnx::UniTensor Add(const T &lc, const cytnx::UniTensor &Rt);
263
297 template <class T>
298 cytnx::UniTensor Add(const cytnx::UniTensor &Lt, const T &rc);
299
300 // Sub:
301 //==================================================
325
358 template <class T>
359 cytnx::UniTensor Sub(const T &lc, const cytnx::UniTensor &Rt);
360
393 template <class T>
394 cytnx::UniTensor Sub(const cytnx::UniTensor &Lt, const T &rc);
395
396 // Mul:
397 //==================================================
421
454 template <class T>
455 cytnx::UniTensor Mul(const T &lc, const cytnx::UniTensor &Rt);
456
489 template <class T>
490 cytnx::UniTensor Mul(const cytnx::UniTensor &Lt, const T &rc);
491
492 // Div:
493 //==================================================
517
551 template <class T>
552 cytnx::UniTensor Div(const T &lc, const cytnx::UniTensor &Rt);
553
587 template <class T>
588 cytnx::UniTensor Div(const cytnx::UniTensor &Lt, const T &rc);
589
590 // Mod:
591 //==================================================
617
648 template <class T>
649 cytnx::UniTensor Mod(const T &lc, const cytnx::UniTensor &Rt);
650
681 template <class T>
682 cytnx::UniTensor Mod(const cytnx::UniTensor &Lt, const T &rc);
683
690 std::vector<cytnx::UniTensor> Svd(const cytnx::UniTensor &Tin, const bool &is_UvT = true);
691
698 std::vector<cytnx::UniTensor> Gesvd(const cytnx::UniTensor &Tin, const bool &is_U = true,
699 const bool &is_vT = true);
700
711 std::vector<cytnx::UniTensor> Svd_truncate(const cytnx::UniTensor &Tin,
712 const cytnx_uint64 &keepdim, const double &err = 0,
713 const bool &is_UvT = true,
714 const bool &return_err = false);
715
716
727 std::vector<cytnx::UniTensor> Gesvd_truncate(const cytnx::UniTensor &Tin,
728 const cytnx_uint64 &keepdim, const double &err = 0,
729 const bool &is_U = true, const bool &is_vT=true,
730 const bool &return_err = false);
731
732
733
734 std::vector<cytnx::UniTensor> Hosvd(
735 const cytnx::UniTensor &Tin, const std::vector<cytnx_uint64> &mode,
736 const bool &is_core = true, const bool &is_Ls = false,
737 const std::vector<cytnx_int64> &trucate_dim = std::vector<cytnx_int64>());
738
747 template <typename T>
748 cytnx::UniTensor ExpH(const cytnx::UniTensor &Tin, const T &a, const T &b = 0);
749
757 template <typename T>
758 cytnx::UniTensor ExpM(const cytnx::UniTensor &Tin, const T &a, const T &b = 0);
759
769
778
784 const cytnx_int64 &b = 1);
785
793 cytnx::UniTensor Trace(const cytnx::UniTensor &Tin, const std::string &a, const std::string &b);
794
800 const cytnx_int64 &b = 1, const bool &by_label = false);
801
810 std::vector<cytnx::UniTensor> Qr(const cytnx::UniTensor &Tin, const bool &is_tau = false);
811
820 std::vector<cytnx::UniTensor> Qdr(const cytnx::UniTensor &Tin, const bool &is_tau = false);
821
822 // Pow:
823 //==================================================
836 UniTensor Pow(const UniTensor &Tin, const double &p);
837
849 void Pow_(UniTensor &Tin, const double &p);
850
851
852
853 //====================================================================================
854 // [Tensor] ====================================================================================
855 //====================================================================================
856
880 Tensor Add(const Tensor &Lt, const Tensor &Rt);
881
903 template <class T>
904 Tensor Add(const T &lc, const Tensor &Rt);
905
927 template <class T>
928 Tensor Add(const Tensor &Lt, const T &rc);
929
954 void iAdd(Tensor &Lt, const Tensor &Rt);
955
956 // Sub:
957 //==================================================
980 Tensor Sub(const Tensor &Lt, const Tensor &Rt);
981
1003 template <class T>
1004 Tensor Sub(const T &lc, const Tensor &Rt);
1005
1027 template <class T>
1028 Tensor Sub(const Tensor &Lt, const T &rc);
1029
1054 void iSub(Tensor &Lt, const Tensor &Rt);
1055
1056 // Mul:
1057 //==================================================
1080 Tensor Mul(const Tensor &Lt, const Tensor &Rt);
1081
1103 template <class T>
1104 Tensor Mul(const T &lc, const Tensor &Rt);
1105
1127 template <class T>
1128 Tensor Mul(const Tensor &Lt, const T &rc);
1129
1154 void iMul(Tensor &Lt, const Tensor &Rt);
1155
1156 // Div:
1157 //==================================================
1181 Tensor Div(const Tensor &Lt, const Tensor &Rt);
1182
1205 template <class T>
1206 Tensor Div(const T &lc, const Tensor &Rt);
1207
1230 template <class T>
1231 Tensor Div(const Tensor &Lt, const T &rc);
1232
1257 void iDiv(Tensor &Lt, const Tensor &Rt);
1258
1259 // Mod:
1260 //==================================================
1261
1284 Tensor Mod(const Tensor &Lt, const Tensor &Rt);
1285
1306 template <class T>
1307 Tensor Mod(const T &lc, const Tensor &Rt);
1308
1329 template <class T>
1330 Tensor Mod(const Tensor &Lt, const T &rc);
1331
1332 // Cpr:
1333 //==================================================
1359 Tensor Cpr(const Tensor &Lt, const Tensor &Rt);
1360
1385 template <class T>
1386 Tensor Cpr(const T &lc, const Tensor &Rt);
1387
1412 template <class T>
1413 Tensor Cpr(const Tensor &Lt, const T &rc);
1414
1415 // Norm:
1416 //=================================================
1426 Tensor Norm(const Tensor &Tl);
1427
1428 // Det:
1429 //=================================================
1438 Tensor Det(const Tensor &Tl);
1439
1440 // Svd:
1441 //==================================================
1467 std::vector<Tensor> Svd(const Tensor &Tin, const bool &is_UvT = true);
1468
1469 // Gesvd:
1470 //==================================================
1497 std::vector<Tensor> Gesvd(const Tensor &Tin, const bool &is_U = true, const bool &is_vT = true);
1498
1499
1500
1501 // Svd_truncate:
1502 //==================================================
1533 std::vector<Tensor> Svd_truncate(const Tensor &Tin, const cytnx_uint64 &keepdim,
1534 const double &err = 0, const bool &is_UvT = true,
1535 const bool &return_err = false);
1536
1537
1538 // Gesvd_truncate:
1539 //==================================================
1572 std::vector<Tensor> Gesvd_truncate(const Tensor &Tin, const cytnx_uint64 &keepdim,
1573 const double &err = 0, const bool &is_U = true, const bool &is_vT = true,
1574 const bool &return_err = false);
1575
1576
1577 // Hosvd:
1578 std::vector<Tensor> Hosvd(
1579 const Tensor &Tin, const std::vector<cytnx_uint64> &mode, const bool &is_core = true,
1580 const bool &is_Ls = false,
1581 const std::vector<cytnx_int64> &trucate_dim = std::vector<cytnx_int64>());
1582
1583 // Qr:
1584 //==================================================
1610 std::vector<Tensor> Qr(const Tensor &Tin, const bool &is_tau = false);
1611
1612 // Qdr:
1613 //==================================================
1633 std::vector<Tensor> Qdr(const Tensor &Tin, const bool &is_tau = false);
1634
1635 // Eigh:
1636 //==================================================
1657 std::vector<Tensor> Eigh(const Tensor &Tin, const bool &is_V = true, const bool &row_v = false);
1658
1659 // Eig:
1660 //==================================================
1680 std::vector<Tensor> Eig(const Tensor &Tin, const bool &is_V = true, const bool &row_v = false);
1681
1682 // Trace:
1683 //==================================================
1697 Tensor Trace(const Tensor &Tn, const cytnx_uint64 &axisA = 0, const cytnx_uint64 &axisB = 1);
1698
1699 // Min:
1700 //==================================================
1706 Tensor Min(const Tensor &Tn);
1707
1708 // Max:
1709 //==================================================
1715 Tensor Max(const Tensor &Tn);
1716
1717 // Sum:
1718 //==================================================
1723 Tensor Sum(const Tensor &Tn);
1724
1725 // Matmul:
1726 //==================================================
1738 Tensor Matmul(const Tensor &TL, const Tensor &TR);
1739
1740 // Matmul_dg:
1741 //==================================================
1748 Tensor Matmul_dg(const Tensor &Tl, const Tensor &Tr);
1749
1750 // InvM:
1751 //==================================================
1758 Tensor InvM(const Tensor &Tin);
1766 void InvM_(Tensor &Tin);
1767
1768 // Inv:
1769 //==================================================
1788 Tensor Inv(const Tensor &Tin, const double &clip);
1789
1802 void Inv_(Tensor &Tin, const double &clip);
1803
1804 // Conj:
1805 //==================================================
1820 Tensor Conj(const Tensor &Tin);
1821
1830 void Conj_(Tensor &Tin);
1831
1832 // Exp:
1833 //==================================================
1847 Tensor Exp(const Tensor &Tin);
1848
1862 Tensor Expf(const Tensor &Tin);
1863
1873 void Exp_(Tensor &Tin);
1874
1884 void Expf_(Tensor &Tin);
1885
1886 // Pow:
1887 //==================================================
1899 Tensor Pow(const Tensor &Tin, const double &p);
1900
1907 void Pow_(Tensor &Tin, const double &p);
1908
1909 // Abs:
1910 //==================================================
1921 Tensor Abs(const Tensor &Tin);
1922
1930 void Abs_(Tensor &Tin);
1931
1932 // Diag:
1933 //==================================================
1942 Tensor Diag(const Tensor &Tin);
1943
1944 // Tensordot:
1945 //==================================================
1961 Tensor Tensordot(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl,
1962 const std::vector<cytnx_uint64> &idxr, const bool &cacheL = false,
1963 const bool &cacheR = false);
1964
1965 // Tensordot_dg:
1966 //==================================================
1984 Tensor Tensordot_dg(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl,
1985 const std::vector<cytnx_uint64> &idxr, const bool &diag_L);
1986
1987 // Outer:
1988 //==================================================
1999 Tensor Outer(const Tensor &Tl, const Tensor &Tr);
2000
2001 // Kron:
2002 //==================================================
2019 Tensor Kron(const Tensor &Tl, const Tensor &Tr, const bool &Tl_pad_left = false,
2020 const bool &Tr_pad_left = false);
2021
2022
2023 // Directsum:
2024 //==================================================
2038 Tensor Directsum(const Tensor &T1, const Tensor &T2, const std::vector<cytnx_uint64> &shared_axes);
2039
2040 // VectorDot:
2041 //=================================================
2053 Tensor Vectordot(const Tensor &Tl, const Tensor &Tr, const bool &is_conj = false);
2054
2055 // Dot:
2056 //=================================================
2076 Tensor Dot(const Tensor &Tl, const Tensor &Tr);
2077
2078 // Tridiag:
2079 //===========================================
2100 std::vector<Tensor> Tridiag(const Tensor &Diag, const Tensor &Sub_diag, const bool &is_V = true,
2101 const bool &is_row = false, bool throw_excp = false);
2102
2103 // ExpH:
2104 //===========================================
2117 template <typename T>
2118 Tensor ExpH(const Tensor &in, const T &a, const T &b =0);
2119 Tensor ExpH(const Tensor &in);
2120
2121
2122
2123 // ExpM:
2124 //===========================================
2136 template <typename T>
2137 Tensor ExpM(const Tensor &in, const T &a, const T &b = 0);
2138
2148 Tensor ExpM(const Tensor &in);
2149
2150 // Arnoldi:
2151 //===========================================
2181 std::vector<Tensor> Arnoldi(
2182 LinOp *Hop, const Tensor &Tin = Tensor(), const std::string which = "LM",
2183 const cytnx_uint64 &maxiter = 10000, const cytnx_double & cvg_crit = 1.0e-9,
2184 const cytnx_uint64 &k = 1, const bool &is_V = true, const bool &verbose = false);
2185
2186 // Lanczos:
2187 //===========================================
2218 std::vector<Tensor> Lanczos(LinOp *Hop, const Tensor &Tin = Tensor(),
2219 const std::string method = "Gnd", const double &CvgCrit = 1.0e-14,
2220 const unsigned int &Maxiter = 10000, const cytnx_uint64 &k = 1,
2221 const bool &is_V = true, const bool &is_row = false,
2222 const cytnx_uint32 &max_krydim = 0, const bool &verbose = false);
2223
2224 // Lanczos:
2225 //===========================================
2256 std::vector<UniTensor> Lanczos(LinOp *Hop, const UniTensor &Tin = UniTensor(),
2257 const std::string method = "Gnd",
2258 const double &CvgCrit = 1.0e-14,
2259 const unsigned int &Maxiter = 10000, const cytnx_uint64 &k = 1,
2260 const bool &is_V = true, const bool &is_row = false,
2261 const cytnx_uint32 &max_krydim = 4, const bool &verbose = false);
2262
2263
2264 // Lanczos:
2265 //===========================================
2287 std::vector<Tensor> Lanczos_ER(LinOp *Hop, const cytnx_uint64 &k = 1, const bool &is_V = true,
2288 const cytnx_uint64 &maxiter = 10000,
2289 const double &CvgCrit = 1.0e-14, const bool &is_row = false,
2290 const Tensor &Tin = Tensor(), const cytnx_uint32 &max_krydim = 4,
2291 const bool &verbose = false);
2292
2293 // Lanczos:
2294 //===========================================
2313 std::vector<Tensor> Lanczos_Gnd(LinOp *Hop, const double &CvgCrit = 1.0e-14,
2314 const bool &is_V = true, const Tensor &Tin = Tensor(),
2315 const bool &verbose = false,
2316 const unsigned int &Maxiter = 100000);
2317
2318 // Lanczos:
2319 //===============================================
2338 std::vector<UniTensor> Lanczos_Gnd_Ut(LinOp *Hop, const UniTensor &Tin,
2339 const double &CvgCrit = 1.0e-14, const bool &is_V = true,
2340 const bool &verbose = false,
2341 const unsigned int &Maxiter = 100000);
2342
2343 // Lstsq:
2344 //===========================================
2370 std::vector<Tensor> Lstsq(const Tensor &A, const Tensor &b, const float &rcond = -1);
2371
2372
2390 Tensor Axpy(const Scalar &a, const Tensor &x, const Tensor &y = Tensor());
2391
2410 void Axpy_(const Scalar &a, const Tensor &x, Tensor &y);
2411
2425 Tensor Ger(const Tensor &x, const Tensor &y, const Scalar &a=Scalar());
2426
2427
2443 void Gemm_(const Scalar &a, const Tensor &x, const Tensor &y, const Scalar &b, Tensor &c);
2444
2460 Tensor Gemm(const Scalar &a, const Tensor &x, const Tensor &y);
2461
2462
2463
2464 } // namespace linalg
2465
2466 // operators:
2476 Tensor operator+(const Tensor &Lt, const Tensor &Rt);
2477
2487 template <class T>
2488 Tensor operator+(const T &lc, const Tensor &Rt);
2489
2499 template <class T>
2500 Tensor operator+(const Tensor &Lt, const T &rc);
2501
2502 //------------------------------------
2512 Tensor operator-(const Tensor &Lt, const Tensor &Rt);
2513
2523 template <class T>
2524 Tensor operator-(const T &lc, const Tensor &Rt);
2525
2535 template <class T>
2536 Tensor operator-(const Tensor &Lt, const T &rc);
2537
2538 //-----------------------------------
2548 Tensor operator*(const Tensor &Lt, const Tensor &Rt);
2549
2559 template <class T>
2560 Tensor operator*(const T &lc, const Tensor &Rt);
2561
2571 template <class T>
2572 Tensor operator*(const Tensor &Lt, const T &rc);
2573
2574 //----------------------------------
2585 Tensor operator/(const Tensor &Lt, const Tensor &Rt);
2586
2597 template <class T>
2598 Tensor operator/(const T &lc, const Tensor &Rt);
2599
2610 template <class T>
2611 Tensor operator/(const Tensor &Lt, const T &rc);
2612
2613 //----------------------------------
2623 Tensor operator%(const Tensor &Lt, const Tensor &Rt);
2624
2634 template <class T>
2635 Tensor operator%(const T &lc, const Tensor &Rt);
2636
2646 template <class T>
2647 Tensor operator%(const Tensor &Lt, const T &rc);
2648
2649 //----------------------------------
2659 Tensor operator==(const Tensor &Lt, const Tensor &Rt);
2660
2670 template <class T>
2671 Tensor operator==(const T &lc, const Tensor &Rt);
2672
2682 template <class T>
2683 Tensor operator==(const Tensor &Lt, const T &rc);
2684
2685} // namespace cytnx
2686
2687#endif
Definition LinOp.hpp:20
A class to represent a scalar.
Definition Scalar.hpp:2470
an tensor (multi-dimensional array)
Definition Tensor.hpp:345
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:2449
std::vector< cytnx::UniTensor > Svd_truncate(const cytnx::UniTensor &Tin, const cytnx_uint64 &keepdim, const double &err=0, const bool &is_UvT=true, const bool &return_err=false)
Perform Singular-Value decomposition on a UniTensor with truncation.
std::vector< cytnx::UniTensor > Qr(const cytnx::UniTensor &Tin, const bool &is_tau=false)
Perform the QR decomposition on a UniTensor.
Tensor Dot(const Tensor &Tl, const Tensor &Tr)
dot product of two arrays.
cytnx::UniTensor Trace(const cytnx::UniTensor &Tin, const cytnx_int64 &a=0, const cytnx_int64 &b=1)
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.
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 Sum(const Tensor &Tn)
get the sum of all the elements.
Tensor Min(const Tensor &Tn)
get the minimum element.
void iSub(Tensor &Lt, const Tensor &Rt)
The subtraction function for Tensot, inplscely.
void Gemm_(const Scalar &a, const Tensor &x, const Tensor &y, const Scalar &b, Tensor &c)
Blas Gemm, performing , inplacely.
void Abs_(Tensor &Tin)
inplace perform elementwiase absolute value. @This is just a inplace version of Abs....
void Pow_(UniTensor &Tin, const double &p)
Take power p on all the elements in UniTensor, inplacely.
Tensor Abs(const Tensor &Tin)
Elementwise absolute value.
Tensor Outer(const Tensor &Tl, const Tensor &Tr)
perform outer produces of two rank-1 Tensor.
std::vector< cytnx::UniTensor > Gesvd_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)
Perform Singular-Value decomposition on a UniTensor with truncation.
void Axpy_(const Scalar &a, const Tensor &x, Tensor &y)
Blas Axpy, performing , inplacely.
Tensor Conj(const Tensor &Tin)
Conjugate all the element in Tensor.
std::vector< cytnx::UniTensor > Svd(const cytnx::UniTensor &Tin, const bool &is_UvT=true)
Perform Singular-Value decomposition on a UniTensor using divide-and-conquer method.
Tensor Matmul(const Tensor &TL, const Tensor &TR)
perform matrix multiplication on two tensors.
cytnx::UniTensor Mod(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
element-wise modulo
Tensor Expf(const Tensor &Tin)
Exponential all the element in Tensor.
Tensor Diag(const Tensor &Tin)
return a diagonal tensor with diagonal elements provided as Tin.
std::vector< Tensor > Lstsq(const Tensor &A, const Tensor &b, const float &rcond=-1)
Return the least-squares solution to a linear matrix equation.
std::vector< Tensor > Tridiag(const Tensor &Diag, const Tensor &Sub_diag, const bool &is_V=true, const bool &is_row=false, bool throw_excp=false)
perform diagonalization of symmetric tri-diagnoal matrix.
void Expf_(Tensor &Tin)
inplace perform Exponential on all the element in Tensor.
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 ei...
Tensor Det(const Tensor &Tl)
Calculate the determinant of a 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< cytnx::UniTensor > Gesvd(const cytnx::UniTensor &Tin, const bool &is_U=true, const bool &is_vT=true)
Perform Singular-Value decomposition on a UniTensor using ?gesvd method.
Tensor Inv(const Tensor &Tin, const double &clip)
Element-wise inverse with clip.
cytnx::UniTensor Mul(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The multiplication function between two UniTensor.
std::vector< Tensor > Lanczos(LinOp *Hop, const Tensor &Tin=Tensor(), const std::string method="Gnd", const double &CvgCrit=1.0e-14, const unsigned int &Maxiter=10000, const cytnx_uint64 &k=1, const bool &is_V=true, const bool &is_row=false, const cytnx_uint32 &max_krydim=0, const bool &verbose=false)
perform Lanczos for hermitian/symmetric matrices or linear function.
Tensor Max(const Tensor &Tn)
get the maximum element.
cytnx::UniTensor Sub(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The subtraction function between two UniTensor.
Tensor Norm(const Tensor &Tl)
Calculate the norm of a tensor.
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 >())
Tensor Axpy(const Scalar &a, const Tensor &x, const Tensor &y=Tensor())
Blas Axpy, performing , inplacely.
void Inv_(Tensor &Tin, const double &clip)
inplace perform Element-wise inverse with clip.
Tensor Vectordot(const Tensor &Tl, const Tensor &Tr, const bool &is_conj=false)
perform inner product of vectors
void Exp_(Tensor &Tin)
inplace perform Exponential on all the element in Tensor.
Tensor Exp(const Tensor &Tin)
Exponential all the element in Tensor.
Tensor Ger(const Tensor &x, const Tensor &y, const Scalar &a=Scalar())
Blas Ger, performing return = a*vec(x)*vec(y)^T.
Tensor Gemm(const Scalar &a, const Tensor &x, const Tensor &y)
Blas Gemm, performing return.
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.
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< cytnx::UniTensor > Qdr(const cytnx::UniTensor &Tin, const bool &is_tau=false)
Perform the QDR decomposition on a UniTensor.
void InvM_(Tensor &Tin)
inplace matrix inverse.
void iDiv(Tensor &Lt, const Tensor &Rt)
The inplace division function for Tensor, inplacely.
cytnx::UniTensor Add(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The addtion function between two UniTensor.
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 ra...
Tensor Directsum(const Tensor &T1, const Tensor &T2, const std::vector< cytnx_uint64 > &shared_axes)
perform directsum of two Tensor.
cytnx::UniTensor ExpM(const cytnx::UniTensor &Tin, const T &a, const T &b=0)
Perform the exponential function on a UniTensor.
void Conj_(Tensor &Tin)
inplace perform Conjugate on all the element in Tensor.
void iAdd(Tensor &Lt, const Tensor &Rt)
The addition function for Tensor, inplacely.
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 ei...
cytnx::UniTensor ExpH(const cytnx::UniTensor &Tin, const T &a, const T &b=0)
Perform the exponential function on a UniTensor, which the blocks are Hermitian matrix.
Tensor Cpr(const Tensor &Lt, const Tensor &Rt)
The comparison function for Tensor.
UniTensor Pow(const UniTensor &Tin, const double &p)
take power p on all the elements in UniTensor.
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 re...
std::vector< Tensor > Arnoldi(LinOp *Hop, const Tensor &Tin=Tensor(), const std::string which="LM", const cytnx_uint64 &maxiter=10000, const cytnx_double &cvg_crit=1.0e-9, const cytnx_uint64 &k=1, const bool &is_V=true, const bool &verbose=false)
perform Arnoldi for matrices or linear function.
Tensor InvM(const Tensor &Tin)
Matrix inverse.
void iMul(Tensor &Lt, const Tensor &Rt)
The multiplication function for Tensor, inplacely.
cytnx::UniTensor Div(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The division function between two UniTensor.
Definition Accessor.hpp:12
cytnx::UniTensor operator*(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The multiplication operator between two UniTensor.
double cytnx_double
Definition Type.hpp:43
uint32_t cytnx_uint32
Definition Type.hpp:46
cytnx::UniTensor operator-(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The subtraction operator between two UniTensor.
Tensor operator==(const Tensor &Lt, const Tensor &Rt)
The comparison operator for Tensor.
uint64_t cytnx_uint64
Definition Type.hpp:45
int64_t cytnx_int64
Definition Type.hpp:48
cytnx::UniTensor operator%(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The modulo operator between two UniTensor.
cytnx::UniTensor operator+(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The addtion operator between two UniTensor.
cytnx::UniTensor operator/(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The division operator between two UniTensor.