MachineIntelligenceCore:Algorithms
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mic::types::Matrix< T > Class Template Reference

Template-typed Matrix of dynamic size. Uses OpenBLAS if found by CMAKE - overloaded, specializations of * operator for types: float, double. More...

#include <Matrix.hpp>

Inheritance diagram for mic::types::Matrix< T >:
Collaboration diagram for mic::types::Matrix< T >:

Public Member Functions

EIGEN_STRONG_INLINE Matrix ()
 
EIGEN_STRONG_INLINE Matrix (int Rows_, int Cols_)
 
EIGEN_STRONG_INLINE Matrix (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &vector_)
 
EIGEN_STRONG_INLINE Matrix (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &matrix_)
 
EIGEN_STRONG_INLINE Matrix (mic::types::Tensor< T > &tensor_)
 
EIGEN_STRONG_INLINE
Eigen::Matrix< T,
Eigen::Dynamic, Eigen::Dynamic > & 
operator= (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat_)
 
EIGEN_STRONG_INLINE
Eigen::Matrix< T,
Eigen::Dynamic, Eigen::Dynamic > 
operator* (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat_)
 
void setValue (T value_)
 
void enumerate ()
 
void randn (T mean=0, T stddev=1)
 
void rand (T min=0, T max=1)
 
void elementwiseFunction (T(*func)(T))
 
void elementwiseFunctionScalar (T(*func)(T, T), T scalar_)
 
void elementwiseFunctionMatrix (T(*func)(T, T), Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat_)
 
void matrixColumnVectorFunction (T(*func)(T, T), Eigen::Matrix< T, Eigen::Dynamic, 1 > &v_)
 
void matrixRowVectorFunction (T(*func)(T, T), Eigen::Matrix< T, Eigen::Dynamic, 1 > &v_)
 
void repeatVector (Eigen::Matrix< T, Eigen::Dynamic, 1 > &in)
 
Eigen::Matrix< T,
Eigen::Dynamic, 1 > 
colwiseReturnMaxIndices ()
 
calculateCrossEntropy (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &targets_)
 
void zeros ()
 
T & operator[] (int idx)
 
operator[] (int idx) const
 
template<>
Eigen::MatrixXd operator* (const Eigen::MatrixXd &mat_)
 
template<>
Eigen::MatrixXf operator* (const Eigen::MatrixXf &mat_)
 

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
 

Detailed Description

template<typename T>
class mic::types::Matrix< T >

Template-typed Matrix of dynamic size. Uses OpenBLAS if found by CMAKE - overloaded, specializations of * operator for types: float, double.

Template Parameters
TTemplate parameter denoting elementary type of data used (int, float, double etc.)
Date
Mar 7, 2016
Author
tkornuta

Definition at line 64 of file Matrix.hpp.

Constructor & Destructor Documentation

template<typename T>
EIGEN_STRONG_INLINE mic::types::Matrix< T >::Matrix ( )
inline

Constructor. Calls default Eigen::MatrixXf constructor.

Definition at line 71 of file Matrix.hpp.

template<typename T>
EIGEN_STRONG_INLINE mic::types::Matrix< T >::Matrix ( int  Rows_,
int  Cols_ 
)
inline

Constructor. Calls default Eigen::MatrixXf constructor.

Parameters
Rows_Number of rows.
Cols_Number of columns.

Definition at line 81 of file Matrix.hpp.

template<typename T>
EIGEN_STRONG_INLINE mic::types::Matrix< T >::Matrix ( const Eigen::Matrix< T, Eigen::Dynamic, 1 > &  vector_)
inline

Copying constructor on the basis of a vector. Sets dimensions to rows = size(), cols = 1.

Parameters
vector_Vector

Definition at line 91 of file Matrix.hpp.

template<typename T>
EIGEN_STRONG_INLINE mic::types::Matrix< T >::Matrix ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  matrix_)
inline

Copying constructor on the basis of another matrix.

Parameters
matrix_Matrix to be copied.

Definition at line 103 of file Matrix.hpp.

template<typename T>
EIGEN_STRONG_INLINE mic::types::Matrix< T >::Matrix ( mic::types::Tensor< T > &  tensor_)
inline

Copying constructor on the basis of a tensor. Copies dimensions and data. Note: tensor must be 2D.

Parameters
tensor_Tensor

Definition at line 116 of file Matrix.hpp.

References mic::types::Tensor< T >::data(), mic::types::Tensor< T >::dims(), and mic::types::Tensor< T >::size().

Here is the call graph for this function:

Member Function Documentation

template<typename T>
T mic::types::Matrix< T >::calculateCrossEntropy ( Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  targets_)
inline

Calculates the cross entropy as measure of how accurate given matrix (treated as prediction) fits to the desired (target) matrix.

Parameters
targets_Desired results (targets) in the form of a matrix of answers.
Returns

Definition at line 396 of file Matrix.hpp.

