Cytnx v0.9.3
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 "UniTensor.hpp"
8#include "LinOp.hpp"
9
10#ifdef BACKEND_TORCH
11#else
12
13 #include "backend/Storage.hpp"
14 #include "backend/Scalar.hpp"
15 #include <functional>
16
17namespace cytnx {
20
32
42 template <class T>
44
54 template <class T>
56
68
78 template <class T>
80
90 template <class T>
92
104
114 template <class T>
116
126 template <class T>
128
140
150 template <class T>
152
162 template <class T>
164
176
186 template <class T>
188
198 template <class T>
200
211 namespace linalg {
212
213 // Add:
214 //==================================================
237
270 template <class T>
271 cytnx::UniTensor Add(const T &lc, const cytnx::UniTensor &Rt);
272
306 template <class T>
307 cytnx::UniTensor Add(const cytnx::UniTensor &Lt, const T &rc);
308
309 // Sub:
310 //==================================================
334
367 template <class T>
368 cytnx::UniTensor Sub(const T &lc, const cytnx::UniTensor &Rt);
369
402 template <class T>
403 cytnx::UniTensor Sub(const cytnx::UniTensor &Lt, const T &rc);
404
405 // Mul:
406 //==================================================
430
463 template <class T>
464 cytnx::UniTensor Mul(const T &lc, const cytnx::UniTensor &Rt);
465
498 template <class T>
499 cytnx::UniTensor Mul(const cytnx::UniTensor &Lt, const T &rc);
500
501 // Div:
502 //==================================================
526
560 template <class T>
561 cytnx::UniTensor Div(const T &lc, const cytnx::UniTensor &Rt);
562
596 template <class T>
597 cytnx::UniTensor Div(const cytnx::UniTensor &Lt, const T &rc);
598
599 // Mod:
600 //==================================================
626
657 template <class T>
658 cytnx::UniTensor Mod(const T &lc, const cytnx::UniTensor &Rt);
659
690 template <class T>
691 cytnx::UniTensor Mod(const cytnx::UniTensor &Lt, const T &rc);
692
699 std::vector<cytnx::UniTensor> Svd(const cytnx::UniTensor &Tin, const bool &is_UvT = true);
700
708 std::vector<cytnx::UniTensor> Gesvd(const cytnx::UniTensor &Tin, const bool &is_U = true,
709 const bool &is_vT = true);
710
721 std::vector<cytnx::UniTensor> Svd_truncate(const cytnx::UniTensor &Tin,
722 const cytnx_uint64 &keepdim, const double &err = 0,
723 const bool &is_UvT = true,
724 const unsigned int &return_err = 0);
725
736 std::vector<cytnx::UniTensor> Gesvd_truncate(const cytnx::UniTensor &Tin,
737 const cytnx_uint64 &keepdim, const double &err = 0,
738 const bool &is_U = true, const bool &is_vT = true,
739 const unsigned int &return_err = 0);
740
741 std::vector<cytnx::UniTensor> Hosvd(
742 const cytnx::UniTensor &Tin, const std::vector<cytnx_uint64> &mode,
743 const bool &is_core = true, const bool &is_Ls = false,
744 const std::vector<cytnx_int64> &trucate_dim = std::vector<cytnx_int64>());
745
754 template <typename T>
755 cytnx::UniTensor ExpH(const cytnx::UniTensor &Tin, const T &a, const T &b = 0);
756
764 template <typename T>
765 cytnx::UniTensor ExpM(const cytnx::UniTensor &Tin, const T &a, const T &b = 0);
766
776
785
791 const cytnx_int64 &b = 1);
792
800 cytnx::UniTensor Trace(const cytnx::UniTensor &Tin, const std::string &a, const std::string &b);
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
858
865
866 //====================================================================================
867 // [Tensor]
868 // ====================================================================================
869 //====================================================================================
870
894 Tensor Add(const Tensor &Lt, const Tensor &Rt);
895
917 template <class T>
918 Tensor Add(const T &lc, const Tensor &Rt);
919
941 template <class T>
942 Tensor Add(const Tensor &Lt, const T &rc);
943
968 void iAdd(Tensor &Lt, const Tensor &Rt);
969
970 // Sub:
971 //==================================================
994 Tensor Sub(const Tensor &Lt, const Tensor &Rt);
995
1017 template <class T>
1018 Tensor Sub(const T &lc, const Tensor &Rt);
1019
1041 template <class T>
1042 Tensor Sub(const Tensor &Lt, const T &rc);
1043
1068 void iSub(Tensor &Lt, const Tensor &Rt);
1069
1070 // Mul:
1071 //==================================================
1094 Tensor Mul(const Tensor &Lt, const Tensor &Rt);
1095
1117 template <class T>
1118 Tensor Mul(const T &lc, const Tensor &Rt);
1119
1141 template <class T>
1142 Tensor Mul(const Tensor &Lt, const T &rc);
1143
1168 void iMul(Tensor &Lt, const Tensor &Rt);
1169
1170 // Div:
1171 //==================================================
1195 Tensor Div(const Tensor &Lt, const Tensor &Rt);
1196
1219 template <class T>
1220 Tensor Div(const T &lc, const Tensor &Rt);
1221
1244 template <class T>
1245 Tensor Div(const Tensor &Lt, const T &rc);
1246
1271 void iDiv(Tensor &Lt, const Tensor &Rt);
1272
1273 // Mod:
1274 //==================================================
1275
1298 Tensor Mod(const Tensor &Lt, const Tensor &Rt);
1299
1320 template <class T>
1321 Tensor Mod(const T &lc, const Tensor &Rt);
1322
1343 template <class T>
1344 Tensor Mod(const Tensor &Lt, const T &rc);
1345
1346 // Cpr:
1347 //==================================================
1373 Tensor Cpr(const Tensor &Lt, const Tensor &Rt);
1374
1399 template <class T>
1400 Tensor Cpr(const T &lc, const Tensor &Rt);
1401
1426 template <class T>
1427 Tensor Cpr(const Tensor &Lt, const T &rc);
1428
1429 // Norm:
1430 //=================================================
1440 Tensor Norm(const Tensor &Tl);
1441
1442 // Det:
1443 //=================================================
1452 Tensor Det(const Tensor &Tl);
1453
1454 // Svd:
1455 //==================================================
1481 std::vector<Tensor> Svd(const Tensor &Tin, const bool &is_UvT = true);
1482
1483 // Gesvd:
1484 //==================================================
1512 std::vector<Tensor> Gesvd(const Tensor &Tin, const bool &is_U = true, const bool &is_vT = true);
1513
1514 // Svd_truncate:
1515 //==================================================
1547 std::vector<Tensor> Svd_truncate(const Tensor &Tin, const cytnx_uint64 &keepdim,
1548 const double &err = 0, const bool &is_UvT = true,
1549 const unsigned int &return_err = 0);
1550
1551 // Gesvd_truncate:
1552 //==================================================
1586 std::vector<Tensor> Gesvd_truncate(const Tensor &Tin, const cytnx_uint64 &keepdim,
1587 const double &err = 0, const bool &is_U = true,
1588 const bool &is_vT = true,
1589 const unsigned int &return_err = 0);
1590
1591 // Hosvd:
1592 std::vector<Tensor> Hosvd(
1593 const Tensor &Tin, const std::vector<cytnx_uint64> &mode, const bool &is_core = true,
1594 const bool &is_Ls = false,
1595 const std::vector<cytnx_int64> &trucate_dim = std::vector<cytnx_int64>());
1596
1597 // Qr:
1598 //==================================================
1624 std::vector<Tensor> Qr(const Tensor &Tin, const bool &is_tau = false);
1625
1626 // Qdr:
1627 //==================================================
1647 std::vector<Tensor> Qdr(const Tensor &Tin, const bool &is_tau = false);
1648
1649 // Eigh:
1650 //==================================================
1673 std::vector<Tensor> Eigh(const Tensor &Tin, const bool &is_V = true, const bool &row_v = false);
1674
1675 // Eig:
1676 //==================================================
1696 std::vector<Tensor> Eig(const Tensor &Tin, const bool &is_V = true, const bool &row_v = false);
1697
1698 // Trace:
1699 //==================================================
1713 Tensor Trace(const Tensor &Tn, const cytnx_uint64 &axisA = 0, const cytnx_uint64 &axisB = 1);
1714
1715 // Min:
1716 //==================================================
1722 Tensor Min(const Tensor &Tn);
1723
1724 // Max:
1725 //==================================================
1731 Tensor Max(const Tensor &Tn);
1732
1733 // Sum:
1734 //==================================================
1739 Tensor Sum(const Tensor &Tn);
1740
1741 // Matmul:
1742 //==================================================
1754 Tensor Matmul(const Tensor &TL, const Tensor &TR);
1755
1756 // Matmul_dg:
1757 //==================================================
1764 Tensor Matmul_dg(const Tensor &Tl, const Tensor &Tr);
1765
1766 // InvM:
1767 //==================================================
1774 Tensor InvM(const Tensor &Tin);
1782 void InvM_(Tensor &Tin);
1783
1784 // Inv:
1785 //==================================================
1804 Tensor Inv(const Tensor &Tin, const double &clip);
1805
1818 void Inv_(Tensor &Tin, const double &clip);
1819
1820 // Conj:
1821 //==================================================
1836 Tensor Conj(const Tensor &Tin);
1837
1846 void Conj_(Tensor &Tin);
1847
1848 // Exp:
1849 //==================================================
1863 Tensor Exp(const Tensor &Tin);
1864
1878 Tensor Expf(const Tensor &Tin);
1879
1889 void Exp_(Tensor &Tin);
1890
1900 void Expf_(Tensor &Tin);
1901
1902 // Pow:
1903 //==================================================
1915 Tensor Pow(const Tensor &Tin, const double &p);
1916
1923 void Pow_(Tensor &Tin, const double &p);
1924
1925 // Abs:
1926 //==================================================
1934 Tensor Abs(const Tensor &Tin);
1935
1943 void Abs_(Tensor &Tin);
1944
1945 // Diag:
1946 //==================================================
1955 Tensor Diag(const Tensor &Tin);
1956
1957 // Tensordot:
1958 //==================================================
1974 Tensor Tensordot(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl,
1975 const std::vector<cytnx_uint64> &idxr, const bool &cacheL = false,
1976 const bool &cacheR = false);
1977
1978 // Tensordot_dg:
1979 //==================================================
1997 Tensor Tensordot_dg(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl,
1998 const std::vector<cytnx_uint64> &idxr, const bool &diag_L);
1999
2000 // Outer:
2001 //==================================================
2012 Tensor Outer(const Tensor &Tl, const Tensor &Tr);
2013
2014 // Kron:
2015 //==================================================
2032 Tensor Kron(const Tensor &Tl, const Tensor &Tr, const bool &Tl_pad_left = false,
2033 const bool &Tr_pad_left = false);
2034
2035 // Directsum:
2036 //==================================================
2051 Tensor Directsum(const Tensor &T1, const Tensor &T2,
2052 const std::vector<cytnx_uint64> &shared_axes);
2053
2054 // VectorDot:
2055 //=================================================
2067 Tensor Vectordot(const Tensor &Tl, const Tensor &Tr, const bool &is_conj = false);
2068
2069 // Dot:
2070 //=================================================
2090 Tensor Dot(const Tensor &Tl, const Tensor &Tr);
2091
2092 // Tridiag:
2093 //===========================================
2114 std::vector<Tensor> Tridiag(const Tensor &Diag, const Tensor &Sub_diag, const bool &is_V = true,
2115 const bool &is_row = false, bool throw_excp = false);
2116
2117 // ExpH:
2118 //===========================================
2136 template <typename T>
2137 Tensor ExpH(const Tensor &in, const T &a, const T &b = 0);
2150 Tensor ExpH(const Tensor &in);
2151
2152 // ExpM:
2153 //===========================================
2166 template <typename T>
2167 Tensor ExpM(const Tensor &in, const T &a, const T &b = 0);
2168
2179 Tensor ExpM(const Tensor &in);
2180
2181 // Arnoldi:
2182 //===========================================
2212 std::vector<Tensor> Arnoldi(LinOp *Hop, const Tensor &Tin = Tensor(),
2213 const std::string which = "LM", const cytnx_uint64 &maxiter = 10000,
2214 const cytnx_double &cvg_crit = 1.0e-9, const cytnx_uint64 &k = 1,
2215 const bool &is_V = true, const bool &verbose = false);
2216
2217 // Lanczos:
2218 //===========================================
2249 std::vector<Tensor> Lanczos(LinOp *Hop, const Tensor &Tin = Tensor(),
2250 const std::string method = "Gnd", const double &CvgCrit = 1.0e-14,
2251 const unsigned int &Maxiter = 10000, const cytnx_uint64 &k = 1,
2252 const bool &is_V = true, const bool &is_row = false,
2253 const cytnx_uint32 &max_krydim = 0, const bool &verbose = false);
2254
2255 // Lanczos:
2256 //===========================================
2287 std::vector<UniTensor> Lanczos(LinOp *Hop, const UniTensor &Tin = UniTensor(),
2288 const std::string method = "Gnd",
2289 const double &CvgCrit = 1.0e-14,
2290 const unsigned int &Maxiter = 10000, const cytnx_uint64 &k = 1,
2291 const bool &is_V = true, const bool &is_row = false,
2292 const cytnx_uint32 &max_krydim = 4, const bool &verbose = false);
2293
2294 // Lanczos:
2295 //===========================================
2317 std::vector<Tensor> Lanczos_ER(LinOp *Hop, const cytnx_uint64 &k = 1, const bool &is_V = true,
2318 const cytnx_uint64 &maxiter = 10000,
2319 const double &CvgCrit = 1.0e-14, const bool &is_row = false,
2320 const Tensor &Tin = Tensor(), const cytnx_uint32 &max_krydim = 4,
2321 const bool &verbose = false);
2322
2323 // Lanczos:
2324 //===========================================
2343 std::vector<Tensor> Lanczos_Gnd(LinOp *Hop, const double &CvgCrit = 1.0e-14,
2344 const bool &is_V = true, const Tensor &Tin = Tensor(),
2345 const bool &verbose = false,
2346 const unsigned int &Maxiter = 100000);
2347
2348 // Lanczos:
2349 //===============================================
2368 std::vector<UniTensor> Lanczos_Gnd_Ut(LinOp *Hop, const UniTensor &Tin,
2369 const double &CvgCrit = 1.0e-14, const bool &is_V = true,
2370 const bool &verbose = false,
2371 const unsigned int &Maxiter = 100000);
2372
2373 // Lstsq:
2374 //===========================================
2400 std::vector<Tensor> Lstsq(const Tensor &A, const Tensor &b, const float &rcond = -1);
2401
2419 Tensor Axpy(const Scalar &a, const Tensor &x, const Tensor &y = Tensor());
2420
2439 void Axpy_(const Scalar &a, const Tensor &x, Tensor &y);
2440
2455 Tensor Ger(const Tensor &x, const Tensor &y, const Scalar &a = Scalar());
2456
2474 void Gemm_(const Scalar &a, const Tensor &x, const Tensor &y, const Scalar &b, Tensor &c);
2475
2491 Tensor Gemm(const Scalar &a, const Tensor &x, const Tensor &y);
2492
2520 void Gemm_Batch(const std::vector<cytnx_int64> &m_array,
2521 const std::vector<cytnx_int64> &n_array,
2522 const std::vector<cytnx_int64> &k_array, const std::vector<Scalar> &alpha_array,
2523 const std::vector<Tensor> &a_tensors, const std::vector<Tensor> &b_tensors,
2524 const std::vector<Scalar> &beta_array, std::vector<Tensor> &c_tensors,
2525 const cytnx_int64 group_count, const std::vector<cytnx_int64> &group_size);
2526
2528 void __Gemm_Batch(const std::vector<char> &transa_array, const std::vector<char> &transb_array,
2529 const std::vector<blas_int> &m_array, const std::vector<blas_int> &n_array,
2530 const std::vector<blas_int> &k_array, const std::vector<Scalar> &alpha_array,
2531 const void **a_array, const void **b_array,
2532 const std::vector<Scalar> &beta_array, void **c_array,
2533 const blas_int group_count, const std::vector<blas_int> &group_size,
2534 const unsigned int dtype, const int device);
2535
2537
2538 } // namespace linalg
2539
2540 // operators:
2551 Tensor operator+(const Tensor &Lt, const Tensor &Rt);
2552
2562 template <class T>
2563 Tensor operator+(const T &lc, const Tensor &Rt);
2564
2574 template <class T>
2575 Tensor operator+(const Tensor &Lt, const T &rc);
2576
2577 //------------------------------------
2588 Tensor operator-(const Tensor &Lt, const Tensor &Rt);
2589
2599 template <class T>
2600 Tensor operator-(const T &lc, const Tensor &Rt);
2601
2611 template <class T>
2612 Tensor operator-(const Tensor &Lt, const T &rc);
2613
2614 //-----------------------------------
2625 Tensor operator*(const Tensor &Lt, const Tensor &Rt);
2626
2636 template <class T>
2637 Tensor operator*(const T &lc, const Tensor &Rt);
2638
2648 template <class T>
2649 Tensor operator*(const Tensor &Lt, const T &rc);
2650
2651 //----------------------------------
2664 Tensor operator/(const Tensor &Lt, const Tensor &Rt);
2665
2676 template <class T>
2677 Tensor operator/(const T &lc, const Tensor &Rt);
2678
2689 template <class T>
2690 Tensor operator/(const Tensor &Lt, const T &rc);
2691
2692 //----------------------------------
2703 Tensor operator%(const Tensor &Lt, const Tensor &Rt);
2704
2714 template <class T>
2715 Tensor operator%(const T &lc, const Tensor &Rt);
2716
2726 template <class T>
2727 Tensor operator%(const Tensor &Lt, const T &rc);
2728
2729 //----------------------------------
2739 Tensor operator==(const Tensor &Lt, const Tensor &Rt);
2740
2750 template <class T>
2751 Tensor operator==(const T &lc, const Tensor &Rt);
2752
2762 template <class T>
2763 Tensor operator==(const Tensor &Lt, const T &rc);
2764
2765} // namespace cytnx
2766
2767#endif // BACKEND_TORCH
2768
2769#endif
int32_t blas_int
Definition Type.hpp:25
Definition LinOp.hpp:21
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:1706
void Gemm_Batch(const std::vector< cytnx_int64 > &m_array, const std::vector< cytnx_int64 > &n_array, const std::vector< cytnx_int64 > &k_array, const std::vector< Scalar > &alpha_array, const std::vector< Tensor > &a_tensors, const std::vector< Tensor > &b_tensors, const std::vector< Scalar > &beta_array, std::vector< Tensor > &c_tensors, const cytnx_int64 group_count, const std::vector< cytnx_int64 > &group_size)
Blas Gemm_Batch, performing many(batch) , inplacely. You do not need to consider the row-major or col...
cytnx::UniTensor Conj(const cytnx::UniTensor &UT)
Elementwise conjugate of the UniTensor.
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.
void Axpy_(const Scalar &a, const Tensor &x, Tensor &y)
Blas Axpy, performing , inplacely.
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.
std::vector< cytnx::UniTensor > Svd_truncate(const cytnx::UniTensor &Tin, const cytnx_uint64 &keepdim, const double &err=0, const bool &is_UvT=true, const unsigned int &return_err=0)
Perform Singular-Value decomposition on a UniTensor with truncation.
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
void Conj_(cytnx::UniTensor &UT)
Inplace elementwise conjugate of the UniTensor.
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.
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 unsigned int &return_err=0)
Perform Singular-Value decomposition on a UniTensor with truncation.
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 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.
Helper function to print vector with ODT:
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:53
uint32_t cytnx_uint32
Definition Type.hpp:56
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.
int get_mkl_code()
uint64_t cytnx_uint64
Definition Type.hpp:55
int64_t cytnx_int64
Definition Type.hpp:58
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.
int set_mkl_ilp64()