OpenNN::Matrix< Type > Class Template Reference

#include <matrix.h>

List of all members.

Public Member Functions

 Matrix (void)
 Matrix (const unsigned int &new_rows_number, const unsigned int &new_columns_number)
 Matrix (const unsigned int &new_rows_number, const unsigned int &new_columns_number, const Type &type)
 Matrix (const std::string &filename)
 Matrix (const Matrix &other_matrix)
 ~Matrix (void)
Matrix< Type > & operator= (const Matrix< Type > &other_matrix)
Type * operator[] (const unsigned int &i)
const Type * operator[] (const unsigned int &i) const
bool operator== (const Matrix< Type > &other_matrix) const
bool operator== (const Type &value) const
bool operator!= (const Matrix< Type > &other_matrix) const
bool operator!= (const Type &value) const
bool operator> (const Matrix< Type > &other_matrix) const
bool operator> (const Type &value) const
bool operator< (const Matrix< Type > &other_matrix) const
bool operator< (const Type &value) const
bool operator>= (const Matrix< Type > &other_matrix) const
bool operator>= (const Type &value) const
bool operator<= (const Matrix< Type > &other_matrix) const
bool operator<= (const Type &value) const
const unsigned int & get_rows_number (void) const
const unsigned int & get_columns_number (void) const
void set (void)
void set (const unsigned int &new_rows_number, const unsigned int &new_columns_number)
void set (const unsigned int &new_rows_number, const unsigned int &new_columns_number, const Type &value)
void set (const Matrix &other_matrix)
void set (const std::string &filename)
void set_identity (const unsigned int &new_size)
void set_rows_number (const unsigned int &new_rows_number)
void set_columns_number (const unsigned int &new_columns_number)
void resize (const unsigned int &new_rows_number, const unsigned int &new_columns_number)
void tuck_in (const unsigned int &row_position, const unsigned int &column_position, const Matrix< Type > &other_matrix)
Matrix< Type > arrange_submatrix (const Vector< unsigned int > &row_indices, const Vector< unsigned int > &column_indices) const
Matrix< Type > arrange_submatrix_rows (const Vector< unsigned int > &row_indices) const
Matrix< Type > arrange_submatrix_columns (const Vector< unsigned int > &column_indices) const
Vector< Type > arrange_row (const unsigned int &i) const
Vector< Type > arrange_row (const unsigned int &row_index, const Vector< unsigned int > &column_indices) const
Vector< Type > arrange_column (const unsigned int &j) const
Vector< Type > arrange_column (const unsigned int &column_index, const Vector< unsigned int > &row_indices) const
Vector< Type > get_diagonal (void) const
void set_row (const unsigned int &row_index, const Vector< Type > &new_row)
void set_row (const unsigned int &row_index, const Type &value)
void set_column (const unsigned int &column_index, const Vector< Type > &new_column)
void set_column (const unsigned int &column_index, const Type &value)
void set_diagonal (const Type &new_diagonal)
void set_diagonal (const Vector< Type > &new_diagonal)
void initialize_diagonal (const unsigned int &new_size, const Type &new_value)
void initialize_diagonal (const unsigned int &new_size, const Vector< Type > &new_values)
Matrix< Type > sum_diagonal (const Type &new_summing_value) const
Matrix< Type > sum_diagonal (const Vector< Type > &new_summing_values) const
void append_row (const Vector< Type > &new_row)
void append_column (const Vector< Type > &new_column)
void subtract_row (const unsigned int &row_index)
void subtract_column (const unsigned int &column_index)
Matrix< Type > get_assembly_columns (const Matrix< Type > &other_matrix) const
void initialize (const Type &value) const
void initialize_uniform (void) const
void initialize_uniform (const double &minimum, double maximum) const
void initialize_uniform (const Matrix< double > &minimum, const Matrix< double > &maximum) const
void initialize_normal (void) const
void initialize_normal (const double &mean, double standard_deviation) const
void initialize_normal (const Matrix< double > &mean, const Matrix< double > &standard_deviation) const
void initialize_identity (void) const
void initialize_diagonal (const Type &value) const
double calculate_trace (void) const
Vector< double > calculate_mean (void) const
Vector< double > calculate_mean (const Vector< unsigned int > &column_indices) const
Vector< double > calculate_mean (const Vector< unsigned int > &row_indices, const Vector< unsigned int > &column_indices) const
Vector< Vector< double > > calculate_mean_standard_deviation (void) const
Vector< Vector< double > > calculate_mean_standard_deviation (const Vector< unsigned int > &column_indices) const
Vector< Vector< double > > calculate_mean_standard_deviation (const Vector< unsigned int > &row_indices, const Vector< unsigned int > &column_indices) const
Vector< Vector< Type > > calculate_minimum_maximum (void) const
Vector< Vector< Type > > calculate_minimum_maximum (const Vector< unsigned int > &column_indices) const
Vector< Vector< Type > > calculate_minimum_maximum (const Vector< unsigned int > &row_indices, const Vector< unsigned int > &column_indices) const
Vector< Vector< double > > calculate_statistics (void) const
Vector< Vector< Vector< Type > > > calculate_histogram (const unsigned int &bins_number) const
Vector< Vector< Vector< Type > > > calculate_histogram (void) const
void scale_mean_standard_deviation (const Vector< double > &mean, const Vector< double > &standard_deviation) const
void scale_minimum_maximum (const Vector< double > &minimum, const Vector< double > &maximum) const
void unscale_mean_standard_deviation (const Vector< double > &mean, const Vector< double > &standard_deviation) const
void unscale_minimum_maximum (const Vector< double > &minimum, const Vector< double > &maximum) const
Vector< unsigned int > calculate_minimal_indices (void) const
Vector< unsigned int > calculate_maximal_indices (void) const
Vector< Vector< unsigned int > > calculate_minimal_maximal_indices (void) const
double calculate_sum_squared_error (const Matrix< double > &other_matrix) const
double calculate_sum_squared_error (const Vector< double > &vector) const
Vector< double > calculate_rows_norm (void) const
Matrix< Type > calculate_absolute_value (void) const
Matrix< Type > calculate_transpose (void) const
Type calculate_determinant (void) const
Matrix< Type > calculate_cofactor (void) const
Matrix< Type > calculate_inverse (void) const
Matrix< Type > operator+ (const Type &scalar) const
Matrix< Type > operator+ (const Vector< Type > &vector) const
Matrix< Type > operator+ (const Matrix< Type > &other_matrix) const
Matrix< Type > operator- (const Type &scalar) const
Matrix< Type > operator- (const Vector< Type > &vector) const
Matrix< Type > operator- (const Matrix< Type > &other_matrix) const
Matrix< Type > operator* (const Type &scalar) const
Matrix< Type > operator* (const Vector< Type > &vector) const
Matrix< Type > operator* (const Matrix< Type > &other_matrix) const
Matrix< Type > operator/ (const Type &scalar) const
Matrix< Type > operator/ (const Vector< Type > &vector) const
Matrix< Type > operator/ (const Matrix< Type > &other_matrix) const
void operator+= (const Type &value)
void operator+= (const Matrix< Type > &other_matrix)
void operator-= (const Type &value)
void operator-= (const Matrix< Type > &other_matrix)
void operator*= (const Type &value)
void operator*= (const Matrix< Type > &other_matrix)
void operator/= (const Type &value)
void operator/= (const Matrix< Type > &other_matrix)
Vector< Type > dot (const Vector< Type > &vector) const
Matrix< Type > dot (const Matrix< Type > &other_matrix) const
Matrix< Type > direct (const Matrix< Type > &other_matrix) const
bool empty (void) const
bool is_square (void) const
bool is_symmetric (void) const
bool is_antisymmetric (void) const
bool is_diagonal (void) const
bool is_scalar (void) const
bool is_identity (void) const
void print (void) const
void load (const std::string &filename)
void save (const std::string &filename) const
std::string to_string (void) const
Matrix< std::string > get_string_matrix (void) const
Vector< Type > to_vector (void) const


