OpenNN  2.2
Open Neural Networks Library
Public Member Functions | Private Attributes | List of all members
OpenNN::Matrix< T > Class Template Reference

#include <matrix.h>

Inheritance diagram for OpenNN::Matrix< T >:

Public Member Functions

 Matrix (void)
 
 Matrix (const size_t &, const size_t &)
 
 Matrix (const size_t &, const size_t &, const T &)
 
 Matrix (const std::string &)
 
 Matrix (const Matrix &)
 
virtual ~Matrix (void)
 
Matrix< T > & operator= (const Matrix< T > &)
 
T & operator() (const size_t &, const size_t &)
 
const T & operator() (const size_t &, const size_t &) const
 
bool operator== (const Matrix< T > &) const
 
bool operator== (const T &) const
 
bool operator!= (const Matrix< T > &) const
 
bool operator!= (const T &value) const
 
bool operator> (const Matrix< T > &) const
 
bool operator> (const T &value) const
 
bool operator< (const Matrix< T > &) const
 
bool operator< (const T &value) const
 
bool operator>= (const Matrix< T > &) const
 
bool operator>= (const T &) const
 
bool operator<= (const Matrix< T > &) const
 
bool operator<= (const T &) const
 
const size_t & get_rows_number (void) const
 
const size_t & get_columns_number (void) const
 
void set (void)
 
void set (const size_t &, const size_t &)
 
void set (const size_t &, const size_t &, const T &)
 
void set (const Matrix< T > &)
 
void set (const std::string &)
 
void set_identity (const size_t &)
 
void set_rows_number (const size_t &)
 
void set_columns_number (const size_t &)
 
void tuck_in (const size_t &, const size_t &, const Matrix< T > &)
 
size_t count_diagonal_elements (void) const
 
size_t count_off_diagonal_elements (void) const
 
Matrix< T > arrange_submatrix (const Vector< size_t > &, const Vector< size_t > &) const
 
Matrix< T > arrange_submatrix_rows (const Vector< size_t > &) const
 
Matrix< T > arrange_submatrix_columns (const Vector< size_t > &) const
 
Vector< T > arrange_row (const size_t &) const
 
Vector< T > arrange_row (const size_t &, const Vector< size_t > &) const
 
Vector< T > arrange_column (const size_t &) const
 
Vector< T > arrange_column (const size_t &, const Vector< size_t > &) const
 
Vector< T > get_diagonal (void) const
 
void set_row (const size_t &, const Vector< T > &)
 
void set_row (const size_t &, const T &)
 
void set_column (const size_t &, const Vector< T > &)
 
void set_column (const size_t &, const T &)
 
void set_diagonal (const T &)
 
void set_diagonal (const Vector< T > &)
 
void initialize_diagonal (const size_t &, const T &)
 
void initialize_diagonal (const size_t &, const Vector< T > &)
 
Matrix< T > sum_diagonal (const T &) const
 
Matrix< T > sum_diagonal (const Vector< T > &) const
 
void append_row (const Vector< T > &)
 
void append_column (const Vector< T > &)
 
void insert_row (const size_t &, const Vector< T > &)
 
void insert_column (const size_t &, const Vector< T > &)
 
void subtract_row (const size_t &)
 
void subtract_column (const size_t &)
 
Matrix< T > assemble_rows (const Matrix< T > &) const
 
Matrix< T > assemble_columns (const Matrix< T > &) const
 
void sort_less (const size_t &)
 
void sort_greater (const size_t &)
 
void initialize (const T &)
 
void randomize_uniform (const double &=-1.0, const double &=1.0)
 
void randomize_uniform (const Matrix< double > &, const Matrix< double > &)
 
void randomize_normal (const double &=0.0, const double &=1.0)
 
void randomize_normal (const Matrix< double > &, const Matrix< double > &)
 
void initialize_identity (void)
 
void initialize_diagonal (const T &)
 
calculate_sum (void) const
 
Vector< T > calculate_rows_sum (void) const
 
void sum_row (const size_t &, const Vector< T > &)
 
double calculate_trace (void) const
 
Vector< double > calculate_mean (void) const
 
double calculate_mean (const size_t &) const
 
Vector< double > calculate_mean (const Vector< size_t > &) const
 
Vector< double > calculate_mean (const Vector< size_t > &, const Vector< size_t > &) const
 
Vector< double > calculate_mean_missing_values (const Vector< Vector< size_t > > &) const
 
Vector< double > calculate_mean_missing_values (const Vector< size_t > &, const Vector< size_t > &, const Vector< Vector< size_t > > &) const
 
Vector< Vector< double > > calculate_mean_standard_deviation (void) const
 
Vector< Vector< double > > calculate_mean_standard_deviation (const Vector< size_t > &) const
 
Vector< Vector< double > > calculate_mean_standard_deviation (const Vector< size_t > &, const Vector< size_t > &) const
 
calculate_minimum (void) const
 
calculate_maximum (void) const
 
Vector< Vector< T > > calculate_minimum_maximum (void) const
 
Vector< Vector< T > > calculate_minimum_maximum (const Vector< size_t > &) const
 
Vector< Vector< T > > calculate_minimum_maximum (const Vector< size_t > &, const Vector< size_t > &) const
 
