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
 
Matrix< T > sort_less_rows (const size_t &) const
 
Matrix< T > sort_greater_rows (const size_t &) const
 
void initialize (const T &)
 
void randomize_uniform (const double &=-1.0, const double &=1.0)
 
void randomize_uniform (const Vector< double > &, const Vector< double > &)
 
void randomize_uniform (const Matrix< double > &, const Matrix< double > &)
 
void randomize_normal (const double &=0.0, const double &=1.0)
 
void randomize_normal (const Vector< double > &, const Vector< double > &)
 
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< Vector< double > > calculate_shape_parameters (void) const
 
Vector< Vector< double > > calculate_shape_parameters_missing_values (const Vector< Vector< size_t > > &) const
 
Vector< Vector< double > > calculate_shape_parameters (const Vector< size_t > &, const Vector< size_t > &) const
 
Vector< Vector< double > > calculate_rows_shape_parameters (const Vector< size_t > &) const
 
Vector< Vector< double > > calculate_rows_shape_parameters_missing_values (const Vector< size_t > &, const Vector< Vector< size_t > > &) const
 
Vector< Vector< double > > calculate_columns_shape_parameters (const Vector< size_t > &) const
 
Vector< Vector< double > > calculate_columns_shape_parameters_missing_values (const Vector< size_t > &, const Vector< Vector< size_t > > &) const
 
Matrix< double > calculate_covariance_matrix (void) 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 > calculate_LU_inverse (void) const
 
Vector< T > solve_LDLT (const Vector< double > &) const
 