Detailed Description

template<class Type>
class OpenNN::Matrix< Type >

This template class defines a matrix for general purpose use. This matrix also implements some mathematical methods which can be useful.

Definition at line 41 of file matrix.h.


Constructor & Destructor Documentation

template<class Type>
OpenNN::Matrix< Type >::Matrix ( void   )  [inline, explicit]

Default constructor. It creates a matrix with zero rows and zero columns.

Definition at line 50 of file matrix.h.

template<class Type>
OpenNN::Matrix< Type >::Matrix ( const unsigned int &  new_rows_number,
const unsigned int &  new_columns_number 
) [inline, explicit]

Constructor. It creates a matrix with n rows and m columns, containing n*m copies of the default value for Type.

Parameters:
new_rows_number Number of rows in matrix.
new_columns_number Number of columns in matrix.

Definition at line 63 of file matrix.h.

template<class Type>
OpenNN::Matrix< Type >::Matrix ( const unsigned int &  new_rows_number,
const unsigned int &  new_columns_number,
const Type &  type 
) [inline, explicit]

Constructor. It creates a matrix with n rows and m columns, containing n*m copies of the type value of Type.

Parameters:
new_rows_number Number of rows in matrix.
new_columns_number Number of columns in matrix.
type Value of Type.

Definition at line 112 of file matrix.h.

template<class Type>
OpenNN::Matrix< Type >::Matrix ( const std::string &  filename  )  [inline, explicit]

File constructor. It creates a matrix which members are loaded froma a data file.

Parameters:
filename Name of matrix data file.

Definition at line 171 of file matrix.h.

template<class Type>
OpenNN::Matrix< Type >::Matrix ( const Matrix< Type > &  other_matrix  )  [inline]

Copy constructor. It creates a copy of an existing matrix.

Parameters:
other_matrix Matrix to be copied.

Definition at line 184 of file matrix.h.

template<class Type>
OpenNN::Matrix< Type >::~Matrix ( void   )  [inline]

Destructor.

Definition at line 245 of file matrix.h.


Member Function Documentation

template<class Type>
Matrix<Type>& OpenNN::Matrix< Type >::operator= ( const Matrix< Type > &  other_matrix  )  [inline]