Vector< Statistics< T > > calculate_statistics (void) const
 
Vector< Statistics< T > > calculate_statistics_missing_values (const Vector< Vector< size_t > > &) const
 
Vector< Statistics< T > > calculate_statistics (const Vector< size_t > &, const Vector< size_t > &) const
 
Vector< Statistics< T > > calculate_rows_statistics (const Vector< size_t > &) const
 
Vector< Statistics< T > > calculate_rows_statistics_missing_values (const Vector< size_t > &, const Vector< Vector< size_t > > &) const
 
Vector< Statistics< T > > calculate_columns_statistics (const Vector< size_t > &) const
 
Vector< Statistics< T > > calculate_columns_statistics_missing_values (const Vector< size_t > &, const Vector< Vector< size_t > >) const
 
Vector< Histogram< T > > calculate_histograms (const size_t &=10) const
 
Vector< Histogram< T > > calculate_histograms_missing_values (const Vector< Vector< size_t > > &, const size_t &=10) const
 
Matrix< size_t > calculate_less_than_indices (const T &) const
 
Matrix< size_t > calculate_greater_than_indices (const T &) const
 
void scale_mean_standard_deviation (const Vector< Statistics< T > > &)
 
Vector< Statistics< T > > scale_mean_standard_deviation (void)
 
