45 ::std::unique_ptr<T[]> _data;
53 Matrix<T> element_wise(T val, ::std::function<
void(T &, T) > func)
const noexcept;
59 void copy(
const Matrix<T> &other)
noexcept;
66 static void par_execute(uint8_t num_threads,
68 ::std::function<
void(
size_t) > callback);
75 Matrix(
size_t rows = 0,
size_t cols = 0, ::std::unique_ptr<T[]> ptr =
nullptr);
154 T
get(
size_t row,
size_t col)
const;
A bit mask used for representing subsets of elements in a container.
Definition BinaryMask.h:22
A list of indecies representing a subset or ordering of data.
Definition IndexMask.h:19
static Matrix< double > init_const(size_t rows, size_t cols, double val)
T sum() const
Get the sum of all elements in a matrix.
Definition Matrix.h:229
Matrix< T > operator-(T a) const noexcept
Subtract a value to every element in a matrix.
Definition Matrix.h:204
Matrix< T > squared() const
Square all elements in a matrix.
Definition Matrix.h:261
BinaryMask operator<=(T val) const
Create a binary mask of values less than or equal to another.
Definition Matrix.h:301
Matrix< T > operator[](const BinaryMask &bin_mask) const
Apply a binary mask.
Definition Matrix.h:404
const double * begin() const
Definition Matrix.h:494
Matrix< T > operator-(const Matrix &other) const
Subtract two matrices element wise.
Definition Matrix.h:188
Matrix(Matrix &&other) noexcept
Move Constructor.
Definition Matrix.h:55
Matrix< T > & operator=(Matrix &&other) noexcept
Move Assignment.
Definition Matrix.h:60
T get(size_t row, size_t col) const
Get value of a matrix.
Definition Matrix.h:342
Matrix< T > abs() const
Take the absolute value of all elements in a matrix.
Definition Matrix.h:224
::std::span< T > get_row_view(size_t idx) const
Get a row view.
Definition Matrix.h:395
IndexMask argsort(bool descending=false) const
Argsort.
Definition Matrix.h:414
const double * end() const
Definition Matrix.h:497
static Matrix< double > identity(size_t dim)
BinaryMask operator==(T val) const
Create a binary mask of values equal to another.
Definition Matrix.h:316
size_t get_rows() const
Definition Matrix.h:482
Matrix< T > operator*(const Matrix &other) const
Dot Product.
Definition Matrix.h:86
static Matrix< double > combine_vertically(::std::vector< Matrix< double > > &matrices, size_t total_rows)
T operator[](size_t idx) const
Get the value at index idx of a Matrix with shape=(n,1).
Definition Matrix.h:331
Matrix< T > operator[](const IndexMask &idx_mask) const noexcept
Apply index mask.
Definition Matrix.h:409
T std() const
Get the standard deviation of all elements in a matrix.
Definition Matrix.h:244
Matrix< T > transpose() const noexcept
Transpose a matrix.
Definition Matrix.h:426
Matrix< T > get(Dim d, size_t idx) const
Get a copy of a Row/Col (prefer views for memory effeciency).
Definition Matrix.h:352
T dot(const Matrix< T > &other) const
Vector dot product (1d).
Definition Matrix.h:117
Matrix(const Matrix &other) noexcept
Copy Constructor.
Definition Matrix.h:29
BinaryMask operator>(T val) const
Create a binary mask of values greater than another.
Definition Matrix.h:306
Matrix< T > col_wise_mask_application(const IndexMask &idx_mask) const noexcept
Apply IndexMask column wise.
Definition Matrix.h:326
BinaryMask operator!=(T val) const
Create a binary mask of values not equal to another.
Definition Matrix.h:321
Matrix< T > standardize() const
Standardize Matrix.
Definition Matrix.h:268
BinaryMask operator<(T val) const
Create a binary mask of values less than another.
Definition Matrix.h:296
size_t size() const
Definition Matrix.h:500
Matrix< T > operator+(T a) const noexcept
Add a value to every element in a matrix.
Definition Matrix.h:181
~Matrix()
Destructor.
Definition Matrix.h:66
Matrix(size_t rows=0, size_t cols=0, ::std::unique_ptr< T[]> ptr=nullptr)
Default Overloaded Constructor.
Definition Matrix.h:7
Matrix< T > operator*(T scale_factor) const noexcept
Scale a matrix.
Definition Matrix.h:110
Matrix< T > operator+(const Matrix &other) const
Add two matrices element wise.
Definition Matrix.h:165
size_t get_cols() const
Definition Matrix.h:485
void print_matrix() const
Definition Matrix.h:508
CNum::DataStructs::Views::StrideView< T > get_col_view(size_t idx) const
Get a column view.
Definition Matrix.h:386
::std::unique_ptr< double[]> && move_ptr()
Definition Matrix.h:503
BinaryMask operator>=(T val) const
Create a binary mask of values greater than or equal to another.
Definition Matrix.h:311
static Matrix< double > join_cols(::std::vector< Matrix< double > > &cols)
Matrix< T > & operator=(const Matrix &other) noexcept
Copy Logic.
Definition Matrix.h:34
T mean() const
Get the mean of all values in a matrix.
Definition Matrix.h:235
Definition StrideView.h:32
The data structures used in CNum.
Definition ConcurrentQueue.h:8
Dim
Definition Matrix.h:26
@ COL
Definition Matrix.h:28
@ ROW
Definition Matrix.h:27