Assignment operator. It assigns to self a copy of an existing matrix.

Parameters:
other_matrix Matrix to be assigned.

Definition at line 260 of file matrix.h.

template<class Type>
Type* OpenNN::Matrix< Type >::operator[] ( const unsigned int &  i  )  [inline]

Reference operator.

Definition at line 301 of file matrix.h.

template<class Type>
const Type* OpenNN::Matrix< Type >::operator[] ( const unsigned int &  i  )  const [inline]

Reference operator.

Definition at line 328 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator== ( const Matrix< Type > &  other_matrix  )  const [inline]

Equivalent relational operator between this matrix and other matrix. It produces true if all the elements of the two matrices are equal, and false otherwise.

Parameters:
other_matrix Matrix to be compared with.

Definition at line 359 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator== ( const Type &  value  )  const [inline]

Equivalent relational operator between this matrix and a Type value. It produces true if all the elements of this matrix are equal to the Type value, and false otherwise.

Parameters:
value Type value to be compared with.

Definition at line 412 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator!= ( const Matrix< Type > &  other_matrix  )  const [inline]

Not equivalent relational operator between this matrix and other matrix. It produces true if the two matrices have any not equal element, and false otherwise.

Parameters:
other_matrix Matrix to be compared with.

Definition at line 435 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator!= ( const Type &  value  )  const [inline]

Not equivalent relational operator between this matrix and a Type value. It produces true if some element of this matrix is not equal to the Type value, and false otherwise.

Parameters:
value Type value to be compared with.

Definition at line 488 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator> ( const Matrix< Type > &  other_matrix  )  const [inline]

Greater than relational operator between this matrix and other vector. It produces true if all the elements of this matrix are greater than the corresponding elements of the other matrix, and false otherwise.

Parameters:
other_matrix matrix to be compared with.

Definition at line 514 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator> ( const Type &  value  )  const [inline]

Greater than relational operator between this matrix and a Type value. It produces true if all the elements of this matrix are greater than the Type value, and false otherwise.

Parameters:
value Type value to be compared with.

Definition at line 567 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator< ( const Matrix< Type > &  other_matrix  )  const [inline]

Less than relational operator between this matrix and other matrix. It produces true if all the elements of this matrix are less than the corresponding elements of the other matrix, and false otherwise.

Parameters:
other_matrix Matrix to be compared with.

Definition at line 591 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator< ( const Type &  value  )  const [inline]

Less than relational operator between this matrix and a Type value. It produces true if all the elements of this matrix are less than the Type value, and false otherwise.

Parameters:
value Type value to be compared with.

Definition at line 644 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator>= ( const Matrix< Type > &  other_matrix  )  const [inline]

Greater than or equal to relational operator between this matrix and other matrix. It produces true if all the elements of this matrix are greater than or equal to the corresponding elements of the other matrix, and false otherwise.

Parameters:
other_matrix Matrix to be compared with.

Definition at line 668 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator>= ( const Type &  value  )  const [inline]

Greater than or equal to than relational operator between this matrix and a Type value. It produces true if all the elements of this matrix are greater than or equal to the Type value, and false otherwise.

Parameters:
value Type value to be compared with.

Definition at line 721 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator<= ( const Matrix< Type > &  other_matrix  )  const [inline]

Less than or equal to relational operator between this matrix and other matrix. It produces true if all the elements of this matrix are less than or equal to the corresponding elements of the other matrix, and false otherwise.

Parameters:
other_matrix Matrix to be compared with.

Definition at line 745 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::operator<= ( const Type &  value  )  const [inline]

Less than or equal to than relational operator between this matrix and a Type value. It produces true if all the elements of this matrix are less than or equal to the Type value, and false otherwise.

Parameters:
value Type value to be compared with.

Definition at line 798 of file matrix.h.

template<class Type>
const unsigned int& OpenNN::Matrix< Type >::get_rows_number ( void   )  const [inline]

This method returns the number of rows in the matrix.

Definition at line 821 of file matrix.h.

template<class Type>
const unsigned int& OpenNN::Matrix< Type >::get_columns_number ( void   )  const [inline]

This method returns the number of columns in the matrix.

Definition at line 831 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set ( void   )  [inline]

This method set the numbers of rows and columns of the matrix to zero.

Definition at line 841 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set ( const unsigned int &  new_rows_number,
const unsigned int &  new_columns_number 
) [inline]

This method set new numbers of rows and columns in the matrix.

Parameters:
new_rows_number Number of rows.
new_columns_number Number of columns.

Definition at line 861 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set ( const unsigned int &  new_rows_number,
const unsigned int &  new_columns_number,
const Type &  value 
) [inline]

This method set new numbers of rows and columns in the matrix. It also initializes all the matrix elements to a given value.

Parameters:
new_rows_number Number of rows.
new_columns_number Number of columns.
value Initialization value.

Definition at line 923 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set ( const Matrix< Type > &  other_matrix  )  [inline]

This method sets all the members of the matrix to those of another matrix.

Parameters:
other_matrix Setting matrix.

