lineas/prelude.rs
1//! All the important bases
2//!
3//! This defined the matrix and vector as well as some simple operation implementations for
4//! matrices. More complex operations are defined in other places
5use std::fmt::Debug;
6
7/// Matrix struct
8///
9/// A `Matrix<T, N, L>` contains an `[[L; N]; T]` array where `N` is the number of rows and `T` is
10/// the number of columns giving a `T`×`N` matrix
11///
12/// To make a new matrix, do [`Matrix::new(data)`][Matrix::new]. You can also specify the type of the data by
13/// following this with a call to the [`dtype`][Matrix::dtype] function.
14///
15/// For example
16/// ```
17/// use lineas::Matrix;
18/// let matrix: Matrix<2, 2, f64> = Matrix::new([[1, 0], [0, 1]]).dtype::<f64>();
19/// ```
20/// This gives us an identity matrix of size 2 with each value being an `f64` instead of `{integer}`
21#[derive(Copy, Clone, Debug, PartialEq)]
22pub struct Matrix<const T: usize, const N: usize, L: Copy + Debug> (pub(crate) [[L; N]; T] );
23
24/// Vector struct
25///
26/// Derived from the [matrix][Matrix] and is technically a 1×`T` matrix
27pub type Vector<const T: usize, L> = Matrix<1, T, L>;
28
29/// Complex number struct
30///
31/// This contains two values, a real and an imaginary. It does complex number things as you would
32/// expect.
33///
34/// To generate a new
35#[derive(Copy, Clone, Debug, PartialEq)]
36pub struct Complex<L: Copy + Debug> {
37 pub(crate) real: L,
38 pub(crate) imaginary: L
39}