void scale_rows_mean_standard_deviation (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void scale_columns_mean_standard_deviation (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void scale_minimum_maximum (const Vector< Statistics< T > > &)
 
Vector< Statistics< T > > scale_minimum_maximum (void)
 
void scale_rows_minimum_maximum (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void scale_columns_minimum_maximum (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void unscale_mean_standard_deviation (const Vector< Statistics< T > > &)
 
void unscale_rows_mean_standard_deviation (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void unscale_columns_mean_standard_deviation (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void unscale_minimum_maximum (const Vector< Statistics< T > > &)
 
void unscale_rows_minimum_maximum (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
void unscale_columns_minimum_maximum (const Vector< Statistics< T > > &, const Vector< size_t > &)
 
Vector< size_t > calculate_minimal_indices (void) const
 
Vector< size_t > calculate_maximal_indices (void) const
 
Vector< Vector< size_t > > calculate_minimal_maximal_indices (void) const
 
double calculate_sum_squared_error (const Matrix< double > &) const
 
double calculate_sum_squared_error (const Vector< double > &) const
 
Vector< double > calculate_rows_norm (void) const
 
Matrix< T > calculate_absolute_value (void) const
 
Matrix< T > calculate_transpose (void) const
 
calculate_determinant (void) const
 
Matrix< T > calculate_cofactor (void) const
 
Matrix< T > calculate_inverse (void) const
 
Matrix< T > operator+ (const T &) const
 
Matrix< T > operator+ (const Vector< T > &) const
 
Matrix< T > operator+ (const Matrix< T > &) const
 
Matrix< T > operator- (const T &scalar) const
 
Matrix< T > operator- (const Vector< T > &) const
 
Matrix< T > operator- (const Matrix< T > &) const
 
Matrix< T > operator* (const T &) const
 
Matrix< T > operator* (const Vector< T > &) const
 
Matrix< T > operator* (const Matrix< T > &) const
 
Matrix< T > operator/ (const T &) const
 
Matrix< T > operator/ (const Vector< T > &) const
 
Matrix< T > operator/ (const Matrix< T > &) const
 
void operator+= (const T &value)
 
void operator+= (const Matrix< T > &other_matrix)
 
void operator-= (const T &)
 
void operator-= (const Matrix< T > &)
 
void operator*= (const T &)
 
void operator*= (const Matrix< T > &)
 
void operator/= (const T &)
 
void operator/= (const Matrix< T > &)
 
Vector< double > dot (const Vector< double > &) const
 
Matrix< double > dot (const Matrix< double > &) const
 
Matrix< T > direct (const Matrix< T > &) 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
 
Matrix< T > filter (const size_t &, const T &, const T &) const
 
void convert_time_series (const size_t &)
 
void convert_autoassociation (void)
 
void convert_angular_variables_degrees (const size_t &)
 
void convert_angular_variables_radians (const size_t &)
 
void print (void) const
 
void load (const std::string &)
 
void save (const std::string &) const
 
void save_csv (const std::string &) const
 
void parse (const std::string &)
 
std::string to_string (const std::string &=" ") const
 
Matrix< std::string > write_string_matrix (const size_t &=3) const
 
std::vector< T > to_std_vector (void) const
 
Vector< T > to_vector (void) const
 
void print_preview (void) const
 

Private Attributes

size_t rows_number
 
size_t columns_number
 

Detailed Description

template<class T>
class OpenNN::Matrix< T >

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

Definition at line 38 of file matrix.h.

Constructor & Destructor Documentation

template<class T >
OpenNN::Matrix< T >::Matrix ( const size_t &  new_rows_number,
const size_t &  new_columns_number 
)
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_numberNumber of rows in matrix.
new_columns_numberNumber of columns in matrix.

Definition at line 425 of file matrix.h.

template<class T>
OpenNN::Matrix< T >::Matrix ( const size_t &  new_rows_number,
const size_t &  new_columns_number,
const T &  value 
)
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_numberNumber of rows in matrix.
new_columns_numberNumber of columns in matrix.
valueValue of Type.

Definition at line 466 of file matrix.h.

template<class T>
OpenNN::Matrix< T >::Matrix ( const std::string &  file_name)
explicit

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

Parameters
file_nameName of matrix data file.

Definition at line 509 of file matrix.h.

template<class T>
OpenNN::Matrix< T >::Matrix ( const Matrix< T > &  other_matrix)

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

Parameters
other_matrixMatrix to be copied.

Definition at line 522 of file matrix.h.

Member Function Documentation

template<class T>
void OpenNN::Matrix< T >::append_column ( const Vector< T > &  new_column)

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_columnColumn to be appended.

Definition at line 2123 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::append_row ( const Vector< T > &  new_row)

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_rowRow to be appended.

Definition at line 2080 of file matrix.h.

template<class T >
Vector< T > OpenNN::Matrix< T >::arrange_column ( const size_t &  j) const

Returns the column j of the matrix.

Parameters
jIndex of column.

Definition at line 1580 of file matrix.h.

template<class T >
Vector< T > OpenNN::Matrix< T >::arrange_column ( const size_t &  column_index,
const Vector< size_t > &  row_indices 
) const

Returns the column j of the matrix, but only those elements specified by given indices.

Parameters
column_indexIndex of column.
row_indicesRow indices of column.

Definition at line 1617 of file matrix.h.

template<class T >
Vector< T > OpenNN::Matrix< T >::arrange_row ( const size_t &  i) const

Returns the row i of the matrix.

Parameters
iIndex of row.

Definition at line 1505 of file matrix.h.

template<class T >
Vector< T > OpenNN::Matrix< T >::arrange_row ( const size_t &  row_index,
const Vector< size_t > &  column_indices 
) const

Returns the row i of the matrix, but only the elements specified by given indices.

Parameters
row_indexIndex of row.
column_indicesColumn indices of row.

Definition at line 1542 of file matrix.h.

template<class T >
Matrix< T > OpenNN::Matrix< T >::arrange_submatrix ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  column_indices 
) const

Returns a matrix with the values of given rows and columns from this matrix.

Parameters
row_indicesIndices of matrix rows.
column_indicesIndices of matrix columns.

Definition at line 1417 of file matrix.h.

template<class T >
Matrix< T > OpenNN::Matrix< T >::arrange_submatrix_columns ( const Vector< size_t > &  column_indices) const

Returns a submatrix with the values of given columns from this matrix.

Parameters
column_indicesIndices of matrix columns.

Definition at line 1477 of file matrix.h.

template<class T >
Matrix< T > OpenNN::Matrix< T >::arrange_submatrix_rows ( const Vector< size_t > &  row_indices) const

Returns a submatrix with the values of given rows from this matrix.

Parameters
row_indicesIndices of matrix rows.

Definition at line 1449 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::assemble_columns ( const Matrix< T > &  other_matrix) const

Assemble two matrices.

Parameters
other_matrixmatrix to be get_assemblyd to this matrix.

Definition at line 2465 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::assemble_rows ( const Matrix< T > &  other_matrix) const

Assemble two matrices.

Parameters
other_matrixmatrix to be get_assembled to this matrix.

Definition at line 2394 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_columns_statistics ( const Vector< size_t > &  column_indices) const

Returns the basic statistics of given columns. The format is a vector of statistics structures. The size of that vector is equal to the number of given columns.

Parameters
column_indicesIndices of the columns for which the statistics are to be computed.

Definition at line 3835 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_columns_statistics_missing_values ( const Vector< size_t > &  column_indices,
const Vector< Vector< size_t > >  missing_indices 
) const

Returns the basic statistics of given columns when the matrix has missing values. The format is a vector of statistics structures. The size of that vector is equal to the number of given columns.

Parameters
column_indicesIndices of the columns for which the statistics are to be computed.
missing_indicesVector of vectors with the indices of the missing values.

Definition at line 3866 of file matrix.h.

template<class T>
Matrix< size_t > OpenNN::Matrix< T >::calculate_greater_than_indices ( const T &  value) const

Returns the matrix indices at which the elements are greater than some given value.

Parameters
valueValue.

Definition at line 3986 of file matrix.h.

template<class T >
Vector< Histogram< T > > OpenNN::Matrix< T >::calculate_histograms ( const size_t &  bins_number = 10) const

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_numberNumber of bins for each histogram.

Definition at line 3897 of file matrix.h.

template<class T >
Vector< Histogram< T > > OpenNN::Matrix< T >::calculate_histograms_missing_values ( const Vector< Vector< size_t > > &  missing_indices,
const size_t &  bins_number = 10 
) const

Calculates a histogram for each column, each having a given number of bins, when the data has missing values. 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_numberNumber of bins for each histogram.
missing_indicesVector of vectors with the indices of the missing values.

Definition at line 3924 of file matrix.h.

template<class T >
Matrix< T > OpenNN::Matrix< T >::calculate_inverse ( void  ) const

Returns the inverse of a square matrix. An error message is printed if the matrix is singular.

Definition at line 5024 of file matrix.h.

template<class T>
Matrix< size_t > OpenNN::Matrix< T >::calculate_less_than_indices ( const T &  value) const

Returns the matrix indices at which the elements are less than some given value.

Parameters
valueValue.

Definition at line 3947 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::calculate_mean ( void  ) const

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 2859 of file matrix.h.

template<class T >
double OpenNN::Matrix< T >::calculate_mean ( const size_t &  column_index) const

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 2902 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::calculate_mean ( const Vector< size_t > &  column_indices) const

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_indicesIndices of columns.

Definition at line 2954 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::calculate_mean ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  column_indices 
) const

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_indicesIndices of rows.
column_indicesIndices of columns.

Definition at line 2988 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::calculate_mean_missing_values ( const Vector< Vector< size_t > > &  missing_indices) const

Returns a vector with the mean values of given columns for given rows when the matrix has missing values. The size of the vector is equal to the size of the column indices vector.

Parameters
missing_indicesVector of vectors with the indices of the missing values.

Definition at line 3096 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::calculate_mean_missing_values ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  column_indices,
const Vector< Vector< size_t > > &  missing_indices 
) const

Returns a vector with the mean values of given columns for given rows when the matrix has missing values. The size of the vector is equal to the size of the column indices vector.

Parameters
row_indicesIndices of rows.
column_indicesIndices of columns.
missing_indicesVector of vectors with the indices of the missing values.

Definition at line 3114 of file matrix.h.

template<class T >
Vector< Vector< double > > OpenNN::Matrix< T >::calculate_mean_standard_deviation ( void  ) const

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 3228 of file matrix.h.

template<class T >
Vector< Vector< double > > OpenNN::Matrix< T >::calculate_mean_standard_deviation ( const Vector< size_t > &  column_indices) const

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_indicesIndices of columns.

Definition at line 3278 of file matrix.h.

template<class T >
Vector< Vector< double > > OpenNN::Matrix< T >::calculate_mean_standard_deviation ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  column_indices 
) const

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_indicesIndices of rows.
column_indicesIndices of columns.

Definition at line 3319 of file matrix.h.

template<class T >
Vector< Vector< size_t > > OpenNN::Matrix< T >::calculate_minimal_maximal_indices ( void  ) const

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 4681 of file matrix.h.

template<class T >
Vector< Vector< T > > OpenNN::Matrix< T >::calculate_minimum_maximum ( void  ) const

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 3498 of file matrix.h.

template<class T >
Vector< Vector< T > > OpenNN::Matrix< T >::calculate_minimum_maximum ( const Vector< size_t > &  column_indices) const

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_indicesIndices of columns.

Definition at line 3538 of file matrix.h.

template<class T >
Vector< Vector< T > > OpenNN::Matrix< T >::calculate_minimum_maximum ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  column_indices 
) const

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_indicesIndices of rows.
column_indicesIndices of columns.

Definition at line 3603 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::calculate_rows_norm ( void  ) const

Returns a vector with the norm of each row. The size of that vector is the number of rows.

Definition at line 4817 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_rows_statistics ( const Vector< size_t > &  row_indices) const

Returns the basic statistics of all the columns for given rows. The format is a vector of statistics structures. The size of that vector is equal to the number of columns in this matrix.

Parameters
row_indicesIndices of the rows for which the statistics are to be computed.

Definition at line 3780 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_rows_statistics_missing_values ( const Vector< size_t > &  row_indices,
const Vector< Vector< size_t > > &  missing_indices 
) const

Returns the basic statistics of all the columns for given rows when the matrix has missing values. The format is a vector of statistics structures. The size of that vector is equal to the number of columns in this matrix.

Parameters
row_indicesIndices of the rows for which the statistics are to be computed.
missing_indicesVector of vectors with the indices of the missing values.

Definition at line 3808 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_statistics ( void  ) const

Returns the basic statistics of the columns. The format is a vector of statistics structures. The size of that vector is equal to the number of columns in this matrix.

Definition at line 3652 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_statistics ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  column_indices 
) const

Returns the basic statistics of given columns for given rows. The format is a vector of statistics structures. The size of that vector is equal to the number of given columns.

Parameters
row_indicesIndices of the rows for which the statistics are to be computed.
column_indicesIndices of the columns for which the statistics are to be computed.

Definition at line 3748 of file matrix.h.

template<class T >
Vector< Statistics< T > > OpenNN::Matrix< T >::calculate_statistics_missing_values ( const Vector< Vector< size_t > > &  missing_indices) const

Returns the basic statistics of the columns when the matrix has missing values. The format is a vector of statistics structures. The size of that vector is equal to the number of columns in this matrix.

Parameters
missing_indicesVector of vectors with the indices of the missing values.

Definition at line 3694 of file matrix.h.

template<class T >
double OpenNN::Matrix< T >::calculate_sum_squared_error ( const Matrix< double > &  other_matrix) const

Returns the sum squared error between the elements of this matrix and the elements of another matrix.

Parameters
other_matrixOther matrix.

Definition at line 4723 of file matrix.h.

template<class T >
double OpenNN::Matrix< T >::calculate_sum_squared_error ( const Vector< double > &  vector) const

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
vectorVector to be compared to this matrix.

Definition at line 4776 of file matrix.h.

template<class T >
double OpenNN::Matrix< T >::calculate_trace ( void  ) const

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 2823 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::convert_angular_variables_degrees ( const size_t &  column_index)

Converts a given column, representing angles in degrees, to two different columns with the sinus and the cosinus of the corresponding angles. Note that this method sets a new number of columns in the matrix.

Parameters
column_indexIndex of column to be converted.

Definition at line 6220 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::convert_angular_variables_radians ( const size_t &  column_index)

Converts a given column, representing angles in radians, to two different columns with the sinus and the cosinus of the corresponding angles. Note that this method sets a new number of columns in the matrix.

Parameters
column_indexIndex of column to be converted.

Definition at line 6274 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::convert_autoassociation ( void  )

Arranges the matrix in a proper format for autoassociation. Note that this method sets new numbers of columns in the matrix.

Definition at line 6205 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::convert_time_series ( const size_t &  lags_number)

Arranges a time series data matrix in a proper format for forecasting. Note that this method sets new numbers of rows and columns in the matrix.

Parameters
lags_numberNumber of lags for the prediction.
Todo:

Definition at line 6173 of file matrix.h.

template<class T >
size_t OpenNN::Matrix< T >::count_diagonal_elements ( void  ) const

Returns the number of elements in the diagonal which are not zero. This method is only defined for square matrices.

Definition at line 1333 of file matrix.h.

template<class T >
size_t OpenNN::Matrix< T >::count_off_diagonal_elements ( void  ) const

Returns the number of elements outside the diagonal which are not zero. This method is only defined for square matrices.

Definition at line 1372 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::direct ( const Matrix< T > &  other_matrix) const

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

Parameters
other_matrixSecond product term.

Definition at line 5872 of file matrix.h.

template<class T >
Vector< double > OpenNN::Matrix< T >::dot ( const Vector< double > &  vector) const

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
vectorVector to be multiplied to this matrix.

Definition at line 5772 of file matrix.h.

template<class T >
Matrix< double > OpenNN::Matrix< T >::dot ( const Matrix< double > &  other_matrix) const

Returns the dot product of this matrix with another matrix.

Parameters
other_matrixMatrix to be multiplied to this matrix.

Definition at line 5823 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::filter ( const size_t &  column_index,
const T &  minimum,
const T &  maximum 
) const

Returns a new matrix where a given column has been filtered.

Parameters
column_indexIndex of column.
minimumMinimum filtering value.
maximumMaximum filtering value.

Definition at line 6137 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::initialize ( const T &  value)

Initializes all the elements of the matrix with a given value.

Parameters
valueType value.

Definition at line 2510 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::initialize_diagonal ( const size_t &  new_size,
const T &  new_value 
)

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_sizeNumber of rows and colums in the matrix.
new_valueValue of all the elements in the main diagonal.

Definition at line 1943 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::initialize_diagonal ( const size_t &  new_size,
const Vector< T > &  new_values 
)

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_sizeNumber of rows and colums in the matrix.
new_valuesValues of the elements in the main diagonal.

Definition at line 1959 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::initialize_diagonal ( const T &  value)

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 2693 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::initialize_identity ( void  )

Sets the diagonal elements in the matrix with ones and the rest elements with zeros. The matrix must be square.

Definition at line 2659 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::insert_column ( const size_t &  position,
const Vector< T > &  new_column 
)

Inserts a new column in a given position. Note that this method resizes the matrix, which can be computationally expensive.

Parameters
positionIndex of new column.
new_columnVector with the column contents.

Definition at line 2223 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::insert_row ( const size_t &  position,
const Vector< T > &  new_row 
)

Inserts a new row in a given position. Note that this method resizes the matrix, which can be computationally expensive.

Parameters
positionIndex of new row.
new_rowVector with the row contents.

Definition at line 2156 of file matrix.h.

template<class T >
bool OpenNN::Matrix< T >::is_antisymmetric ( void  ) const

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 5984 of file matrix.h.

template<class T >
bool OpenNN::Matrix< T >::is_diagonal ( void  ) const

Returns true if this matrix is diagonal. A diagonal matrix is which the entries outside the main diagonal are zero.

Definition at line 6022 of file matrix.h.

template<class T >
bool OpenNN::Matrix< T >::is_identity ( void  ) const

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 6091 of file matrix.h.

template<class T >
bool OpenNN::Matrix< T >::is_scalar ( void  ) const

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 6062 of file matrix.h.

template<class T >
bool OpenNN::Matrix< T >::is_square ( void  ) const

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

Definition at line 5927 of file matrix.h.

template<class T >
bool OpenNN::Matrix< T >::is_symmetric ( void  ) const

Returns true if this matrix is symmetric. A symmetric matrix is a squared matrix which is equal to its transpose.

Definition at line 5946 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::load ( const std::string &  file_name)

Loads the numbers of rows and columns and the values of the matrix from a data file.

Parameters
file_nameFile name.

Definition at line 6324 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator!= ( const Matrix< T > &  other_matrix) const

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_matrixMatrix to be compared with.

Definition at line 713 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator!= ( const T &  value) const

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
valueType value to be compared with.

Definition at line 764 of file matrix.h.

template<class T >
T & OpenNN::Matrix< T >::operator() ( const size_t &  row,
const size_t &  column 
)
inline

Reference operator.

Returns the element (i,j) of the matrix.

Parameters
rowIndex of row.
columnIndex of column.

Definition at line 572 of file matrix.h.

template<class T >
const T & OpenNN::Matrix< T >::operator() ( const size_t &  row,
const size_t &  column 
) const
inline

Reference operator.

Returns the element (i,j) of the matrix.

Parameters
rowIndex of row.
columnIndex of column.

Definition at line 614 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator* ( const T &  scalar) const

Product matrix*scalar arithmetic operator.

Parameters
scalarScalar value to be multiplied to this matrix.

Definition at line 5282 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator* ( const Vector< T > &  vector) const

Row by element matrix*row arithmetic operator.

Parameters
vectorvector to be multiplied to this matrix.

Definition at line 5301 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator* ( const Matrix< T > &  other_matrix) const

Product matrix*matrix arithmetic operator.

Parameters
other_matrixMatrix to be multiplied to this matrix.

Definition at line 5342 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator*= ( const T &  value)

Scalar product and assignment operator.

Parameters
valueScalar value to be multiplied to this matrix.

Definition at line 5616 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator*= ( const Matrix< T > &  other_matrix)

Matrix product and assignment operator.

Parameters
other_matrixMatrix to be multiplied to this matrix.

Definition at line 5634 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator+ ( const T &  scalar) const

Sum matrix+scalar arithmetic operator.

Parameters
scalarScalar value to be added to this matrix.

Definition at line 5096 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator+ ( const Vector< T > &  vector) const

Sum matrix+vector arithmetic operator.

Parameters
vectorVector to be added to this matrix.

Definition at line 5112 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator+ ( const Matrix< T > &  other_matrix) const

Sum matrix+matrix arithmetic operator.

Parameters
other_matrixMatrix to be added to this vector.

Definition at line 5153 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator+= ( const T &  value)

Scalar sum and assignment operator.

Parameters
valueScalar value to be added to this matrix.

Definition at line 5480 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator+= ( const Matrix< T > &  other_matrix)

Matrix sum and assignment operator.

Parameters
other_matrixMatrix to be added to this matrix.

Definition at line 5498 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator- ( const T &  scalar) const

Difference matrix-scalar arithmetic operator.

Parameters
scalarScalar value to be subtracted to this matrix.

Definition at line 5189 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator- ( const Vector< T > &  vector) const

Sum matrix-vector arithmetic operator.

Parameters
vectorVector to be subtracted to this matrix.

Definition at line 5205 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator- ( const Matrix< T > &  other_matrix) const

Difference matrix-matrix arithmetic operator.

Parameters
other_matrixMatrix to be subtracted to this matrix.

Definition at line 5246 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator-= ( const T &  value)

Scalar rest and assignment operator.

Parameters
valueScalar value to be subtracted to this matrix.

Definition at line 5548 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator-= ( const Matrix< T > &  other_matrix)

Matrix rest and assignment operator.

Parameters
other_matrixMatrix to be subtracted to this matrix.

Definition at line 5566 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator/ ( const T &  scalar) const

Cocient Matrix/scalar arithmetic operator.

Parameters
scalarValue of scalar.

Definition at line 5381 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator/ ( const Vector< T > &  vector) const

Cocient matrix/vector arithmetic operator.

Parameters
vectorVector to be divided to this matrix.

Definition at line 5400 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::operator/ ( const Matrix< T > &  other_matrix) const

Cocient matrix/matrix arithmetic operator.

Parameters
other_matrixMatrix to be divided to this vector.

Definition at line 5441 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator/= ( const T &  value)

Scalar division and assignment operator.

Parameters
valueScalar value to be divided to this matrix.

Definition at line 5674 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::operator/= ( const Matrix< T > &  other_matrix)

Matrix division and assignment operator.

Parameters
other_matrixMatrix to be divided to this matrix.

Definition at line 5692 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator< ( const Matrix< T > &  other_matrix) const

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_matrixMatrix to be compared with.

Definition at line 861 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator< ( const T &  value) const

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
valueType value to be compared with.

Definition at line 912 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator<= ( const Matrix< T > &  other_matrix) const

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_matrixMatrix to be compared with.

Definition at line 1007 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator<= ( const T &  value) const

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
valueType value to be compared with.

Definition at line 1058 of file matrix.h.

template<class T>
Matrix< T > & OpenNN::Matrix< T >::operator= ( const Matrix< T > &  other_matrix)
inline

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

Parameters
other_matrixMatrix to be assigned.

Definition at line 545 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator== ( const Matrix< T > &  other_matrix) const

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_matrixMatrix to be compared with.

Definition at line 657 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator== ( const T &  value) const

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
valueType value to be compared with.

Definition at line 692 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator> ( const Matrix< T > &  other_matrix) const

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_matrixmatrix to be compared with.

Definition at line 788 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator> ( const T &  value) const

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
valueType value to be compared with.

Definition at line 839 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator>= ( const Matrix< T > &  other_matrix) const

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_matrixMatrix to be compared with.

Definition at line 934 of file matrix.h.

template<class T>
bool OpenNN::Matrix< T >::operator>= ( const T &  value) const

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
valueType value to be compared with.

Definition at line 985 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::parse ( const std::string &  str)

This method takes a string representation of a matrix and sets this matrix from that data.

Parameters
strString to be parsed.

Definition at line 6513 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::print_preview ( void  ) const

Prints to the sceen a preview of the matrix, i.e., the first, second and last rows

Definition at line 6661 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::randomize_normal ( const double &  mean = 0.0,
const double &  standard_deviation = 1.0 
)

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

Parameters
meanMean value of uniform distribution.
standard_deviationStandard deviation value of uniform distribution.

Definition at line 2593 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::randomize_normal ( const Matrix< double > &  mean,
const Matrix< double > &  standard_deviation 
)

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

Parameters
meanMean values of uniform distributions.
standard_deviationStandard deviation values of uniform distributions.

Definition at line 2627 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::randomize_uniform ( const double &  minimum = -1.0,
const double &  maximum = 1.0 
)

Initializes all the elements in the matrix with random values comprised between a minimum and a maximum values.

Parameters
minimumMinimum possible value.
maximumMaximum possible value.

Definition at line 2524 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::randomize_uniform ( const Matrix< double > &  minimum,
const Matrix< double > &  maximum 
)

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

Parameters
minimumMinimum possible values.
maximumMaximum possible values.

Definition at line 2558 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::save ( const std::string &  file_name) const

Saves the values of the matrix to a data file separated by spaces.

Parameters
file_nameFile name.

Definition at line 6417 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::save_csv ( const std::string &  file_name) const

Saves the values of the matrix to a data file separated by commas.

Parameters
file_nameFile name.

Definition at line 6456 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::scale_columns_mean_standard_deviation ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  columns_indices 
)