Definition at line 962 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set ( const std::string &  filename  )  [inline]

This method sets the members of this object by loading them from a data file.

Parameters:
filename Name of data file.

Definition at line 972 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_identity ( const unsigned int &  new_size  )  [inline]

This method sets the matrix to be squared, with elements equal one in the diagonal and zero outside the diagonal.

Parameters:
new_size New number of rows and columns in this matrix.

Definition at line 983 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_rows_number ( const unsigned int &  new_rows_number  )  [inline]

This method sets a new number of rows in the matrix.

Parameters:
new_rows_number Number of matrix rows.

Definition at line 995 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_columns_number ( const unsigned int &  new_columns_number  )  [inline]

This method sets a new number of columns in the matrix.

Parameters:
new_columns_number Number of matrix columns.

Definition at line 1009 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::resize ( const unsigned int &  new_rows_number,
const unsigned int &  new_columns_number 
) [inline]

This method sets new numbers of rows and columns in the vector. It does initialize the new matrix with the previous values.

Parameters:
new_rows_number New number of rows.
new_columns_number New number of columns.

Definition at line 1025 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::tuck_in ( const unsigned int &  row_position,
const unsigned int &  column_position,
const Matrix< Type > &  other_matrix 
) [inline]

Tuck in another matrix starting from a given position.

Parameters:
row_position Insertion row position.
column_position Insertion row position.
other_matrix Matrix to be inserted.

Definition at line 1136 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::arrange_submatrix ( const Vector< unsigned int > &  row_indices,
const Vector< unsigned int > &  column_indices 
) const [inline]

This method returns a matrix with the values of given rows and columns from this matrix.

Parameters:
row_indices Indices of matrix rows.
column_indices Indices of matrix columns.

Definition at line 1185 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::arrange_submatrix_rows ( const Vector< unsigned int > &  row_indices  )  const [inline]

This method returns a submatrix with the values of given rows from this matrix.

Parameters:
row_indices Indices of matrix rows.

Definition at line 1216 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::arrange_submatrix_columns ( const Vector< unsigned int > &  column_indices  )  const [inline]

This method returns a submatrix with the values of given columns from this matrix.

Parameters:
column_indices Indices of matrix columns.

Definition at line 1243 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::arrange_row ( const unsigned int &  i  )  const [inline]

This method returns the row i of the matrix.

Parameters:
i Index of row.

Definition at line 1270 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::arrange_row ( const unsigned int &  row_index,
const Vector< unsigned int > &  column_indices 
) const [inline]

This method returns the row i of the matrix, but only the elements specified by given indices.

Parameters:
row_index Index of row.
column_indices Column indices of row.

Definition at line 1306 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::arrange_column ( const unsigned int &  j  )  const [inline]

This method returns the column j of the matrix.

Parameters:
j Index of column.

Definition at line 1344 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::arrange_column ( const unsigned int &  column_index,
const Vector< unsigned int > &  row_indices 
) const [inline]

This method returns the column j of the matrix, but only those elements specified by given indices.

Parameters:
column_index Index of column.
row_indices Row indices of column.

Definition at line 1380 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::get_diagonal ( void   )  const [inline]

This method returns the diagonal of the matrix.

Definition at line 1416 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_row ( const unsigned int &  row_index,
const Vector< Type > &  new_row 
) [inline]

This method sets new values of a single row in the matrix.

Parameters:
row_index Index of row.
new_row New values of single row.

Definition at line 1452 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_row ( const unsigned int &  row_index,
const Type &  value 
) [inline]

This method sets a new value of a single row in the matrix.

Parameters:
row_index Index of row.
value New value of single row.

Definition at line 1499 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_column ( const unsigned int &  column_index,
const Vector< Type > &  new_column 
) [inline]

This method sets new values of a single column in the matrix.

Parameters:
column_index Index of column.
new_column New values of single column.

Definition at line 1533 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_column ( const unsigned int &  column_index,
const Type &  value 
) [inline]

This method sets a new values of a single column in the matrix.

Parameters:
column_index Index of column.
value New value of single column.

Definition at line 1580 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_diagonal ( const Type &  new_diagonal  )  [inline]

This method sets a new value for the diagonal elements in the matrix. The matrix must be square.

Parameters:
new_diagonal New value of diagonal.

Definition at line 1615 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::set_diagonal ( const Vector< Type > &  new_diagonal  )  [inline]

This method sets new values of the diagonal in the matrix. The matrix must be square.

Parameters:
new_diagonal New values of diagonal.

Definition at line 1649 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_diagonal ( const unsigned int &  new_size,
const Type &  new_value 
) [inline]

This method sets this matrix to be diagonal. A diagonal matrix is a square matrix in which the entries outside the main diagonal are all zero. It also initializes the elements on the main diagonal to a unique given value.

Parameters:
new_size Number of rows and colums in the matrix.
new_value Value of all the elements in the main diagonal.

Definition at line 1698 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_diagonal ( const unsigned int &  new_size,
const Vector< Type > &  new_values 
) [inline]

This method sets this matrix to be diagonal. A diagonal matrix is a square matrix in which the entries outside the main diagonal are all zero. It also initializes the elements on the main diagonal to given values.

