CNum 0.2.1
CPU-optimized ML library for C++
Loading...
Searching...
No Matches
IndexMask.h
Go to the documentation of this file.
1#ifndef INDEX_MASK_H
2#define INDEX_MASK_H
4#include <stdexcept>
5#include <memory>
6#include <numeric>
7#include <algorithm>
8
9namespace CNum::DataStructs {
10 template <typename T> class Matrix;
11
13
15 *
16 * The index mask at its core is a list of indeces that can be used to reorder and get subsets of
17 * datasets.
18 */
19 class IndexMask {
20 private:
21 ::std::unique_ptr<size_t[]> _mask;
22 size_t _size;
23
25 void copy(const IndexMask &other) noexcept;
27 void move(IndexMask &&other) noexcept;
28
29 public:
30 IndexMask() = delete;
32 IndexMask(::std::unique_ptr<size_t[]> mask, size_t size);
33
35 IndexMask(const IndexMask &other) noexcept;
37 IndexMask &operator=(const IndexMask &other) noexcept;
38
40 IndexMask(IndexMask &&other) noexcept;
42 IndexMask &operator=(IndexMask &&other) noexcept;
43
50 template <typename T>
51 ::CNum::DataStructs::Matrix<T> matrix_apply_mask(const ::CNum::DataStructs::Matrix<T> &m) const;
52
59 template <typename T>
60 ::CNum::DataStructs::Matrix<T> matrix_apply_mask_col_wise(const ::CNum::DataStructs::Matrix<T> &m) const;
61
66 template <typename Container, typename T, typename CompareFunction = ::std::greater<T>>
67 static IndexMask argsort(const Container &container);
68 };
69
70#include "CNum/DataStructs/Matrix/IndexMask.tpp"
71};
72
73#endif
IndexMask(IndexMask &&other) noexcept
Move constructor.
::CNum::DataStructs::Matrix< T > matrix_apply_mask(const ::CNum::DataStructs::Matrix< T > &m) const
Apply an index mask to a Matrix.
IndexMask & operator=(const IndexMask &other) noexcept
Copy equals operator.
::CNum::DataStructs::Matrix< T > matrix_apply_mask_col_wise(const ::CNum::DataStructs::Matrix< T > &m) const
Apply an index mask to a Matrix column wise.
static IndexMask argsort(const Container &container)
Create an index mask.
Definition IndexMask.h:3
IndexMask & operator=(IndexMask &&other) noexcept
Move equals operator.
IndexMask(::std::unique_ptr< size_t[]> mask, size_t size)
Constructor.
IndexMask(const IndexMask &other) noexcept
Copy constructor.
2d array abstraction
Definition Matrix.h:43
The data structures used in CNum.
Definition ConcurrentQueue.h:8