From fcdc853a936b84539a1742337ba70480f9017492 Mon Sep 17 00:00:00 2001 From: Brendan Barnes Date: Mon, 15 Jul 2024 02:09:09 +0000 Subject: [PATCH] save --- README.md | 88 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 74c8739..7d98b44 100644 --- a/README.md +++ b/README.md @@ -615,47 +615,77 @@ quantity atanh(const quantity& q); The SQUINT library provides various linear algebra operations for tensors: -```cpp -// Element-wise operations -template -auto operator+(const fixed_tensor& lhs, const fixed_tensor& rhs); - -template -auto operator-(const fixed_tensor& lhs, const fixed_tensor& rhs); - -template -auto operator*(const fixed_tensor& lhs, const fixed_tensor& rhs); -// Matrix multiplication -template -auto matmul(const fixed_tensor& lhs, const fixed_tensor& rhs); +Element-wise operations: -// Transposition -template -auto transpose(const fixed_tensor& tensor); +```cpp +// Addition +template +auto operator+(const A &a, const B &b); + +// Subtraction +template +auto operator-(const A &a, const B &b); + +// Scalar multiplication +template +auto operator*(const A &a, const Scalar &s); +template +auto operator*(const Scalar &s, const A &a); + +// Scalar division +template +auto operator/(const A &a, const Scalar &s); +``` -// Matrix inversion -template -auto inv(const fixed_tensor& matrix); +Matrix operations -// Pseudo-inverse -template -auto pinv(const fixed_tensor& matrix); +```cpp +// Matrix multiplication +template +auto operator*(const A &a, const B &b); // Solve linear system -template -auto solve(const fixed_tensor& A, const fixed_tensor& b); +template +auto solve(A &a, B &b); // Solve linear least squares -template -auto solve_lls(const fixed_tensor& A, const fixed_tensor& b); +template +auto solve_lls(A& a, B& b); // Cross product (for 3D vectors) -template -auto cross(const fixed_tensor& lhs, const fixed_tensor& rhs); +template +auto cross(const A& lhs, const B& rhs); +``` + +Class Methods: + +```cpp +// Transposition (returning a tensor view) +auto transpose(); +// Matrix inversion (returning a new tensor) +auto inv(); +// Pseudo-inverse (returning a new tensor) +auto pinv(); + +auto squared_norm(); +auto trace(); +auto mean(); +auto sum(); +auto min(); +auto max(); + +template +auto &operator+=(const Other &other); +template +auto &operator-=(const Other &other); +template +auto &operator*=(const Scalar &s); +template +auto &operator/=(const Scalar &s); ``` -These operations are also available for `dynamic_tensor` with appropriate interfaces. +These operations are also available for `dynamic_tensor` with appropriate interfaces and also work with tensor views. ## Building and Testing