Parameters:
new_size Number of rows and colums in the matrix.
new_values Values of the elements in the main diagonal.

Definition at line 1713 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::sum_diagonal ( const Type &  new_summing_value  )  const [inline]

This method sums a new value to the diagonal elements in the matrix. The matrix must be square.

Parameters:
new_summing_value New summing value.

Definition at line 1745 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::sum_diagonal ( const Vector< Type > &  new_summing_values  )  const [inline]

This method sums new values to the diagonal in the matrix. The matrix must be square.

Parameters:
new_summing_values Vector of summing values.

Definition at line 1781 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::append_row ( const Vector< Type > &  new_row  )  [inline]

This method appends a new row to the matrix. The size of the row vector must be equal to the number of columns of the matrix. Note that resizing is necessary here and therefore this method can be very inefficient.

Parameters:
new_row Row to be appended.

Definition at line 1831 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::append_column ( const Vector< Type > &  new_column  )  [inline]

This method appends a new column to the matrix. The size of the column vector must be equal to the number of rows of the matrix. Note that resizing is necessary here and therefore this method can be very inefficient.

Parameters:
new_column Column to be appended.

Definition at line 1863 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::subtract_row ( const unsigned int &  row_index  )  [inline]

This method removes the row with given index. Note that resizing is here necessary and this method can be very inefficient.

Parameters:
row_index Index of row to be removed.

Definition at line 1894 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::subtract_column ( const unsigned int &  column_index  )  [inline]

This method removes the column with given index. Note that resizing is here necessary and this method can be very inefficient.

Parameters:
column_index Index of column to be removed.

Definition at line 1949 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::get_assembly_columns ( const Matrix< Type > &  other_matrix  )  const [inline]

Assemble two matrices.

Parameters:
other_matrix matrix to be get_assemblyd to this matrix.

Definition at line 2003 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize ( const Type &  value  )  const [inline]

This method initializes all the elements of the matrix with a given value.

Parameters:
value Type value.

Definition at line 2047 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_uniform ( void   )  const [inline]

This method initializes all the elements in the matrix with random values comprised between -1 and 1.

Definition at line 2063 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_uniform ( const double &  minimum,
double  maximum 
) const [inline]

This method initializes all the elements in the matrix with random values comprised between a minimum and a maximum values.

Parameters:
minimum Minimum possible value.
maximum Maximum possible value.

Definition at line 2082 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_uniform ( const Matrix< double > &  minimum,
const Matrix< double > &  maximum 
) const [inline]

This method initializes all the elements in the matrix with random values comprised between a minimum and a maximum values for each element.

Parameters:
minimum Minimum possible values.
maximum Maximum possible values.

Definition at line 2118 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_normal ( void   )  const [inline]

This method assigns random values to each element in the matrix, taken from a normal distribution with mean 0 and standard deviation 1.

Definition at line 2152 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_normal ( const double &  mean,
double  standard_deviation 
) const [inline]

This method assigns random values to each element in the matrix, taken from a normal distribution with a given mean and a given standard deviation.

Parameters:
mean Mean value of uniform distribution.
standard_deviation Standard deviation value of uniform distribution.

Definition at line 2171 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_normal ( const Matrix< double > &  mean,
const Matrix< double > &  standard_deviation 
) const [inline]

This method assigns random values to each element in the vector, taken from normal distributions with given means and standard deviations for each element.

Parameters:
mean Mean values of uniform distributions.
standard_deviation Standard deviation values of uniform distributions.

Definition at line 2207 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_identity ( void   )  const [inline]

This method sets the diagonal elements in the matrix with ones and the rest elements with zeros. The matrix must be square.

Definition at line 2241 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::initialize_diagonal ( const Type &  value  )  const [inline]

This method sets the diagonal elements in the matrix with ones and the rest elements with a given value. The matrix must be square.

Definition at line 2282 of file matrix.h.

template<class Type>
double OpenNN::Matrix< Type >::calculate_trace ( void   )  const [inline]

This method returns the trace of the matrix, which is defined to be the sum of the main diagonal elements. The matrix must be square.

Definition at line 2323 of file matrix.h.

template<class Type>
Vector<double> OpenNN::Matrix< Type >::calculate_mean ( void   )  const [inline]

This method returns a vector with the mean values of all the matrix columns. The size is equal to the number of columns in the matrix.

Definition at line 2358 of file matrix.h.

template<class Type>
Vector<double> OpenNN::Matrix< Type >::calculate_mean ( const Vector< unsigned int > &  column_indices  )  const [inline]

This method returns a vector with the mean values of given columns. The size of the vector is equal to the size of the column indices vector.

Parameters:
column_indices Indices of columns.

Definition at line 2403 of file matrix.h.

template<class Type>
Vector<double> OpenNN::Matrix< Type >::calculate_mean ( const Vector< unsigned int > &  row_indices,
const Vector< unsigned int > &  column_indices 
) const [inline]

This method returns a vector with the mean values of given columns for given rows. The size of the vector is equal to the size of the column indices vector.

