MachineIntelligenceCore:Algorithms
|
A dynamic array of matrices. It's just what it looks like - std::vector<Matrix>; elements are are accessible by name with operator [] name needs to be given together with name in the main constructor. More...
#include <MatrixArray.hpp>
Public Member Functions | |
MatrixArray ()=default | |
MatrixArray (std::string name_) | |
MatrixArray (std::string name_, std::initializer_list< std::tuple< std::string, size_t, size_t > > args_) | |
MatrixArray (const MatrixArray &other) | |
MatrixArray & | operator= (const MatrixArray &other) |
void | add (std::initializer_list< std::tuple< std::string, size_t, size_t > > params_) |
void | add (std::tuple< std::string, size_t, size_t > param_) |
void | add (std::string name_, size_t input_, size_t output_) |
void | add (std::string name_, std::shared_ptr< mic::types::Matrix< T > > matrix_ptr_) |
mic::types::MatrixPtr< T > & | operator[] (size_t number_) |
bool | keyExists (char key_) |
bool | keyExists (std::string key_) |
mic::types::MatrixPtr< T > & | operator[] (char key_) |
mic::types::MatrixPtr< T > & | operator[] (std::string key_) |
void | setZero () |
std::string | name () |
std::map< std::string, size_t > | keys () |
size_t | size () |
Protected Attributes | |
std::string | array_name |
Name of the given vector of matrices. More... | |
std::vector < mic::types::MatrixPtr< T > > | matrices |
Vector of matrices. More... | |
std::map< std::string, size_t > | keys_map |
Vector of names of consecutive matrices in the array. More... | |
Private Member Functions | |
template<class Archive > | |
void | save (Archive &ar, const unsigned int version) const |
template<class Archive > | |
void | load (Archive &ar, const unsigned int version) |
Friends | |
class | boost::serialization::access |
std::ostream & | operator<< (std::ostream &os_, const MatrixArray &obj_) |
A dynamic array of matrices. It's just what it looks like - std::vector<Matrix>; elements are are accessible by name with operator [] name needs to be given together with name in the main constructor.
An example:
m = MatrixArray(
{ "something" }, {
std::make_tuple("W", M, N), std::make_tuple("U", X, Y),
} )
will make a 2 sub-matrices "W" and "U" of dimensions M x N and X x Y respectively;
later, m['W'] will return the first matrix and m['U'] the second one.
Other things are just implementations of operators and IO.
T | Template parameter denoting elementary type of data used (int, float, double etc.) |
Definition at line 73 of file MatrixArray.hpp.
|
default |
Default empty constructor.
|
inline |
Simple constructor. Stores the name.
name_ | Name of the array. |
Definition at line 85 of file MatrixArray.hpp.
|
inline |
The main constructor. Adds parameters.
name_ | Name of the array. |
args_ | Vector of tuples containing <id, width, height>. |
Definition at line 94 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::add().
|
inline |
Definition at line 100 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
|
inline |
Adds several matrices at once.
params_ | Vector of tuples containing <id, width, height>. |
Definition at line 141 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
Referenced by mic::types::MatrixArray< T >::MatrixArray(), and TEST().
|
inline |
Adds a single matrix to array.
param_ | A tuple to be added. |
Definition at line 152 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
|
inline |
Adds a single matrix to array.
name_ | Name of the matrix. |
input_ | Input length. |
output_ | Output length. |
Definition at line 163 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
|
inline |
Adds a pointer to an existing matrix to array.
name_ | Name of the matrix. |
matrix_ptr_ | Pointer to the existing array. |
Definition at line 173 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
|
inline |
Checks whether matrix indexed by a given key exists.
key_ | Key as a single character. |
Definition at line 194 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map.
Referenced by mic::types::MatrixArray< T >::operator[]().
|
inline |
Checks whether matrix indexed by a given key exists.
key_ | Key as string. |
Definition at line 202 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map.
|
inline |
Returns the name of the vector of matrices.
Definition at line 266 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::keys_map.
|
inlineprivate |
Serialization load - loads the matrix object to archive.
ar | Used archive. |
version | Version of the matrix class (not used currently). |
Definition at line 316 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, mic::types::MatrixArray< T >::keys_map, mic::types::MatrixArray< T >::matrices, and mic::types::MatrixArray< T >::size().
|
inline |
Returns the name of the vector of matrices.
Definition at line 259 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name.
|
inline |
Definition at line 118 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
|
inline |
Returns the matrix with given number.
number_ | Number of the matrix. |
Definition at line 183 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, and mic::types::MatrixArray< T >::matrices.
|
inline |
Returns the matrix with given key (id).
number_ | Matrix key. |
Definition at line 212 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, and mic::types::MatrixArray< T >::keyExists().
|
inline |
Returns the matrix with given key (id).
number_ | Matrix key. |
Definition at line 224 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, mic::types::MatrixArray< T >::keyExists(), mic::types::MatrixArray< T >::keys_map, and mic::types::MatrixArray< T >::matrices.
|
inlineprivate |
Serialization save - saves the matrix object to archive.
ar | Used archive. |
version | Version of the matrix class (not used currently). |
Definition at line 298 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::array_name, mic::types::MatrixArray< T >::keys_map, mic::types::MatrixArray< T >::matrices, and mic::types::MatrixArray< T >::size().
|
inline |
Zeroes all matrices.
Definition at line 250 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::matrices.
|
inline |
Returns the size of vector.
Definition at line 273 of file MatrixArray.hpp.
References mic::types::MatrixArray< T >::matrices.
Referenced by mic::types::MatrixArray< T >::load(), and mic::types::MatrixArray< T >::save().
|
friend |
Definition at line 290 of file MatrixArray.hpp.
|
friend |
Stream operator enabling to print the array.
os_ | Ostream object. |
obj_ | Array object. |
Definition at line 236 of file MatrixArray.hpp.
|
protected |
Name of the given vector of matrices.
Definition at line 279 of file MatrixArray.hpp.
Referenced by mic::types::MatrixArray< T >::load(), mic::types::MatrixArray< T >::MatrixArray(), mic::types::MatrixArray< T >::name(), mic::types::MatrixArray< T >::operator=(), mic::types::MatrixArray< T >::operator[](), and mic::types::MatrixArray< T >::save().
|
protected |
Vector of names of consecutive matrices in the array.
Definition at line 286 of file MatrixArray.hpp.
Referenced by mic::types::MatrixArray< T >::add(), mic::types::MatrixArray< T >::keyExists(), mic::types::MatrixArray< T >::keys(), mic::types::MatrixArray< T >::load(), mic::types::MatrixArray< T >::MatrixArray(), mic::types::MatrixArray< T >::operator=(), mic::types::MatrixArray< T >::operator[](), and mic::types::MatrixArray< T >::save().
|
protected |
Vector of matrices.
Definition at line 282 of file MatrixArray.hpp.
Referenced by mic::types::MatrixArray< T >::add(), mic::types::MatrixArray< T >::load(), mic::types::MatrixArray< T >::MatrixArray(), mic::types::MatrixArray< T >::operator=(), mic::types::MatrixArray< T >::operator[](), mic::types::MatrixArray< T >::save(), mic::types::MatrixArray< T >::setZero(), and mic::types::MatrixArray< T >::size().