Scales given columns of this matrix with the mean and standard deviation method.

Parameters
statisticsVector of statistics structure containing the mean and standard deviation values for the scaling. The size of that vector must be equal to the number of columns to be scaled.
columns_indicesVector of indices with the columns to be scaled. The size of that vector must be equal to the number of columns to be scaled.

Definition at line 4143 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::scale_columns_minimum_maximum ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  column_indices 
)

Scales given columns of this matrix with the minimum and maximum method.

Parameters
statisticsVector of statistics structure containing the minimum and maximum values for the scaling. The size of that vector must be equal to the number of columns to be scaled.
column_indicesVector of indices with the columns to be scaled. The size of that vector must be equal to the number of columns to be scaled.

Definition at line 4314 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::scale_mean_standard_deviation ( const Vector< Statistics< T > > &  statistics)

Scales the matrix elements with the mean and standard deviation method. It updates the data in the matrix.

Parameters
statisticsVector of statistics structures conatining the mean and standard deviation values for the scaling. The size of that vector must be equal to the number of columns in this matrix.

Definition at line 4028 of file matrix.h.

template<class T>
Vector< Statistics< T > > OpenNN::Matrix< T >::scale_mean_standard_deviation ( void  )

Scales the data using the mean and standard deviation method and the mean and standard deviation values calculated from the matrix. It also returns the statistics of all the columns.