Parameters:
row_indices Indices of rows.
column_indices Indices of columns.

Definition at line 2438 of file matrix.h.

template<class Type>
Vector< Vector<double> > OpenNN::Matrix< Type >::calculate_mean_standard_deviation ( void   )  const [inline]

This method returns a vector of vectors with the mean and standard deviation values of all the matrix columns. The size of the vector is two. The size of each element is equal to the number of columns in the matrix.

Definition at line 2547 of file matrix.h.

template<class Type>
Vector< Vector<double> > OpenNN::Matrix< Type >::calculate_mean_standard_deviation ( const Vector< unsigned int > &  column_indices  )  const [inline]

This method returns a vector of vectors with the mean and standard deviation values of given columns. The size of the vector is two. The size of each element is equal to the size of the column indices vector.

Parameters:
column_indices Indices of columns.

Definition at line 2616 of file matrix.h.

template<class Type>
Vector< Vector<double> > OpenNN::Matrix< Type >::calculate_mean_standard_deviation ( const Vector< unsigned int > &  row_indices,
const Vector< unsigned int > &  column_indices 
) const [inline]

This method returns a vector of vectors with the mean and standard deviation values of given columns for given rows. The size of the vector is two. The size of each element is equal to the size of the column indices vector.

Parameters:
row_indices Indices of rows.
column_indices Indices of columns.

Definition at line 2677 of file matrix.h.

template<class Type>
Vector< Vector<Type> > OpenNN::Matrix< Type >::calculate_minimum_maximum ( void   )  const [inline]

This method returns a vector of vectors with the minimum and maximum values of all the matrix columns. The size of the vector is two. The size of each element is equal to the number of columns in the matrix.

Definition at line 2813 of file matrix.h.

template<class Type>
Vector< Vector<Type> > OpenNN::Matrix< Type >::calculate_minimum_maximum ( const Vector< unsigned int > &  column_indices  )  const [inline]

This method returns a vector of vectors with the minimum and maximum values of given columns. The size of the vector is two. The size of each element is equal to the size of the column indices vector.

Parameters:
column_indices Indices of columns.

Definition at line 2852 of file matrix.h.

template<class Type>
Vector< Vector<Type> > OpenNN::Matrix< Type >::calculate_minimum_maximum ( const Vector< unsigned int > &  row_indices,
const Vector< unsigned int > &  column_indices 
) const [inline]

This method returns a vector of vectors with the minimum and maximum values of given columns for given rows. The size of the vector is two. The size of each element is equal to the size of the column indices vector.

Parameters:
row_indices Indices of rows.
column_indices Indices of columns.

Definition at line 2916 of file matrix.h.

template<class Type>
Vector< Vector<double> > OpenNN::Matrix< Type >::calculate_statistics ( void   )  const [inline]

This method returns the basic statistics of the columns. The format is a vector of size four. The first subvector contains the minimum values of the columns. The second subvector contains the maximum values of the columns. The third subvector contains the mean values of the columns. The fourth subvector contains the standard deviation values of the columns.

Definition at line 2967 of file matrix.h.

template<class Type>
Vector< Vector< Vector<Type> > > OpenNN::Matrix< Type >::calculate_histogram ( const unsigned int &  bins_number  )  const [inline]

This method calculates a histogram for each column, each having a given number of bins. It returns a vector of vectors of vectors. The size of the main vector is the number of columns. Each subvector contains the frequencies and centers of that colums.

Parameters:
bins_number Number of bins for each histogram.

Definition at line 3001 of file matrix.h.

template<class Type>
Vector< Vector< Vector<Type> > > OpenNN::Matrix< Type >::calculate_histogram ( void   )  const [inline]

This method calculates a histogram for each column, each having a default number of bins (10). It returns a vector of vectors of vectors. The size of the main vector is the number of columns. Each subvector contains the frequencies and centers of that colums.

Definition at line 3025 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::scale_mean_standard_deviation ( const Vector< double > &  mean,
const Vector< double > &  standard_deviation 
) const [inline]

This method scales the matrix elements with given mean and standard deviation values. It updates the data in the matrix. The size of the mean and standard deviation vectors must be equal to the number of columns in the matrix.

Parameters:
mean Mean values.
standard_deviation Standard deviation values.

Definition at line 3050 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::scale_minimum_maximum ( const Vector< double > &  minimum,
const Vector< double > &  maximum 
) const [inline]

This method scales the matrix elements with given minimum and maximum values. It updates the data in the matrix. The size of the minimum and maximum vectors must be equal to the number of columns in the matrix.

Parameters:
minimum Minimum values.
maximum Maximum values.

Definition at line 3113 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::unscale_mean_standard_deviation ( const Vector< double > &  mean,
const Vector< double > &  standard_deviation 
) const [inline]

This method unscales the matrix elements with given mean and standard deviation values. It updates the matrix elements. The size of the mean and standard deviation vectors must be equal to the number of columns in the matrix.

Parameters:
mean Mean values.
standard_deviation Standard deviation values.

Definition at line 3177 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::unscale_minimum_maximum ( const Vector< double > &  minimum,
const Vector< double > &  maximum 
) const [inline]