double calculate_distance (const size_t &, const size_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 &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< double > calculate_eigenvalues (void) const
 
Matrix< double > calculate_eigenvectors (void) 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
 
bool is_binary (void) const
 
bool is_column_binary (const size_t &) const
 
Matrix< T > filter (const size_t &, const T &, const T &) const
 
void convert_time_series (const size_t &)
 
void convert_association (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 load_binary (const std::string &)
 
void save (const std::string &) const
 
void save_binary (const std::string &) const
 
void save_csv (const std::string &, const Vector< std::string > &=Vector< 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

◆ Matrix() [1/4]

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

◆ Matrix() [2/4]

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

◆ Matrix() [3/4]

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

◆ Matrix() [4/4]

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

Member Function Documentation

◆ append_column()

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

◆ append_row()

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

◆ arrange_column() [1/2]

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

◆ arrange_column() [2/2]

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

◆ arrange_row() [1/2]

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

◆ arrange_row() [2/2]

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

◆ arrange_submatrix()

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

◆ arrange_submatrix_columns()

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

◆ arrange_submatrix_rows()

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

◆ assemble_columns()

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

◆ assemble_rows()

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

◆ calculate_columns_shape_parameters()

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

Returns the asymmetry and the kurtosis of given columns. The format is a vector of subvectors. 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 4297 of file matrix.h.

◆ calculate_columns_shape_parameters_missing_values()

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

Returns the asymmetry and the kurtosis of given columns when the matrix has missing values. The format is a vector of subvectors. 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 4328 of file matrix.h.

◆ calculate_columns_statistics()

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

◆ calculate_columns_statistics_missing_values()

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

◆ calculate_covariance_matrix()

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

Retruns the covariance matrix of this matrix. The number of columns and rows of the matrix is equal to the number of columns of this matrix.

Definition at line 4356 of file matrix.h.

◆ calculate_eigenvalues()

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

Calculates the eigen values of this matrix, which must be squared. Returns a matrix with only one column and rows the same as this matrix with the eigenvalues.

Definition at line 6514 of file matrix.h.

◆ calculate_eigenvectors()

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

Calculates the eigenvectors of this matrix, which must be squared. Returns a matrix whose columns are the eigenvectors.

Definition at line 6581 of file matrix.h.

◆ calculate_greater_than_indices()

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

◆ calculate_histograms()

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

◆ calculate_histograms_missing_values()

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

◆ calculate_inverse()

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

◆ calculate_less_than_indices()

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

◆ calculate_LU_inverse()

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

Returns the inverse of a square matrix using the LU decomposition method. The given matrix must be invertible.

Definition at line 5612 of file matrix.h.

◆ calculate_mean() [1/4]

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

◆ calculate_mean() [2/4]

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

◆ calculate_mean() [3/4]

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

◆ calculate_mean() [4/4]

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

◆ calculate_mean_missing_values() [1/2]

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

◆ calculate_mean_missing_values() [2/2]

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

◆ calculate_mean_standard_deviation() [1/3]

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

◆ calculate_mean_standard_deviation() [2/3]

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

◆ calculate_mean_standard_deviation() [3/3]

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

◆ calculate_minimal_maximal_indices()

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

◆ calculate_minimum_maximum() [1/3]

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

◆ calculate_minimum_maximum() [2/3]

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

◆ calculate_minimum_maximum() [3/3]

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

◆ calculate_rows_norm()

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

◆ calculate_rows_shape_parameters()

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

Returns the asymmetry and the kurtosis of all the columns for given rows. The format is a vector of subvectors. 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 4242 of file matrix.h.

◆ calculate_rows_shape_parameters_missing_values()

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

Returns the asymmetry and the kurtosis of all the columns for given rows when the matrix has missing values. The format is a vector of subvectors. 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 4270 of file matrix.h.

◆ calculate_rows_statistics()

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

◆ calculate_rows_statistics_missing_values()

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

◆ calculate_shape_parameters() [1/2]

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

Returns the asymmetry and the kurtosis of the columns. The format is a vector of subvectors. The size of that vector is equal to the number of columns in this matrix.

Definition at line 4114 of file matrix.h.

◆ calculate_shape_parameters() [2/2]

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

Returns the asymmetry and the kurtosis of given columns for given rows. The format is a vector of subvectors. 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 4210 of file matrix.h.

◆ calculate_shape_parameters_missing_values()

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

Returns the asymmetry and the kurtosis of the columns when the matrix has missing values. The format is a vector of subvectors. 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 4156 of file matrix.h.

◆ calculate_statistics() [1/2]

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

◆ calculate_statistics() [2/2]

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

◆ calculate_statistics_missing_values()

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

◆ calculate_sum_squared_error() [1/2]

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

◆ calculate_sum_squared_error() [2/2]

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

◆ calculate_trace()

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

◆ convert_angular_variables_degrees()

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

◆ convert_angular_variables_radians()

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

◆ convert_association()

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

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

Definition at line 7042 of file matrix.h.

◆ convert_time_series()

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

◆ count_diagonal_elements()

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

◆ count_off_diagonal_elements()

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

◆ direct()

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

◆ dot() [1/2]

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

◆ dot() [2/2]

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

◆ filter()

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

◆ initialize()

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

◆ initialize_diagonal() [1/3]

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

◆ initialize_diagonal() [2/3]

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

◆ initialize_diagonal() [3/3]

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

Sets the diagonal elements in the matrix with a given value and the rest elements with zeros. The matrix must be square.

Definition at line 2907 of file matrix.h.

◆ initialize_identity()

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

◆ insert_column()

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

◆ insert_row()

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

◆ is_antisymmetric()

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

◆ is_diagonal()

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

◆ is_identity()

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

◆ is_scalar()

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

◆ is_square()

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

◆ is_symmetric()

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

◆ load()

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

◆ load_binary()

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

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

Parameters
file_nameName of binary file.

Definition at line 7254 of file matrix.h.

◆ operator!=() [1/2]

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

◆ operator!=() [2/2]

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

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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

◆ operator*() [1/3]

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

◆ operator*() [2/3]

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

◆ operator*() [3/3]

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

◆ operator*=() [1/2]

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

◆ operator*=() [2/2]

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

◆ operator+() [1/3]

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

◆ operator+() [2/3]

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

◆ operator+() [3/3]

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

◆ operator+=() [1/2]

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

◆ operator+=() [2/2]

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

◆ operator-() [1/3]

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

◆ operator-() [2/3]

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

◆ operator-() [3/3]

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

◆ operator-=() [1/2]

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

◆ operator-=() [2/2]

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

◆ operator/() [1/3]

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

◆ operator/() [2/3]

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

◆ operator/() [3/3]

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

◆ operator/=() [1/2]

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

◆ operator/=() [2/2]

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

◆ operator<() [1/2]

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

◆ operator<() [2/2]

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

◆ operator<=() [1/2]

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

◆ operator<=() [2/2]

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

◆ operator=()

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

◆ operator==() [1/2]

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

◆ operator==() [2/2]

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

◆ operator>() [1/2]

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

◆ operator>() [2/2]

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

◆ operator>=() [1/2]

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

◆ operator>=() [2/2]

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

◆ parse()

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

◆ print_preview()

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

◆ randomize_normal() [1/3]

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

◆ randomize_normal() [2/3]

template<class T >
void OpenNN::Matrix< T >::randomize_normal ( const Vector< double > &  means,
const Vector< double > &  standard_deviations 
)

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

Parameters
meansMeans values of uniform distribution.
standard_deviationsStandard deviations values of uniform distribution.

Definition at line 2781 of file matrix.h.

◆ randomize_normal() [3/3]

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

◆ randomize_uniform() [1/3]

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

◆ randomize_uniform() [2/3]

template<class T >
void OpenNN::Matrix< T >::randomize_uniform ( const Vector< double > &  minimums,
const Vector< double > &  maximums 
)

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

Parameters
minimumsMinimum possible values.
maximumsMaximum possible values.

Definition at line 2652 of file matrix.h.

◆ randomize_uniform() [3/3]

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

◆ save()

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

◆ save_binary()

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

Saves the values of the matrix to a binary file.

Parameters
file_nameFile name.

Definition at line 7344 of file matrix.h.

◆ save_csv()

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

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

Parameters
file_nameFile name.
column_namesNames of the columns.

Definition at line 7394 of file matrix.h.

◆ scale_columns_mean_standard_deviation()

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

◆ scale_columns_minimum_maximum()

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

◆ scale_mean_standard_deviation() [1/2]

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

◆ scale_mean_standard_deviation() [2/2]

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

◆ scale_minimum_maximum() [1/2]

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

◆ scale_minimum_maximum() [2/2]

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

◆ scale_rows_mean_standard_deviation()

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

◆ scale_rows_minimum_maximum()

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

◆ set() [1/4]

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

◆ set() [2/4]

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

◆ set() [3/4]

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

◆ set() [4/4]

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

◆ set_column() [1/2]

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

◆ set_column() [2/2]

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

◆ set_columns_number()

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

◆ set_diagonal() [1/2]

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

◆ set_diagonal() [2/2]

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

◆ set_identity()

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

◆ set_row() [1/2]

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

◆ set_row() [2/2]

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

◆ set_rows_number()

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

◆ solve_LDLT()

template<class T >
Vector< T > OpenNN::Matrix< T >::solve_LDLT ( const Vector< double > &  b) const

Solve a sisem of the form Ax = b, using the Cholesky decomposition. A is this matrix and must be positive or negative semidefinite.

Parameters
bIndependent term of the system.

Definition at line 5660 of file matrix.h.

◆ sort_greater_rows()

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

Sorts the rows of the matrix in ascending order attending to the values of the column with given index. It returns a new sorted matrix, it does not change the original one.

Parameters
column_indexIndex of column to sort.

Definition at line 2516 of file matrix.h.

◆ sort_less_rows()

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

Sorts the rows of the matrix in descending order attending to the values of the column with given index. It returns a new sorted matrix, it does not change the original one.

Parameters
column_indexIndex of column to sort.

Definition at line 2476 of file matrix.h.

◆ subtract_column()

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

◆ subtract_row()

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

◆ sum_diagonal() [1/2]

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

◆ sum_diagonal() [2/2]

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

◆ sum_row()

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

◆ to_std_vector()

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

◆ to_string()

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

◆ to_vector()

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

◆ tuck_in()

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

◆ unscale_columns_mean_standard_deviation()

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

Unscales 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 unscaled. The size of that vector must be equal to the number of columns to be scaled.

Definition at line 4962 of file matrix.h.

◆ unscale_columns_minimum_maximum()

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

◆ unscale_mean_standard_deviation()

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

◆ unscale_minimum_maximum()

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

◆ unscale_rows_mean_standard_deviation()

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

◆ unscale_rows_minimum_maximum()

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


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