Definition at line 4073 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::scale_minimum_maximum ( const Vector< Statistics< T > > &  statistics)

Scales the matrix columns with the minimum and maximum method. It updates the data in the matrix.

Parameters
statisticsVector of statistics structures containing the minimum and maximum values for the scaling. The size of that vector must be equal to the number of columns in this matrix.

Definition at line 4197 of file matrix.h.

template<class T>
Vector< Statistics< T > > OpenNN::Matrix< T >::scale_minimum_maximum ( void  )

Scales the data using the minimum and maximum method and the minimum and maximum values calculated from the matrix. It also returns the statistics of all the columns.

Definition at line 4242 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::scale_rows_mean_standard_deviation ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  row_indices 
)

Scales given rows from the matrix using the mean and standard deviation method.

Parameters
statisticsVector of statistics for all the columns.
row_indicesIndices of rows to be scaled.

Definition at line 4090 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::scale_rows_minimum_maximum ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  row_indices 
)

Scales given rows from the matrix using the minimum and maximum method.

Parameters
statisticsVector of statistics for all the columns.
row_indicesIndices of rows to be scaled.

Definition at line 4259 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::set ( const size_t &  new_rows_number,
const size_t &  new_columns_number 
)

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

Parameters
new_rows_numberNumber of rows.
new_columns_numberNumber of columns.

Definition at line 1116 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set ( const size_t &  new_rows_number,
const size_t &  new_columns_number,
const T &  value 
)

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_numberNumber of rows.
new_columns_numberNumber of columns.
valueInitialization value.

Definition at line 1167 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set ( const Matrix< T > &  other_matrix)

Sets all the members of the matrix to those of another matrix.

Parameters
other_matrixSetting matrix.

Definition at line 1207 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set ( const std::string &  file_name)

Sets the members of this object by loading them from a data file.

Parameters
file_nameName of data file.

Definition at line 1227 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set_column ( const size_t &  column_index,
const Vector< T > &  new_column 
)

Sets new values of a single column in the matrix.

Parameters
column_indexIndex of column.
new_columnNew values of single column.

Definition at line 1774 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set_column ( const size_t &  column_index,
const T &  value 
)

Sets a new values of a single column in the matrix.

Parameters
column_indexIndex of column.
valueNew value of single column.

Definition at line 1822 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::set_columns_number ( const size_t &  new_columns_number)

Sets a new number of columns in the matrix.

Parameters
new_columns_numberNumber of matrix columns.

Definition at line 1267 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set_diagonal ( const T &  new_diagonal)

Sets a new value for the diagonal elements in the matrix. The matrix must be square.

Parameters
new_diagonalNew value of diagonal.

Definition at line 1858 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set_diagonal ( const Vector< T > &  new_diagonal)

Sets new values of the diagonal in the matrix. The matrix must be square.

Parameters
new_diagonalNew values of diagonal.

Definition at line 1893 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::set_identity ( const size_t &  new_size)

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

Parameters
new_sizeNew number of rows and columns in this matrix.

Definition at line 1239 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set_row ( const size_t &  row_index,
const Vector< T > &  new_row 
)

Sets new values of a single row in the matrix.

Parameters
row_indexIndex of row.
new_rowNew values of single row.

Definition at line 1691 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::set_row ( const size_t &  row_index,
const T &  value 
)

Sets a new value of a single row in the matrix.

Parameters
row_indexIndex of row.
valueNew value of single row.

Definition at line 1739 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::set_rows_number ( const size_t &  new_rows_number)

Sets a new number of rows in the matrix.

Parameters
new_rows_numberNumber of matrix rows.

Definition at line 1252 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::sort_greater ( const size_t &  )
Todo:
This method is not implemented.

Definition at line 2453 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::sort_less ( const size_t &  )
Todo:
This method is not implemented.

Definition at line 2442 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::subtract_column ( const size_t &  column_index)

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

Parameters
column_indexIndex of column to be removed.

Definition at line 2339 of file matrix.h.