This method unscales the matrix elements with given minimum and maximum values. It updates the matrix elements. The size of the minimum and maximum vectors must be equal to the number of columns in the matrix.

Parameters:
minimum Minimum values.
maximum Maximum deviation values.

Definition at line 3239 of file matrix.h.

template<class Type>
Vector<unsigned int> OpenNN::Matrix< Type >::calculate_minimal_indices ( void   )  const [inline]

This method returns the row and column indices corresponding to the entry with minimum value.

Definition at line 3297 of file matrix.h.

template<class Type>
Vector<unsigned int> OpenNN::Matrix< Type >::calculate_maximal_indices ( void   )  const [inline]

This method returns the row and column indices corresponding to the entry with maximum value.

Definition at line 3323 of file matrix.h.

template<class Type>
Vector< Vector<unsigned int> > OpenNN::Matrix< Type >::calculate_minimal_maximal_indices ( void   )  const [inline]

This method returns the row and column indices corresponding to the entries with minimum and maximum values. The format is a vector of two vectors. Each subvector also has two elements. The first vector contains the minimal indices, and the second vector contains the maximal indices.

Definition at line 3353 of file matrix.h.

template<class Type>
double OpenNN::Matrix< Type >::calculate_sum_squared_error ( const Matrix< double > &  other_matrix  )  const [inline]

This method returns the sum squared error between the elements of this matrix and the elements of another matrix.

Parameters:
other_matrix Other matrix.

Definition at line 3394 of file matrix.h.

template<class Type>
double OpenNN::Matrix< Type >::calculate_sum_squared_error ( const Vector< double > &  vector  )  const [inline]

This method retuns the sum squared error between the elements of this matrix and the elements of a vector, by columns. The size of the vector must be equal to the number of columns of this matrix.

Parameters:
vector Vector to be compared to this matrix.

Definition at line 3448 of file matrix.h.

template<class Type>
Vector<double> OpenNN::Matrix< Type >::calculate_rows_norm ( void   )  const [inline]

This method returns a vector with the norm of each row. The size of that vector is the number of rows.

Definition at line 3488 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::calculate_absolute_value ( void   )  const [inline]

This method returns a matrix with the absolute values of this matrix.

Definition at line 3510 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::calculate_transpose ( void   )  const [inline]

This method returns the transpose of the matrix.

Definition at line 3538 of file matrix.h.

template<class Type>
Type OpenNN::Matrix< Type >::calculate_determinant ( void   )  const [inline]

This method returns the determinant of a square matrix.

Definition at line 3558 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::calculate_cofactor ( void   )  const [inline]

This method returns the cofactor matrix.

Definition at line 3638 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::calculate_inverse ( void   )  const [inline]

This method returns the inverse of a square matrix. An error message is printed if the matrix is singular.

Definition at line 3689 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator+ ( const Type &  scalar  )  const [inline]

Sum matrix+scalar arithmetic operator.

Parameters:
scalar Scalar value to be added to this matrix.

Definition at line 3742 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator+ ( const Vector< Type > &  vector  )  const [inline]

Sum matrix+vector arithmetic operator.

Parameters:
vector Vector to be added to this matrix.

Definition at line 3763 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator+ ( const Matrix< Type > &  other_matrix  )  const [inline]

Sum matrix+matrix arithmetic operator.

Parameters:
other_matrix Matrix to be added to this vector.

Definition at line 3803 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator- ( const Type &  scalar  )  const [inline]

Difference matrix-scalar arithmetic operator.

Parameters:
scalar Scalar value to be subtracted to this matrix.

Definition at line 3844 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator- ( const Vector< Type > &  vector  )  const [inline]

Sum matrix-vector arithmetic operator.

Parameters:
vector Vector to be subtracted to this matrix.

Definition at line 3865 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator- ( const Matrix< Type > &  other_matrix  )  const [inline]

Difference matrix-matrix arithmetic operator.

Parameters:
other_matrix Matrix to be subtracted to this matrix.

Definition at line 3905 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator* ( const Type &  scalar  )  const [inline]

Product matrix*scalar arithmetic operator.

Parameters:
scalar Scalar value to be multiplied to this matrix.

Definition at line 3946 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator* ( const Vector< Type > &  vector  )  const [inline]

Row by element matrix*row arithmetic operator.

Parameters:
vector vector to be multiplied to this matrix.

Definition at line 3967 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator* ( const Matrix< Type > &  other_matrix  )  const [inline]

Product matrix*matrix arithmetic operator.

Parameters:
other_matrix Matrix to be multiplied to this matrix.

Definition at line 4007 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator/ ( const Type &  scalar  )  const [inline]

Cocient Matrix/scalar arithmetic operator.

Parameters:
scalar Value of scalar.

Definition at line 4048 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator/ ( const Vector< Type > &  vector  )  const [inline]

Cocient matrix/vector arithmetic operator.

Parameters:
vector Vector to be divided to this matrix.

Definition at line 4069 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::operator/ ( const Matrix< Type > &  other_matrix  )  const [inline]

Cocient matrix/matrix arithmetic operator.