template<typename T>
Eigen::Matrix<T, Eigen::Dynamic, 1> mic::types::Matrix< T >::colwiseReturnMaxIndices ( )
inline

Returns a vector of indices indicating maximal elements in consecutive matrix columns (colwise).

Returns
Vector of indices.

Definition at line 366 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::elementwiseFunction ( T(*)(T)  func)
inline

Applies elementwise function to all matrix elements.

Parameters
funcFunction to be applied.

Definition at line 242 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::elementwiseFunctionMatrix ( T(*)(T, T)  func,
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  mat_ 
)
inline

Applies elementwise function to all matrix elements and uses additional Matrix mat_ data as function parameter.

Parameters
funcFunction to be applied.
mat_Matrix passed to function as argument.

Definition at line 276 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::elementwiseFunctionScalar ( T(*)(T, T)  func,
scalar_ 
)
inline

Applies elementwise function to all matrix elements passing scalar as function argument.

Parameters
funcFunction to be applied.
scalar_Scalar passed to function as argument.

Definition at line 259 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::enumerate ( )
inline

Enumerates - sets values of elements to their indices.

Definition at line 185 of file Matrix.hpp.

Referenced by TEST().

template<typename T>
template<class Archive >
void mic::types::Matrix< T >::load ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

Serialization load - loads the matrix object to archive.

Parameters
arUsed archive.
versionVersion of the matrix class.

Definition at line 456 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::matrixColumnVectorFunction ( T(*)(T, T)  func,
Eigen::Matrix< T, Eigen::Dynamic, 1 > &  v_ 
)
inline

Applies function to all matrix elements and uses additional vector data as function parameter - columnwise.

Parameters
funcUsed function
v_Vector passed to function

Definition at line 299 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::matrixRowVectorFunction ( T(*)(T, T)  func,
Eigen::Matrix< T, Eigen::Dynamic, 1 > &  v_ 
)
inline

Applies function to all matrix elements and uses additional vector data as function parameter - rowwise.

Parameters
funcUsed function
v_Vector passed to function

Definition at line 325 of file Matrix.hpp.

template<>
Eigen::MatrixXd mic::types::Matrix< double >::operator* ( const Eigen::MatrixXd &  mat_)
inline
Author
tkornuta

Definition at line 40 of file MatrixXdSpecializations.hpp.

template<>
Eigen::MatrixXf mic::types::Matrix< float >::operator* ( const Eigen::MatrixXf &  mat_)
inline
Author
tkornuta

Definition at line 43 of file MatrixXfSpecializations.hpp.

template<typename T>
EIGEN_STRONG_INLINE Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> mic::types::Matrix< T >::operator* ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  mat_)
inline

Overloaded multiplication operator.

Parameters
mat_Input matrix
Returns
Resulting matrix - multiplication of this and input mat_.

Definition at line 162 of file Matrix.hpp.

template<typename T>
EIGEN_STRONG_INLINE Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& mic::types::Matrix< T >::operator= ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &  mat_)
inline

Overloaded assignment operator - calls base operator.

Parameters
mat_Input matrix
Returns
An exact copy of the input matrix.

Definition at line 149 of file Matrix.hpp.

template<typename T>
T& mic::types::Matrix< T >::operator[] ( int  idx)
inline

Definition at line 419 of file Matrix.hpp.

template<typename T>
T mic::types::Matrix< T >::operator[] ( int  idx) const
inline

Definition at line 423 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::rand ( min = 0,
max = 1 
)
inline

Set values of all matrix elements to random numbers from range <min, max> - uniform distribution.

Parameters
minMin value.
maxMax value.
Returns
Random real value.

Definition at line 221 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::randn ( mean = 0,
stddev = 1 
)
inline

Set values of all matrix elements to random with a normal distribution.

Parameters
meanMean
stddevVariance

Definition at line 199 of file Matrix.hpp.

Referenced by TEST().

template<typename T>
void mic::types::Matrix< T >::repeatVector ( Eigen::Matrix< T, Eigen::Dynamic, 1 > &  in)
inline

Sets the consecutive columns to be equal to given vector.

Parameters
inInput vector, that will be "cloned".

Definition at line 352 of file Matrix.hpp.

template<typename T>
template<class Archive >
void mic::types::Matrix< T >::save ( Archive &  ar,
const unsigned int  version 
) const
inlineprivate

Serialization save - saves the matrix object to archive.

Parameters
arUsed archive.
versionVersion of the matrix class.

Definition at line 438 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::setValue ( value_)
inline

Sets values of all element to the value given as parameter.

Parameters
value_The value to be set.

Definition at line 173 of file Matrix.hpp.

template<typename T>
void mic::types::Matrix< T >::zeros ( )
inline

Set zeros.

Definition at line 415 of file Matrix.hpp.

Referenced by TEST().

Friends And Related Function Documentation

template<typename T>
friend class boost::serialization::access
friend

Definition at line 430 of file Matrix.hpp.


The documentation for this class was generated from the following file: