32 "Function to perform matrix multiplication of two 2D tensors with "
38 double alpha,
double beta) {
41 AddMM(A, B, output, alpha, beta);
44 "Function to perform addmm of two 2D tensors with compatible "
45 "shapes. Specifically this function returns output = alpha * A @ B "
47 "input"_a,
"A"_a,
"B"_a,
"alpha"_a,
"beta"_a);
55 "Function to compute determinant of a 2D square tensor.",
"A"_a);
59 [](
const Tensor &A,
bool permute_l) {
60 Tensor permutation, lower, upper;
61 LU(A, permutation, lower, upper, permute_l);
62 return py::make_tuple(permutation, lower, upper);
64 "Function to compute LU factorisation of a square 2D tensor.",
65 "A"_a,
"permute_l"_a =
false);
72 return py::make_tuple(ipiv, output);
74 "Function to compute LU factorisation of a square 2D tensor.",
84 "Function to inverse a square 2D tensor.",
"A"_a);
93 "Function to solve X for a linear system AX = B where A is a "
105 "Function to solve X for a linear system AX = B where A is a full "
114 return py::make_tuple(U, S, VT);
116 "Function to decompose A with A = U S VT.",
"A"_a);
120 [](
const Tensor &A,
const int diagonal) {
122 Triu(A, U, diagonal);
125 "Function to get upper triangular matrix, above diagonal",
"A"_a,
130 [](
const Tensor &A,
const int diagonal) {
132 Tril(A, L, diagonal);
135 "Function to get lower triangular matrix, below diagonal",
"A"_a,
140 [](
const Tensor &A,
const int diagonal = 0) {
142 Triul(A, U, L, diagonal);
143 return py::make_tuple(U, L);
145 "Function to get both upper and lower triangular matrix",
"A"_a,
Tensor Expand(const SizeVector &dst_shape) const
SizeVector GetShape() const
void LeastSquares(const Tensor &A, const Tensor &B, Tensor &X)
Solve AX = B with QR decomposition. A is a full-rank m x n matrix (m >= n).
void Solve(const Tensor &A, const Tensor &B, Tensor &X)
Solve AX = B with LU decomposition. A is a square matrix.
void SVD(const Tensor &A, Tensor &U, Tensor &S, Tensor &VT)
void LUIpiv(const Tensor &A, Tensor &ipiv, Tensor &output)
void AddMM(const Tensor &A, const Tensor &B, Tensor &output, double alpha, double beta)
void Triu(const Tensor &A, Tensor &output, const int diagonal)
void Triul(const Tensor &A, Tensor &upper, Tensor &lower, const int diagonal)
void Inverse(const Tensor &A, Tensor &output)
Computes A^{-1} with LU factorization, where A is a N x N square matrix.
void Tril(const Tensor &A, Tensor &output, const int diagonal)
void Matmul(const Tensor &A, const Tensor &B, Tensor &output)
Computes matrix multiplication C = AB.
void LU(const Tensor &A, Tensor &permutation, Tensor &lower, Tensor &upper, const bool permute_l)
void pybind_core_linalg(py::module &m)
double Det(const Tensor &A)
Generic file read and write utility for python interface.