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 {
15
26
36 template <class T>
38
48 template <class T>
50
61
71 template <class T>
73
83 template <class T>
85
96
106 template <class T>
108
118 template <class T>
120
131
141 template <class T>
143
153 template <class T>
155
166
176 template <class T>
178
188 template <class T>
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
699 std::vector<cytnx::UniTensor> Gesvd(const cytnx::UniTensor &Tin, const bool &is_U = true,
700 const bool &is_vT = true);
701
712 std::vector<cytnx::UniTensor> Svd_truncate(const cytnx::UniTensor &Tin,
713 const cytnx_uint64 &keepdim, const double &err = 0,
714 const bool &is_UvT = true,
715 const bool &return_err = false);
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 std::vector<cytnx::UniTensor> Hosvd(
733 const cytnx::UniTensor &Tin, const std::vector<cytnx_uint64> &mode,
734 const bool &is_core = true, const bool &is_Ls = false,
735 const std::vector<cytnx_int64> &trucate_dim = std::vector<cytnx_int64>());
736
745 template <typename T>
746 cytnx::UniTensor ExpH(const cytnx::UniTensor &Tin, const T &a, const T &b = 0);
747
755 template <typename T>
756 cytnx::UniTensor ExpM(const cytnx::UniTensor &Tin, const T &a, const T &b = 0);
757
767
776
782 const cytnx_int64 &b = 1);
783
791 cytnx::UniTensor Trace(const cytnx::UniTensor &Tin, const std::string &a, const std::string &b);
792
801 std::vector<cytnx::UniTensor> Qr(const cytnx::UniTensor &Tin, const bool &is_tau = false);
802
811 std::vector<cytnx::UniTensor> Qdr(const cytnx::UniTensor &Tin, const bool &is_tau = false);
812
813 // Pow:
814 //==================================================
827 UniTensor Pow(const UniTensor &Tin, const double &p);
828
840 void Pow_(UniTensor &Tin, const double &p);
841
842 //====================================================================================
843 // [Tensor]
844 // ====================================================================================
845 //====================================================================================
846
870 Tensor Add(const Tensor &Lt, const Tensor &Rt);
871
893 template <class T>
894 Tensor Add(const T &lc, const Tensor &Rt);
895
917 template <class T>
918 Tensor Add(const Tensor &Lt, const T &rc);
919
944 void iAdd(Tensor &Lt, const Tensor &Rt);
945
946 // Sub:
947 //==================================================
970 Tensor Sub(const Tensor &Lt, const Tensor &Rt);
971
993 template <class T>
994 Tensor Sub(const T &lc, const Tensor &Rt);
995
1017 template <class T>
1018 Tensor Sub(const Tensor &Lt, const T &rc);
1019
1044 void iSub(Tensor &Lt, const Tensor &Rt);
1045
1046 // Mul:
1047 //==================================================
1070 Tensor Mul(const Tensor &Lt, const Tensor &Rt);
1071
1093 template <class T>
1094 Tensor Mul(const T &lc, const Tensor &Rt);
1095
1117 template <class T>
1118 Tensor Mul(const Tensor &Lt, const T &rc);
1119
1144 void iMul(Tensor &Lt, const Tensor &Rt);
1145
1146 // Div:
1147 //==================================================
1171 Tensor Div(const Tensor &Lt, const Tensor &Rt);
1172
1195 template <class T>
1196 Tensor Div(const T &lc, const Tensor &Rt);
1197
1220 template <class T>
1221 Tensor Div(const Tensor &Lt, const T &rc);
1222
1247 void iDiv(Tensor &Lt, const Tensor &Rt);
1248
1249 // Mod:
1250 //==================================================
1251
1274 Tensor Mod(const Tensor &Lt, const Tensor &Rt);
1275
1296 template <class T>
1297 Tensor Mod(const T &lc, const Tensor &Rt);
1298
1319 template <class T>
1320 Tensor Mod(const Tensor &Lt, const T &rc);
1321
1322 // Cpr:
1323 //==================================================
1349 Tensor Cpr(const Tensor &Lt, const Tensor &Rt);
1350
1375 template <class T>
1376 Tensor Cpr(const T &lc, const Tensor &Rt);
1377
1402 template <class T>
1403 Tensor Cpr(const Tensor &Lt, const T &rc);
1404
1405 // Norm:
1406 //=================================================
1416 Tensor Norm(const Tensor &Tl);
1417
1418 // Det:
1419 //=================================================
1428 Tensor Det(const Tensor &Tl);
1429
1430 // Svd:
1431 //==================================================
1457 std::vector<Tensor> Svd(const Tensor &Tin, const bool &is_UvT = true);
1458
1459 // Gesvd:
1460 //==================================================
1488 std::vector<Tensor> Gesvd(const Tensor &Tin, const bool &is_U = true, const bool &is_vT = true);
1489
1490 // Svd_truncate:
1491 //==================================================
1522 std::vector<Tensor> Svd_truncate(const Tensor &Tin, const cytnx_uint64 &keepdim,
1523 const double &err = 0, const bool &is_UvT = true,
1524 const bool &return_err = false);
1525
1526 // Gesvd_truncate:
1527 //==================================================
1560 std::vector<Tensor> Gesvd_truncate(const Tensor &Tin, const cytnx_uint64 &keepdim,
1561 const double &err = 0, const bool &is_U = true,
1562 const bool &is_vT = true, const bool &return_err = false);
1563
1564 // Hosvd:
1565 std::vector<Tensor> Hosvd(
1566 const Tensor &Tin, const std::vector<cytnx_uint64> &mode, const bool &is_core = true,
1567 const bool &is_Ls = false,
1568 const std::vector<cytnx_int64> &trucate_dim = std::vector<cytnx_int64>());
1569
1570 // Qr:
1571 //==================================================
1597 std::vector<Tensor> Qr(const Tensor &Tin, const bool &is_tau = false);
1598
1599 // Qdr:
1600 //==================================================
1620 std::vector<Tensor> Qdr(const Tensor &Tin, const bool &is_tau = false);
1621
1622 // Eigh:
1623 //==================================================
1644 std::vector<Tensor> Eigh(const Tensor &Tin, const bool &is_V = true, const bool &row_v = false);
1645
1646 // Eig:
1647 //==================================================
1667 std::vector<Tensor> Eig(const Tensor &Tin, const bool &is_V = true, const bool &row_v = false);
1668
1669 // Trace:
1670 //==================================================
1684 Tensor Trace(const Tensor &Tn, const cytnx_uint64 &axisA = 0, const cytnx_uint64 &axisB = 1);
1685
1686 // Min:
1687 //==================================================
1693 Tensor Min(const Tensor &Tn);
1694
1695 // Max:
1696 //==================================================
1702 Tensor Max(const Tensor &Tn);
1703
1704 // Sum:
1705 //==================================================
1710 Tensor Sum(const Tensor &Tn);
1711
1712 // Matmul:
1713 //==================================================
1725 Tensor Matmul(const Tensor &TL, const Tensor &TR);
1726
1727 // Matmul_dg:
1728 //==================================================
1735 Tensor Matmul_dg(const Tensor &Tl, const Tensor &Tr);
1736
1737 // InvM:
1738 //==================================================
1745 Tensor InvM(const Tensor &Tin);
1753 void InvM_(Tensor &Tin);
1754
1755 // Inv:
1756 //==================================================
1775 Tensor Inv(const Tensor &Tin, const double &clip);
1776
1789 void Inv_(Tensor &Tin, const double &clip);
1790
1791 // Conj:
1792 //==================================================
1807 Tensor Conj(const Tensor &Tin);
1808
1817 void Conj_(Tensor &Tin);
1818
1819 // Exp:
1820 //==================================================
1834 Tensor Exp(const Tensor &Tin);
1835
1849 Tensor Expf(const Tensor &Tin);
1850
1860 void Exp_(Tensor &Tin);
1861
1871 void Expf_(Tensor &Tin);
1872
1873 // Pow:
1874 //==================================================
1886 Tensor Pow(const Tensor &Tin, const double &p);
1887
1894 void Pow_(Tensor &Tin, const double &p);
1895
1896 // Abs:
1897 //==================================================
1905 Tensor Abs(const Tensor &Tin);
1906
1914 void Abs_(Tensor &Tin);
1915
1916 // Diag:
1917 //==================================================
1926 Tensor Diag(const Tensor &Tin);
1927
1928 // Tensordot:
1929 //==================================================
1945 Tensor Tensordot(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl,
1946 const std::vector<cytnx_uint64> &idxr, const bool &cacheL = false,
1947 const bool &cacheR = false);
1948
1949 // Tensordot_dg:
1950 //==================================================
1968 Tensor Tensordot_dg(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl,
1969 const std::vector<cytnx_uint64> &idxr, const bool &diag_L);
1970
1971 // Outer:
1972 //==================================================
1983 Tensor Outer(const Tensor &Tl, const Tensor &Tr);
1984
1985 // Kron:
1986 //==================================================
2003 Tensor Kron(const Tensor &Tl, const Tensor &Tr, const bool &Tl_pad_left = false,
2004 const bool &Tr_pad_left = false);
2005
2006 // Directsum:
2007 //==================================================
2022 Tensor Directsum(const Tensor &T1, const Tensor &T2,
2023 const std::vector<cytnx_uint64> &shared_axes);
2024
2025 // VectorDot:
2026 //=================================================
2038 Tensor Vectordot(const Tensor &Tl, const Tensor &Tr, const bool &is_conj = false);
2039
2040 // Dot:
2041 //=================================================
2061 Tensor Dot(const Tensor &Tl, const Tensor &Tr);
2062
2063 // Tridiag:
2064 //===========================================
2085 std::vector<Tensor> Tridiag(const Tensor &Diag, const Tensor &Sub_diag, const bool &is_V = true,
2086 const bool &is_row = false, bool throw_excp = false);
2087
2088 // ExpH:
2089 //===========================================
2102 template <typename T>
2103 Tensor ExpH(const Tensor &in, const T &a, const T &b = 0);
2104 Tensor ExpH(const Tensor &in);
2105
2106 // ExpM:
2107 //===========================================
2119 template <typename T>
2120 Tensor ExpM(const Tensor &in, const T &a, const T &b = 0);
2121
2131 Tensor ExpM(const Tensor &in);
2132
2133 // Arnoldi:
2134 //===========================================
2164 std::vector<Tensor> Arnoldi(LinOp *Hop, const Tensor &Tin = Tensor(),
2165 const std::string which = "LM", const cytnx_uint64 &maxiter = 10000,
2166 const cytnx_double &cvg_crit = 1.0e-9, const cytnx_uint64 &k = 1,
2167 const bool &is_V = true, const bool &verbose = false);
2168
2169 // Lanczos:
2170 //===========================================
2201 std::vector<Tensor> Lanczos(LinOp *Hop, const Tensor &Tin = Tensor(),
2202 const std::string method = "Gnd", const double &CvgCrit = 1.0e-14,
2203 const unsigned int &Maxiter = 10000, const cytnx_uint64 &k = 1,
2204 const bool &is_V = true, const bool &is_row = false,
2205 const cytnx_uint32 &max_krydim = 0, const bool &verbose = false);
2206
2207 // Lanczos:
2208 //===========================================
2239 std::vector<UniTensor> Lanczos(LinOp *Hop, const UniTensor &Tin = UniTensor(),
2240 const std::string method = "Gnd",
2241 const double &CvgCrit = 1.0e-14,
2242 const unsigned int &Maxiter = 10000, const cytnx_uint64 &k = 1,
2243 const bool &is_V = true, const bool &is_row = false,
2244 const cytnx_uint32 &max_krydim = 4, const bool &verbose = false);
2245
2246 // Lanczos:
2247 //===========================================
2269 std::vector<Tensor> Lanczos_ER(LinOp *Hop, const cytnx_uint64 &k = 1, const bool &is_V = true,
2270 const cytnx_uint64 &maxiter = 10000,
2271 const double &CvgCrit = 1.0e-14, const bool &is_row = false,
2272 const Tensor &Tin = Tensor(), const cytnx_uint32 &max_krydim = 4,
2273 const bool &verbose = false);
2274
2275 // Lanczos:
2276 //===========================================
2295 std::vector<Tensor> Lanczos_Gnd(LinOp *Hop, const double &CvgCrit = 1.0e-14,
2296 const bool &is_V = true, const Tensor &Tin = Tensor(),
2297 const bool &verbose = false,
2298 const unsigned int &Maxiter = 100000);
2299
2300 // Lanczos:
2301 //===============================================
2320 std::vector<UniTensor> Lanczos_Gnd_Ut(LinOp *Hop, const UniTensor &Tin,
2321 const double &CvgCrit = 1.0e-14, const bool &is_V = true,
2322 const bool &verbose = false,
2323 const unsigned int &Maxiter = 100000);
2324
2325 // Lstsq:
2326 //===========================================
2352 std::vector<Tensor> Lstsq(const Tensor &A, const Tensor &b, const float &rcond = -1);
2353
2371 Tensor Axpy(const Scalar &a, const Tensor &x, const Tensor &y = Tensor());
2372
2391 void Axpy_(const Scalar &a, const Tensor &x, Tensor &y);
2392
2407 Tensor Ger(const Tensor &x, const Tensor &y, const Scalar &a = Scalar());
2408
2426 void Gemm_(const Scalar &a, const Tensor &x, const Tensor &y, const Scalar &b, Tensor &c);
2427
2443 Tensor Gemm(const Scalar &a, const Tensor &x, const Tensor &y);
2444
2472 void Gemm_Batch(const std::vector<cytnx_int64> &m_array,
2473 const std::vector<cytnx_int64> &n_array,
2474 const std::vector<cytnx_int64> &k_array, const std::vector<Scalar> &alpha_array,
2475 const std::vector<Tensor> &a_tensors, const std::vector<Tensor> &b_tensors,
2476 const std::vector<Scalar> &beta_array, std::vector<Tensor> &c_tensors,
2477 const cytnx_int64 group_count, const std::vector<cytnx_int64> &group_size);
2478
2479 } // namespace linalg
2480
2481 // operators:
2491 Tensor operator+(const Tensor &Lt, const Tensor &Rt);
2492
2502 template <class T>
2503 Tensor operator+(const T &lc, const Tensor &Rt);
2504
2514 template <class T>
2515 Tensor operator+(const Tensor &Lt, const T &rc);
2516
2517 //------------------------------------
2527 Tensor operator-(const Tensor &Lt, const Tensor &Rt);
2528
2538 template <class T>
2539 Tensor operator-(const T &lc, const Tensor &Rt);
2540
2550 template <class T>
2551 Tensor operator-(const Tensor &Lt, const T &rc);
2552
2553 //-----------------------------------
2563 Tensor operator*(const Tensor &Lt, const Tensor &Rt);
2564
2574 template <class T>
2575 Tensor operator*(const T &lc, const Tensor &Rt);
2576
2586 template <class T>
2587 Tensor operator*(const Tensor &Lt, const T &rc);
2588
2589 //----------------------------------
2600 Tensor operator/(const Tensor &Lt, const Tensor &Rt);
2601
2612 template <class T>
2613 Tensor operator/(const T &lc, const Tensor &Rt);
2614
2625 template <class T>
2626 Tensor operator/(const Tensor &Lt, const T &rc);
2627
2628 //----------------------------------
2638 Tensor operator%(const Tensor &Lt, const Tensor &Rt);
2639
2649 template <class T>
2650 Tensor operator%(const T &lc, const Tensor &Rt);
2651
2661 template <class T>
2662 Tensor operator%(const Tensor &Lt, const T &rc);
2663
2664 //----------------------------------
2674 Tensor operator==(const Tensor &Lt, const Tensor &Rt);
2675
2685 template <class T>
2686 Tensor operator==(const T &lc, const Tensor &Rt);
2687
2697 template <class T>
2698 Tensor operator==(const Tensor &Lt, const T &rc);
2699
2700} // namespace cytnx
2701
2702#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:1705
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.
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...
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.
int set_mkl_ilp64()