template<class T >
void OpenNN::Matrix< T >::subtract_row ( const size_t &  row_index)

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

Parameters
row_indexIndex of row to be removed.

Definition at line 2283 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::sum_diagonal ( const T &  value) const

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

Parameters
valueNew summing value.

Definition at line 1992 of file matrix.h.

template<class T>
Matrix< T > OpenNN::Matrix< T >::sum_diagonal ( const Vector< T > &  new_summing_values) const

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

Parameters
new_summing_valuesVector of summing values.

Definition at line 2029 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::sum_row ( const size_t &  row_index,
const Vector< T > &  vector 
)

Sums the values of a given row with the values of a given vector. The size of the vector must be equal to the number of columns.

Definition at line 2791 of file matrix.h.

template<class T >
std::vector< T > OpenNN::Matrix< T >::to_std_vector ( void  ) const

Returns a std::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 6627 of file matrix.h.

template<class T >
std::string OpenNN::Matrix< T >::to_string ( const std::string &  separator = " ") const

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

Definition at line 6575 of file matrix.h.

template<class T >
Vector< T > OpenNN::Matrix< T >::to_vector ( void  ) const

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 6642 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::tuck_in ( const size_t &  row_position,
const size_t &  column_position,
const Matrix< T > &  other_matrix 
)

Tuck in another matrix starting from a given position.

Parameters
row_positionInsertion row position.
column_positionInsertion row position.
other_matrixMatrix to be inserted.

Definition at line 1284 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::unscale_columns_mean_standard_deviation ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  column_indices 
)

Scales given columns of this matrix with the mean and standard deviation method.

Parameters
statisticsVector of statistics structure containing the mean and standard deviation values for the scaling. The size of that vector must be equal to the number of columns in the matrix.
column_indicesVector of indices with the columns to be scaled. The size of that vector must be equal to the number of columns to be scaled.

Definition at line 4446 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::unscale_columns_minimum_maximum ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  column_indices 
)

Unscales given columns in the matrix with the minimum and maximum method.

Parameters
statisticsVector of statistics structures containing the minimum and maximum values for the unscaling. The size of that vector must be equal to the number of columns in the matrix.
column_indicesVector of indices of the columns to be unscaled. The size of that vector must be equal to the number of columns to be unscaled.

Definition at line 4577 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::unscale_mean_standard_deviation ( const Vector< Statistics< T > > &  statistics)

Unscales the matrix columns with the mean and standard deviation method. It updates the matrix elements.

Parameters
statisticsVector of statistics structures containing the mean and standard deviations for the unscaling. The size of that vector must be equal to the number of columns in this matrix.

Definition at line 4368 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::unscale_minimum_maximum ( const Vector< Statistics< T > > &  statistics)

Unscales the matrix columns with the minimum and maximum method.

Parameters
statisticsVector of statistics which contains the minimum and maximum scaling values. The size of that vector must be equal to the number of columns in this matrix.

Definition at line 4493 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::unscale_rows_mean_standard_deviation ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  row_indices 
)

Unscales given rows using the mean and standard deviation method.

Parameters
statisticsVector of statistics structures for all the columns. The size of this vector must be equal to the number of columns.
row_indicesIndices of rows to be unscaled.

Definition at line 4412 of file matrix.h.

template<class T>
void OpenNN::Matrix< T >::unscale_rows_minimum_maximum ( const Vector< Statistics< T > > &  statistics,
const Vector< size_t > &  row_indices 
)

Unscales given rows using the minimum and maximum method.

Parameters
statisticsVector of statistics structures for all the columns. The size of this vector must be equal to the number of columns.
row_indicesIndices of rows to be unscaled.

Definition at line 4542 of file matrix.h.


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