Parameters:
other_matrix Matrix to be divided to this vector.

Definition at line 4109 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator+= ( const Type &  value  )  [inline]

Scalar sum and assignment operator.

Parameters:
value Scalar value to be added to this matrix.

Definition at line 4150 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator+= ( const Matrix< Type > &  other_matrix  )  [inline]

Matrix sum and assignment operator.

Parameters:
other_matrix Matrix to be added to this matrix.

Definition at line 4167 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator-= ( const Type &  value  )  [inline]

Scalar rest and assignment operator.

Parameters:
value Scalar value to be subtracted to this matrix.

Definition at line 4216 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator-= ( const Matrix< Type > &  other_matrix  )  [inline]

Matrix rest and assignment operator.

Parameters:
other_matrix Matrix to be subtracted to this matrix.

Definition at line 4233 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator*= ( const Type &  value  )  [inline]

Scalar product and assignment operator.

Parameters:
value Scalar value to be multiplied to this matrix.

Definition at line 4282 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator*= ( const Matrix< Type > &  other_matrix  )  [inline]

Matrix product and assignment operator.

Parameters:
other_matrix Matrix to be multiplied to this matrix.

Definition at line 4299 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator/= ( const Type &  value  )  [inline]

Scalar division and assignment operator.

Parameters:
value Scalar value to be divided to this matrix.

Definition at line 4335 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::operator/= ( const Matrix< Type > &  other_matrix  )  [inline]

Matrix division and assignment operator.

Parameters:
other_matrix Matrix to be divided to this matrix.

Definition at line 4352 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::dot ( const Vector< Type > &  vector  )  const [inline]

This method returns the dot product of this matrix with a vector. The size of the vector must be equal to the number of columns of the matrix.

Parameters:
vector Vector to be multiplied to this matrix.

Definition at line 4402 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::dot ( const Matrix< Type > &  other_matrix  )  const [inline]

This method returns the dot product of this matrix with another matrix.

Parameters:
other_matrix Matrix to be multiplied to this matrix.

Definition at line 4447 of file matrix.h.

template<class Type>
Matrix<Type> OpenNN::Matrix< Type >::direct ( const Matrix< Type > &  other_matrix  )  const [inline]

This method calculates the direct product of this matrix with another matrix. This product is also known as the Kronecker product.

Parameters:
other_matrix Second product term.
Todo:

Definition at line 4494 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::empty ( void   )  const [inline]

This method returns true if number of rows and columns is zero.

Definition at line 4508 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::is_square ( void   )  const [inline]

This method returns true if this matrix is square. A square matrix has the same numbers of rows and columns.

Definition at line 4528 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::is_symmetric ( void   )  const [inline]

This method returns true if this matrix is symmetric. A symmetric matrix is a squared matrix which is equal to its transpose.

Definition at line 4547 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::is_antisymmetric ( void   )  const [inline]

This method returns true if this matrix is antysymmetric. A symmetric matrix is a squared matrix which its opposed is equal to its transpose.

Definition at line 4589 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::is_diagonal ( void   )  const [inline]

This method returns true if this matrix is diagonal. A diagonal matrix is which the entries outside the main diagonal are zero.

Definition at line 4630 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::is_scalar ( void   )  const [inline]

This method returns true if this matrix is scalar. A scalar matrix is a diagonal matrix whose diagonal elements all contain the same scalar.

Definition at line 4669 of file matrix.h.

template<class Type>
bool OpenNN::Matrix< Type >::is_identity ( void   )  const [inline]

This method returns true if this matrix is the identity. The identity matrix or unit matrix is a square matrix with ones on the main diagonal and zeros elsewhere.

Definition at line 4697 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::print ( void   )  const [inline]

This method prints to the screen in the matrix object.

Definition at line 4739 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::load ( const std::string &  filename  )  [inline]

This method loads the numbers of rows and columns and the values of the matrix from a data file.

Parameters:
filename Filename.

Definition at line 4751 of file matrix.h.

template<class Type>
void OpenNN::Matrix< Type >::save ( const std::string &  filename  )  const [inline]

This method saves the numbers of rows and columns and the values of the matrix to a data file.

Parameters:
filename Filename.

Definition at line 4826 of file matrix.h.

template<class Type>
std::string OpenNN::Matrix< Type >::to_string ( void   )  const [inline]

This method returns a string representation of this matrix. The elements are separated by spaces. The rows are separated by the character "\n".

Definition at line 4865 of file matrix.h.

template<class Type>
Matrix<std::string> OpenNN::Matrix< Type >::get_string_matrix ( void   )  const [inline]

This method returns a new matrix in which each entry has been converted to a string.

Definition at line 4879 of file matrix.h.

template<class Type>
Vector<Type> OpenNN::Matrix< Type >::to_vector ( void   )  const [inline]

This method returns a vector representation of this matrix. The size of the new vector is equal to the number of elements of this matrix. The entries of the new vector are the entries of this matrix ordered by rows.

Definition at line 4906 of file matrix.h.


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

Generated on Sun Aug 26 11:58:21 2012 for OpenNN by  doxygen 1.5.9