Introduction
Tatooine provides basic linear algebra data structures and operations.
There are template classes tatooine::vec
and tatooine::mat
that are derived of tatooine::tensor
. The latter represents a generically sized Tensor.
These types are mostly usable in a constexpr context. If you instantiate tatooine::tensor
with no dimensions you will get a dynamically resizable tensor.
Examples
Construction
#include <tatoine/vec.h>
#include <tatoine/mat.h>
auto vector_construction() {
auto const v_int_4 =
vec{1, 2, 3, 4};
auto const v_double_2 =
vec{1.0, 2}
auto const v_double_3 =
vec3d{1, 2}
}
Definition: algorithm.h:6
auto vector_factories() {
auto const v0 = vec2::ones();
auto const v1 = vec4::zeros();
}
auto matrix_construction() {
auto const m_int_2_2 =
mat{{1,2},
{3,4}};
auto const m_double_2_3 =
mat{{1.0, 2.0, 3.0},
{ 1, 2, 3}};
auto const m_double_3_3 =
mat3{{1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
}
auto matrix_factories() {
auto const m0 = mat2::ones();
auto const m1 = mat4::zeros();
auto const m1 = mat3::eye();
}
Operations
#include <tatoine/vec.h>
#include <tatoine/mat.h>
auto vector_basic_usage() {
auto const v =
vec2{1,2};
auto const w =
vec2{2,3};
auto const vw_added = v + w;
auto const vw_subtracted = v - w;
auto const vw_component_wise_multiplication = v * w;
}
auto matrix_vector_multiplication() {
auto const A =
mat2{{1,2},
{3,4}};
auto const x =
vec2{1,2};
auto const b = A * x;
}
auto matrix_matrix_multiplication() {
auto const A =
mat2{{1,2},
{3,4}};
auto const X = mat2::eye();
auto const B = A * X;
}
auto transposing_a_matrix() {
auto const A =
mat2{{1,2},
{3,4}};
}
auto transposed(dynamic_tensor auto &&t)
Definition: transposed_tensor.h:170
auto inverting_a_matrix() {
auto const A =
mat2{{1,2},
{3,4}};
auto const Ainv =
inv(A);
}
constexpr auto inv(diag_static_tensor< Tensor, N, N > const &A) -> std::optional< diag_static_tensor< vec< tatooine::value_type< Tensor >, N >, N, N > >
Definition: diag_tensor.h:109
auto solving_a_linear_system() {
auto const A =
mat2{{1,2},
{3,4}};
auto const b =
vec2{5,6};
auto const x = *
solve(A, b);
}
auto solving_a_linear_system() {
auto const A =
mat2{{1,2},
{3,4}};
auto const B =
mat2{{5,6},
{7,8}};
auto const X = *
solve(A, B);
}
auto solve(polynomial< Real, 1 > const &p) -> std::vector< Real >
solve a + b*x
Definition: polynomial.h:187
auto solving_a_linear_system() {
auto const A =
mat2{{1,2},
{3,4}};
auto const b =
vec2{5,6};
auto const x = *
solve(A, b);
}
auto compute_eigenvalues() {
auto const A =
mat2{{1,2},
{3,4}};
}
constexpr auto eigenvalues(Mat &&A)
Definition: eigenvalues.h:85
constexpr auto eigenvalues_sym(Mat &&A)
Definition: eigenvalues.h:55
auto compute_eigenvectors() {
auto const A =
mat2{{1,2},
{3,4}};
}
auto eigenvectors_sym(Mat &&A)
Definition: eigenvalues.h:44
auto eigenvectors(Mat &&B)
Definition: eigenvalues.h:123
Typedefs
Vectors
For tatooine::vec
with tatooine::real_type
:
templated size tatooine::Vec
,
tatooine::vec2
, tatooine::vec3
, ..., tatooine::vec9
For tatooine::vec
with explicit float
:
templated size tatooine::VecF
,
tatooine::vec2f
, tatooine::vec3f
, ..., tatooine::vec9f
For tatooine::vec
with explicit double
:
templated size tatooine::VecD
,
tatooine::vec2d
, tatooine::vec3d
, ..., tatooine::vec9d
Matrices
For tatooine::mat
with tatooine::real_type
:
tatooine::mat2
, tatooine::mat3
, ..., tatooine::mat9
,
tatooine::mat23
, tatooine::mat24
, ..., tatooine::mat99
For tatooine::mat
with explicit float
:
tatooine::mat2f
, tatooine::mat3f
, ..., tatooine::mat9f
,
tatooine::mat23f
, tatooine::mat24f
, ..., tatooine::mat99f
For tatooine::mat
with explicit double
:
tatooine::mat2d
, tatooine::mat3d
, ..., tatooine::mat9d
,
tatooine::mat22d
, tatooine::mat24d
, ..., tatooine::mat99d