Matrix< T > Class Template Reference

This template class defines a matrix for general purpose use. More...

#include <matrix.h>

Inheritance diagram for Matrix< T >:

Public Member Functions

 Matrix ()
 Default constructor. It creates a matrix with zero rows and zero columns.
 
 Matrix (const size_t &, const size_t &)
 
 Matrix (const size_t &, const size_t &, const T &)
 
 Matrix (const string &, const char &, const bool &)
 
 Matrix (const Matrix &)
 
 Matrix (const initializer_list< Vector< T >> &)
 
 Matrix (const initializer_list< Vector< T >> &, const initializer_list< string > &)
 
virtual ~Matrix ()
 Destructor.
 
Matrix< T > & operator= (const Matrix< T > &)
 
T & operator() (const size_t &, const size_t &)
 Reference operator. More...
 
const T & operator() (const size_t &, const size_t &) const
 Reference operator. More...
 
T & operator() (const size_t &, const string &)
 
const T & operator() (const size_t &, const string &) const
 Reference operator.
 
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
 
Matrix< T > operator+ (const T &) const
 
Matrix< T > operator+ (const Matrix< T > &) const
 
Matrix< T > operator- (const T &scalar) const
 
Matrix< T > operator- (const Matrix< T > &) const
 
Matrix< T > operator* (const T &) const
 
Matrix< T > operator* (const Matrix< T > &) const
 
Matrix< T > operator* (const Tensor< 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 > &)
 
const size_t & get_rows_number () const
 Returns the number of rows in the matrix.
 
const size_t & get_columns_number () const
 Returns the number of columns in the matrix.
 
const Vector< string > get_header () const
 Returns a string vector with the header.
 
const string get_header (const size_t &) const
 
size_t get_column_index (const string &) const
 
Vector< size_t > get_columns_indices (const Vector< string > &) const
 
Vector< size_t > get_binary_columns_indices () const
 Returns a vector with the index of the binary columns.
 
Vector< size_t > get_rows_equal_to (const Vector< T > &) const
 
Matrix< T > get_submatrix (const Vector< size_t > &, const Vector< size_t > &) const
 
Tensor< T > get_tensor (const Vector< size_t > &, const Vector< size_t > &, const Vector< size_t > &) const
 
Matrix< T > get_submatrix_rows (const Vector< size_t > &) const
 
Matrix< T > get_submatrix_columns (const Vector< size_t > &) const
 
Vector< T > get_row (const size_t &) const
 
Vector< T > get_rows (const size_t &, const size_t &) const
 
Vector< T > get_row (const size_t &, const Vector< size_t > &) const
 
Vector< T > get_column (const size_t &) const
 
Vector< T > get_column (const string &) const
 
Matrix< T > get_columns (const Vector< string > &) const
 
Vector< T > get_column (const size_t &, const Vector< size_t > &) const
 
Vector< T > get_diagonal () const
 Returns the diagonal of the matrix.
 
get_first (const size_t &) const
 
get_first (const string &) const
 
get_last (const size_t &) const
 
get_last (const string &) const
 
Vector< size_t > get_constant_columns_indices () const
 Returns a indices vector with the index of columns that are constant.
 
Matrix< T > get_first_rows (const size_t &) const
 
Matrix< T > get_first_columns (const size_t &) const
 
Matrix< T > get_last_columns (const size_t &) const
 
Matrix< T > get_last_rows (const size_t &) const
 
void set ()
 This method set the numbers of rows and columns of the matrix to zero.
 
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 string &)
 
void set (const initializer_list< Vector< T >> &)
 Set the columns of the matrix.
 
void set_identity (const size_t &)
 
void set_rows_number (const size_t &)
 
void set_columns_number (const size_t &)
 
void set_header (const Vector< string > &)
 
void set_header (const size_t &, const string &)
 
void set_row (const size_t &, const Vector< T > &)
 
void set_row (const size_t &, const T &)
 
void set_submatrix_rows (const size_t &, const Matrix< T > &)
 
void set_column (const size_t &, const Vector< T > &, const string &="")
 
void set_column (const string &, const Vector< T > &, const string &="")
 
void set_column (const string &, const T &, const string &="")
 
void set_column (const size_t &, const T &, const string &="")
 
void set_diagonal (const T &)
 
void set_diagonal (const Vector< T > &)
 
bool empty () const
 Returns true if number of rows and columns is zero.
 
bool is_square () const
 
bool is_symmetric () const
 
bool is_antisymmetric () const
 
bool is_diagonal () const
 
bool is_scalar () const
 
bool is_identity () const
 
bool is_binary () const
 Returns true if this matrix has binary values.
 
bool is_column_binary (const size_t &) const
 Returns true if a column this matrix has binary values.
 
bool is_column_constant (const size_t &) const
 
bool is_positive () const
 Return true if all the elements of the matrix are positive. False otherwhise.
 
bool is_row_equal_to (const size_t &, const Vector< size_t > &, const T &) const
 
bool has_column_value (const size_t &, const T &) const
 
size_t count_diagonal_elements () const
 
size_t count_off_diagonal_elements () const
 
size_t count_equal_to (const T &) const
 
size_t count_equal_to (const size_t &, const T &) const
 
size_t count_equal_to (const size_t &, const Vector< T > &) const
 
size_t count_equal_to (const size_t &, const Vector< T > &, const size_t &, const T &) const
 
size_t count_equal_to (const size_t &, const Vector< T > &, const size_t &, const T &, const size_t &, const T &, const size_t &, const T &) const
 
size_t count_equal_to (const size_t &, const T &, const size_t &, const T &) const
 
size_t count_equal_to (const size_t &, const T &, const size_t &, const T &, const size_t &, const T &, const size_t &, const T &) const
 
size_t count_equal_to (const string &, const T &) const
 
size_t count_equal_to (const string &, const Vector< T > &) const
 
size_t count_equal_to (const string &, const T &, const string &, const T &) const
 
Vector< size_t > count_equal_to_by_rows (const T &) const
 
Vector< double > count_equal_to_by_rows (const T &, const Vector< double > &) const
 
size_t count_not_equal_to (const T &) const
 
size_t count_not_equal_to (const size_t &, const T &) const
 
size_t count_not_equal_to (const size_t &, const Vector< T > &) const
 
size_t count_not_equal_to (const size_t &, const T &, const size_t &, const T &) const
 
size_t count_not_equal_to (const string &, const T &) const
 
size_t count_not_equal_to (const string &, const T &, const string &, const T &) const
 
size_t count_rows_equal_to (const T &) const
 
size_t count_rows_not_equal_to (const T &) const
 
size_t count_rows_equal_to (const Vector< size_t > &, const T &) const
 
size_t count_columns_equal_to (const Vector< T > &, const T &) const
 
Vector< size_t > count_unique_elements () const
 Return the number of elements that are unquique in eacher column of the matrix.
 
Vector< size_t > count_column_occurrences (const T &) const
 Return the times that a given value is contain in each column of hte matrix.
 
bool has_nan () const
 Returns true if matrix contains nan, and false otherwise.
 
bool has_nan_row (const size_t &) const
 
bool has_nan_column (const size_t &) const
 
size_t count_nan () const
 Returns the number of elements that contains nan.
 
size_t count_not_NAN () const
 Returns the number of elements that not contains nan.
 
size_t count_rows_with_nan () const
 Returns the number of rows which contains at least one nan.
 
Vector< size_t > get_nan_indices () const
 Returns the number of rows which contains at least one nan.
 
size_t count_columns_with_nan () const
 Returns the number of columns which contains at least one nan.
 
Vector< size_t > count_nan_rows () const
 
Vector< size_t > count_nan_columns () const
 
void filter (const T &, const T &)
 
Matrix< T > filter_column_equal_to (const size_t &, const T &) const
 
Matrix< T > filter_column_equal_to (const string &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_equal_to (const size_t &, const Vector< T > &) const
 
Matrix< T > filter_column_equal_to (const string &, const Vector< T > &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_equal_to (const size_t &, const Vector< T > &, const size_t &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_equal_to (const string &, const Vector< T > &, const string &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_equal_to (const size_t &, const T &, const size_t &, const T &, const size_t &, const T &, const size_t &, const T &) const
 Returns a new matrix where certain columns has been filtered.
 
Matrix< T > filter_column_equal_to (const string &, const T &, const string &, const T &, const string &, const T &, const string &, const T &) const
 Returns a new matrix where certain columns has been filtered.
 
Matrix< T > filter_column_equal_to (const size_t &, const Vector< T > &, const size_t &, const T &, const size_t &, const T &, const size_t &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_equal_to (const string &, const Vector< T > &, const string &, const T &, const string &, const T &, const string &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_not_equal_to (const size_t &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_not_equal_to (const string &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_not_equal_to (const string &, const Vector< T > &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_not_equal_to (const size_t &, const Vector< T > &) const
 
Matrix< T > filter_column_less_than (const size_t &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_less_than (const string &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_greater_than (const size_t &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_greater_than (const string &, const T &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_less_than_string (const string &, const double &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_greater_than_string (const string &, const double &) const
 Returns a new matrix where a given column has been filtered.
 
Matrix< T > filter_column_minimum_maximum (const size_t &, const T &, const T &) const
 
Matrix< T > filter_column_minimum_maximum (const string &, const T &, const T &) const
 
Matrix< T > filter_extreme_values (const size_t &, const double &, const double &) const
 
Matrix< T > filter_extreme_values (const string &, const double &, const double &) const
 
void initialize (const T &)
 
void initialize_sequential ()
 Initializes all the elements of the matrix in a sequential order (0, 1, 2...).
 
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 initialize_diagonal (const T &)
 
void initialize_diagonal (const size_t &, const T &)
 
void initialize_diagonal (const size_t &, const Vector< T > &)
 
void append_header (const string &)
 Append a string in all the elememts of the header.
 
void embed (const size_t &, const size_t &, const Matrix< T > &)
 
void embed (const size_t &, const size_t &, const Vector< T > &)
 
void sum_diagonal (const T &)
 
void multiply_diagonal (const T &)
 
void sum_diagonal (const Vector< T > &)
 
Matrix< T > append_row (const Vector< T > &) const
 
Matrix< T > append_column (const Vector< T > &, const string &="") const
 
Matrix< T > insert_row (const size_t &, const Vector< T > &) const
 
void insert_row_values (const size_t &, const size_t &, const Vector< T > &)
 
Matrix< T > insert_column (const size_t &, const Vector< T > &, const string &="") const
 
Matrix< T > insert_column (const string &, const Vector< T > &, const string &="") const
 
Matrix< T > insert_matrix (const size_t &, const Matrix< T > &) const
 
Matrix< T > insert_padding (const size_t &, const size_t &) const
 
Matrix< T > add_columns (const size_t &) const
 
Matrix< T > add_columns_first (const size_t &) const
 
void split_column (const string &, const Vector< string > &, const char &=',', const string &="NA")
 
void split_column (const string &, const string &, const string &, const size_t &, const size_t &)
 
void swap_columns (const size_t &, const size_t &)
 
void swap_columns (const string &, const string &)
 
void merge_columns (const string &, const string &, const string &, const char &)
 
void merge_columns (const size_t &, const size_t &, const char &)
 
Matrix< T > merge_matrices (const Matrix< T > &, const string &, const string &, const string &="", const string &="") const
 
Matrix< T > merge_matrices (const Matrix< T > &, const size_t &, const size_t &) const
 
Matrix< T > right_join (const Matrix< T > &, const string &, const string &, const string &="", const string &="") const
 
Matrix< T > right_join (const Matrix< T > &, const size_t &, const size_t &) const
 
Matrix< T > left_join (const Matrix< T > &, const string &, const string &, const string &="", const string &="") const
 
Matrix< T > left_join (const Matrix< T > &, const string &, const string &, const string &, const string &, const string &="", const string &="") const
 
Matrix< T > left_join (const Matrix< T > &, const size_t &, const size_t &) const
 
Matrix< T > delete_row (const size_t &) const
 
Matrix< T > delete_rows (const Vector< size_t > &) const
 
Matrix< T > delete_rows_with_value (const T &) const
 
Matrix< T > delete_columns_with_value (const T &) const
 
Matrix< T > delete_rows_equal_to (const T &) const
 
Matrix< T > delete_first_rows (const size_t &) const
 
Matrix< T > delete_last_rows (const size_t &) const
 
Matrix< T > delete_first_columns (const size_t &) const
 
Matrix< T > delete_last_columns (const size_t &) const
 
Matrix< T > delete_column (const size_t &) const
 
Matrix< T > delete_columns (const Vector< size_t > &) const
 
Matrix< T > delete_column (const string &) const
 
Matrix< T > delete_columns (const Vector< string > &) const
 
Matrix< T > delete_columns_name_contains (const Vector< string > &) const
 
Matrix< T > delete_constant_rows () const
 
Matrix< T > delete_constant_columns () const
 
Matrix< T > delete_binary_columns () const
 
Matrix< T > delete_binary_columns (const double &) const
 
Matrix< T > assemble_rows (const Matrix< T > &) const
 
Matrix< T > assemble_columns (const Matrix< T > &) const
 
Matrix< T > sort_ascending (const size_t &) const
 
Matrix< T > sort_descending (const size_t &) const
 
Matrix< T > sort_ascending_strings (const size_t &) const
 
Matrix< T > sort_descending_strings (const size_t &) const
 
Matrix< T > sort_rank_rows (const Vector< size_t > &) const
 
Matrix< T > sort_columns (const Vector< size_t > &) const
 
Matrix< T > sort_columns (const Vector< string > &) const
 
void replace (const T &, const T &)
 
void replace_header (const string &, const string &)
 
void replace_in_row (const size_t &, const T &, const T &)
 
void replace_in_column (const size_t &, const T &, const T &)
 
void replace_in_column (const string &, const T &, const T &)
 
void replace_substring (const string &, const string &)
 
void replace_substring (const size_t &, const string &, const string &)
 
void replace_substring (const string &, const string &, const string &)
 
void replace_contains (const string &, const string &)
 
void replace_contains_in_row (const size_t &, const string &, const string &)
 
void replace_column_equal_to (const size_t &, const T &, const T &)
 
void replace_column_equal_to (const string &, const T &, const T &)
 
void replace_column_not_equal_to (const string &, const T &, const T &)
 
void replace_column_not_equal_to (const string &, const Vector< T > &, const T &)
 
void replace_column_less_than_string (const string &, const double &, const T &)
 
void replace_column_contains (const string &, const string &, const string &)
 
size_t count_column_contains (const string &, const string &) const
 
calculate_sum () const
 Returns the sum of all the elements in the matrix.
 
Vector< T > calculate_rows_sum () const
 Returns the sum of all the rows in the matrix.
 
Vector< T > calculate_columns_sum () const
 Returns the sum of all the columns in the matrix.
 
calculate_column_sum (const size_t &) const
 
calculate_row_sum (const size_t &) const
 
void sum_row (const size_t &, const Vector< T > &)
 
void sum_column (const size_t &, const Vector< T > &)
 
Matrix< T > sum_rows (const Vector< T > &) const
 
Matrix< T > subtract_rows (const Vector< T > &) const
 
Matrix< T > multiply_rows (const Vector< T > &) const
 
Vector< Matrix< T > > multiply_rows (const Matrix< T > &) const
 
double calculate_trace () const
 
Vector< double > calculate_missing_values_percentage () const
 Returns the percentage of missing values in each column.
 
Matrix< size_t > get_indices_less_than (const T &) const
 
Matrix< size_t > get_indices_greater_than (const T &) const
 
Matrix< T > calculate_reverse_columns () const
 Return a matrix the elements of the matrix changes. The last one will be the first.
 
Matrix< T > calculate_transpose () const
 Returns the transpose of the matrix.
 
bool compare_rows (const size_t &, const Matrix< T > &, const size_t &) const
 
void divide_rows (const Vector< T > &)
 
string matrix_to_string (const char &=' ') const
 
Matrix< size_t > to_size_t_matrix () const
 Returns a size_t representation of this matrix.
 
Matrix< float > to_float_matrix () const
 Returns a float representation of this matrix.
 
Matrix< double > to_double_matrix () const
 Returns a double representation of this matrix.
 
Matrix< string > to_string_matrix (const size_t &=3) const
 Returns a new matrix in which each entry has been converted to a string.
 
Matrix< double > to_zeros () const
 Set the elements of the matrix to zero.
 
Matrix< double > to_ones () const
 Set the elements of the matrix to zero.
 
Matrix< double > bool_to_double () const
 Returns a double representation of this bool matrix.
 
Matrix< size_t > string_to_size_t () const
 Returns a size_t representation of this string matrix.
 
Matrix< double > string_to_double () const
 Returns a double representation of this string matrix.
 
vector< T > to_std_vector () const
 
Vector< T > to_vector () const
 
Vector< Vector< T > > to_vector_of_vectors () const
 
Vector< Matrix< T > > to_vector_matrix (const size_t &, const size_t &, const size_t &) const
 
Matrix< T > to_categorical (const size_t &) const
 
Tensor< T > to_tensor () const
 
void print () const
 Prints to the screen in the matrix object.
 
void load_csv (const string &, const char &=',', const bool &=false, const string &="NA")
 
void load_csv_string (const string &, const char &=',', const bool &=true)
 
void load_binary (const string &)
 
void save_binary (const string &) const
 
void save_csv (const string &, const char &=',', const Vector< string > &=Vector< string >(), const string &="Id") const
 
void save_json (const string &, const Vector< string > &=Vector< string >()) const
 
void parse (const string &)
 
void print_preview () const
 

Private Attributes

size_t rows_number
 Number of rows in the matrix.
 
size_t columns_number
 Number of columns in the matrix.
 
Vector< string > header
 Header with names of columns.
 

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

Constructor & Destructor Documentation

◆ Matrix() [1/4]

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

◆ Matrix() [2/4]

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

◆ Matrix() [3/4]

Matrix ( const string &  file_name,
const char &  separator,
const bool &  header 
)
explicit

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

Parameters
file_nameName of matrix data file.
separatorSeparator type: ';' , ',', '/'.
headerIf matrix contains header write true, and false otherwise.

Definition at line 716 of file matrix.h.

◆ Matrix() [4/4]

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

Member Function Documentation

◆ add_columns()

Matrix< T > add_columns ( const size_t &  columns_to_add) const

Add a new columns. Note that this method resizes the matrix, which can be computationally expensive.

Parameters
columns_to_addNumber of columns to add.

Definition at line 3819 of file matrix.h.

◆ add_columns_first()

Matrix< T > add_columns_first ( const size_t &  columns_to_add) const

Add a new columns at the beginning of the matrix. Note that this method resizes the matrix, which can be computationally expensive.

Parameters
columns_to_addNumber of columns to add.

Definition at line 3849 of file matrix.h.

◆ append_column()

Matrix< T > append_column ( const Vector< T > &  new_column,
const string &  new_name = "" 
) const

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.
new_nameName to the new column to be append.

Definition at line 3516 of file matrix.h.

◆ append_row()

Matrix< T > append_row ( const Vector< T > &  new_row) const

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

◆ assemble_columns()

Matrix< T > assemble_columns ( const Matrix< T > &  other_matrix) const

Assemble two matrices by columns.

Parameters
other_matrixmatrix to be get_assembled to this matrix.

Definition at line 5413 of file matrix.h.

◆ assemble_rows()

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

◆ calculate_column_sum()

T calculate_column_sum ( const size_t &  column_index) const

Returns the sum of a selected column in the matrix.

Parameters
calculate_column_sumColumn chosen to calculate its sum.

Definition at line 6225 of file matrix.h.

◆ calculate_row_sum()

T calculate_row_sum ( const size_t &  row_index) const

Returns the sum of a selected row in the matrix.

Parameters
calculate_column_sumRow chosen to calculate its sum.

Definition at line 6242 of file matrix.h.

◆ calculate_trace()

double calculate_trace ( ) 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 6458 of file matrix.h.

◆ compare_rows()

bool compare_rows ( const size_t &  row_index,
const Matrix< T > &  other_matrix,
const size_t &  other_row_index 
) const

Compare two rows of two different matrix. It doen't have to be the same row.

Parameters
row_indexIndex of the row of the first row.
other_matrixThe other matrix to compare.
other_row_indexIndez of the row of the second row.

Definition at line 7420 of file matrix.h.

◆ count_column_contains()

size_t count_column_contains ( const string &  column_name,
const string &  find_what 
) const

Returns the number of columns that have a sting given to the function

Parameters
column_nameHeader of the column where the function is going to compare
find_whatString to find in the matrix

Definition at line 5768 of file matrix.h.

◆ count_diagonal_elements()

size_t count_diagonal_elements ( ) const

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

Definition at line 1791 of file matrix.h.

◆ count_equal_to() [1/10]

size_t count_equal_to ( const size_t &  column_index,
const T &  value 
) const

Returns the number of elements in a given column that are equal to a given value.

Parameters
column_indexIndex of column.
valueValue to find.

Definition at line 1888 of file matrix.h.

◆ count_equal_to() [2/10]

size_t count_equal_to ( const size_t &  column_1_index,
const T &  value_1,
const size_t &  column_2_index,
const T &  value_2 
) const

Looks for elements that have a given value in one column, and another given value in another column. It returns the number of elements found.

Parameters
column_1_indexIndex of a column.
value_1Value to be found in the column above.
column_2_indexIndex of another column.
value_2Value to be found in the column above.

Definition at line 2028 of file matrix.h.

◆ count_equal_to() [3/10]

size_t count_equal_to ( const size_t &  column_1_index,
const T &  value_1,
const size_t &  column_2_index,
const T &  value_2,
const size_t &  column_3_index,
const T &  value_3,
const size_t &  column_4_index,
const T &  value_4 
) const

Looks for elements that have given values in 4 different columns. It returns the number of elements found.

Parameters
column_1_indexIndex of a column.
value_1Value to be found in the column above.
column_2_indexIndex of another column.
value_2Value to be found in the column above.
column_3_indexIndex of another column.
value_3Value to be found in the column above.
column_4_indexIndex of another column.
value_4Value to be found in the column above.

Definition at line 2058 of file matrix.h.

◆ count_equal_to() [4/10]

size_t count_equal_to ( const size_t &  column_index,
const Vector< T > &  values 
) const

Returns the number of elements in a given column that are equal to a given set of values.

Parameters
column_indexIndex of column.
valuesVector of values.

Definition at line 1909 of file matrix.h.

◆ count_equal_to() [5/10]

size_t count_equal_to ( const size_t &  column_1_index,
const Vector< T > &  values_1,
const size_t &  column_2_index,
const T &  value_2 
) const

Looks for elements that have a given set of values in one column and a a given value in another column, and returns the number of elements found.

Parameters
column_indexIndex of a column.
valuesVector of values to be found in the column above.
column_indexIndex of another column.
valueValue to be found in the column above.

Definition at line 1940 of file matrix.h.

◆ count_equal_to() [6/10]

size_t count_equal_to ( const size_t &  column_1_index,
const Vector< T > &  values_1,
const size_t &  column_2_index,
const T &  value_2,
const size_t &  column_3_index,
const T &  value_3,
const size_t &  column_4_index,
const T &  value_4 
) const

Looks for elements that have a given set of values in one column, and given values in another three columns. It returns the number of elements found.

Parameters
column_1_indexIndex of a column.
values_1Vector of values to be found in the column above.
column_2_indexIndex of another column.
value_2Value to be found in the column above.
column_3_indexIndex of another column.
value_3Value to be found in the column above.
column_4_indexIndex of another column.
value_4Value to be found in the column above.

Definition at line 1984 of file matrix.h.

◆ count_equal_to() [7/10]

size_t count_equal_to ( const string &  column_name,
const T &  value 
) const

Looks for elements that have a given value in one column. It returns the number of elements found.

Parameters
column_1_nameName of a column.
valueValue to be found in the column above.

Definition at line 2086 of file matrix.h.

◆ count_equal_to() [8/10]

size_t count_equal_to ( const string &  column_1_name,
const T &  value_1,
const string &  column_2_name,
const T &  value_2 
) const

Looks for elements that have a given value in one column, and another given value in another column. It returns the number of elements found.

Parameters
column_1_nameName of a column.
value_1Value to be found in the column above.
column_2_nameName of another column.
value_2Value to be found in the column above.

Definition at line 2117 of file matrix.h.

◆ count_equal_to() [9/10]

size_t count_equal_to ( const string &  column_name,
const Vector< T > &  values 
) const

Looks for elements that have a given values in one column. It returns the number of elements found.

Parameters
column_1_nameName of a column.
valuesValues to be found in the column above.

Definition at line 2100 of file matrix.h.

◆ count_equal_to() [10/10]

size_t count_equal_to ( const T &  value) const

Returns the number of elements in a given column that are equal to a given value.

Parameters
valueValue to find.

Definition at line 1864 of file matrix.h.

◆ count_equal_to_by_rows() [1/2]

Vector< size_t > count_equal_to_by_rows ( const T &  value) const

Looks for elements that have a given value in all rows, row a row. It returns a vector with the number of elements found, each vector element correponds with the number of elements that contains given value in one row.

Parameters
valueValue to be found in the rows.

Definition at line 2133 of file matrix.h.

◆ count_equal_to_by_rows() [2/2]

Vector< double > count_equal_to_by_rows ( const T &  value,
const Vector< double > &  weights 
) const

Looks for elements that have a given value in all rows, row a row. It returns a vector with the number of elements found, each vector element correponds with the number of elements that contains given value in one row.

Parameters
valueValue to be found in the rows.
weightsWeights asigned to each row.

Definition at line 2153 of file matrix.h.

◆ count_nan_columns()

Vector< size_t > count_nan_columns ( ) const

Return a vector with each element represent the number of nan that contain each column. Note the vector is the same dimesion that the column number of the matrix.

Definition at line 2943 of file matrix.h.

◆ count_nan_rows()

Vector< size_t > count_nan_rows ( ) const

Return a vector with each element represent the number of nan that contain each row. Note the vector is the same dimenssion that the rows number of the matrix.

Definition at line 2922 of file matrix.h.

◆ count_not_equal_to() [1/6]

size_t count_not_equal_to ( const size_t &  column_index,
const T &  value 
) const

Returns the number of elements in a given column that are equal to a given value.

Parameters
column_indexIndex of column.
valueValue to find.

Definition at line 2183 of file matrix.h.

◆ count_not_equal_to() [2/6]

size_t count_not_equal_to ( const size_t &  column_1_index,
const T &  value_1,
const size_t &  column_2_index,
const T &  value_2 
) const

Looks for elements that not have a given value in one column, and another given value in another column. It returns the number of elements found.

Parameters
column_1_indexIndex of a column.
value_1Value to be found in the column above.
column_2_indexIndex of another column.
value_2Value to be found in the column above.

Definition at line 2241 of file matrix.h.

◆ count_not_equal_to() [3/6]

size_t count_not_equal_to ( const size_t &  column_index,
const Vector< T > &  values 
) const

Returns the number of elements in a given column that are not equal to a given set of values.

Parameters
column_indexIndex of column.
valuesVector of values.

Definition at line 2204 of file matrix.h.

◆ count_not_equal_to() [4/6]

size_t count_not_equal_to ( const string &  column_name,
const T &  value 
) const

Returns the number of elements in a given column that are not equal to a given value.

Parameters
column_nameName of column.
valueValue to find.

Definition at line 2263 of file matrix.h.

◆ count_not_equal_to() [5/6]

size_t count_not_equal_to ( const string &  column_1_name,
const T &  value_1,
const string &  column_2_name,
const T &  value_2 
) const

Looks for elements that not have a given value in one column, and another given value in another column. It returns the number of elements found.

Parameters
column_1_nameName of a column.
value_1Value to be found in the column above.
column_2_nameName of another column.
value_2Value to be found in the column above.

Definition at line 2280 of file matrix.h.

◆ count_not_equal_to() [6/6]

size_t count_not_equal_to ( const T &  value) const

Returns the number of elements in a given column that are not equal to a given value.

Parameters
valueValue to find.

Definition at line 2170 of file matrix.h.

◆ count_off_diagonal_elements()

size_t count_off_diagonal_elements ( ) const

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

Definition at line 1826 of file matrix.h.

◆ count_rows_equal_to() [1/2]

size_t count_rows_equal_to ( const T &  value) const

Looks for elements that have a given value in all rows, row a row. It returns the number of rows that all columns contains a given value.

Parameters
valueValue to be found in the rows.

Definition at line 2295 of file matrix.h.

◆ count_rows_equal_to() [2/2]

size_t count_rows_equal_to ( const Vector< size_t > &  columns_indices,
const T &  value 
) const

Looks for elements that have a given value in all rows, row a row. It returns the number of rows that given columns contains this value.

Parameters
columns_indicesVector of column indices to check.
valueValue to be found in the rows.

Definition at line 2361 of file matrix.h.

◆ count_rows_not_equal_to()

size_t count_rows_not_equal_to ( const T &  value) const

Looks for elements that not have a given value in all rows, row a row. It returns the number of rows that all columns contains a given value.

Parameters
valueValue to be found in the rows.

Definition at line 2321 of file matrix.h.

◆ delete_binary_columns() [1/2]

Matrix< T > delete_binary_columns ( ) const

This method remove the columns that are binary. Note that resizing is here necessary and this method can be very inefficient.

Definition at line 5053 of file matrix.h.

◆ delete_binary_columns() [2/2]

Matrix< T > delete_binary_columns ( const double &  minimum_support) const

This method remove the columns that are binary. Note that resizing is here necessary and this method can be very inefficient.

Definition at line 5065 of file matrix.h.

◆ delete_column() [1/2]

Matrix< T > delete_column ( const size_t &  column_index) const

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

◆ delete_column() [2/2]

Matrix< T > delete_column ( const string &  column_name) const

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

Parameters
column_nameName of column to be removed.

Definition at line 4917 of file matrix.h.

◆ delete_columns() [1/2]

Matrix< T > delete_columns ( const Vector< size_t > &  delete_indices) const

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

Parameters
delete_indicesIndices vector that contains the column indices to be removed.

Definition at line 4949 of file matrix.h.

◆ delete_columns() [2/2]

Matrix< T > delete_columns ( const Vector< string > &  delete_names) const

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

Parameters
delete_namesNames vector that contains the columns names to be removed.

Definition at line 4986 of file matrix.h.

◆ delete_columns_name_contains()

Matrix< T > delete_columns_name_contains ( const Vector< string > &  substrings) const

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

Parameters
substringSubstring to be removed.

Definition at line 4999 of file matrix.h.

◆ delete_columns_with_value()

Matrix< T > delete_columns_with_value ( const T &  value) const

This method removes the columns that contains a given value. Note that resizing is here necessary and this method can be very inefficient.

Parameters
valueValue to be removed.

Definition at line 4645 of file matrix.h.

◆ delete_constant_columns()

Matrix< T > delete_constant_columns ( ) const

This method remove the columns that are constant. Note that resizing is here necessary and this method can be very inefficient.

Definition at line 5043 of file matrix.h.

◆ delete_constant_rows()

Matrix< T > delete_constant_rows ( ) const

This method remove the rows that are constant. Note that resizing is here necessary and this method can be very inefficient.

Definition at line 5088 of file matrix.h.

◆ delete_first_columns()

Matrix< T > delete_first_columns ( const size_t &  number) const

This method removes the first columns. Note that resizing is here necessary.

Parameters
numberNumber of the first columns to be removed.

Definition at line 4718 of file matrix.h.

◆ delete_first_rows()

Matrix< T > delete_first_rows ( const size_t &  number) const

This method removes the first rows. Note that resizing is here necessary.

Parameters
numberNumber of the first rows to be removed.

Definition at line 4705 of file matrix.h.

◆ delete_last_columns()

Matrix< T > delete_last_columns ( const size_t &  number) const

This method remove the last columns of the matrix. Note that resizing is here necessary and this method can be very inefficient.

Parameters
numberNumber of columns to be removed.

Definition at line 4813 of file matrix.h.

◆ delete_last_rows()

Matrix< T > delete_last_rows ( const size_t &  number) const

This method remove the last rows of the matrix. Note that resizing is here necessary and this method can be very inefficient.

Parameters
numberNumber of rows to be removed.

Definition at line 4800 of file matrix.h.

◆ delete_row()

Matrix< T > delete_row ( const size_t &  row_index) const

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

◆ delete_rows()

Matrix< T > delete_rows ( const Vector< size_t > &  rows_to_remove) const

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

Parameters
row_to_removeIndices of rows to be removed.

Definition at line 4567 of file matrix.h.

◆ delete_rows_equal_to()

Matrix< T > delete_rows_equal_to ( const T &  value) const

This method removes the rows that contains a given value. Note that resizing is here necessary.

Parameters
valueValue to be removed.

Definition at line 4692 of file matrix.h.

◆ delete_rows_with_value()

Matrix< T > delete_rows_with_value ( const T &  value) const

This method removes the rows that contains a given value. Note that resizing is here necessary and this method can be very inefficient.

Parameters
valueValue to be removed.

Definition at line 4598 of file matrix.h.

◆ divide_rows()

void divide_rows ( const Vector< T > &  vector)

Divide the rows of the matrix for a vector given to the function Notice that the rows of the matrix and the vector must have the same size.

Definition at line 6633 of file matrix.h.

◆ embed() [1/2]

void embed ( 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 1703 of file matrix.h.

◆ embed() [2/2]

void embed ( const size_t &  row_position,
const size_t &  column_position,
const Vector< T > &  other_vector 
)

Tuck in a vector to a given row of the matrix

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

Definition at line 1750 of file matrix.h.

◆ filter()

void filter ( const T &  minimum,
const T &  maximum 
)

Filter a matrix between two values.

Parameters
minimumMinimum value allowed to the elements to not be filter.
maximunMaximum value allowed to the elements to not be filter.

Definition at line 6665 of file matrix.h.

◆ filter_column_equal_to() [1/2]

Matrix< T > filter_column_equal_to ( const size_t &  column_index,
const T &  value 
) const

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

Parameters
column_indexIndex of column.
valueFiltering value.

Definition at line 7552 of file matrix.h.

◆ filter_column_equal_to() [2/2]

Matrix< T > filter_column_equal_to ( const size_t &  column_index,
const Vector< T > &  values 
) const

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

Parameters
column_indexIndex of column.
valueVector to filtering value.

Definition at line 7642 of file matrix.h.

◆ filter_column_minimum_maximum()

Matrix< T > filter_column_minimum_maximum ( 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 7485 of file matrix.h.

◆ filter_column_not_equal_to()

Matrix< T > filter_column_not_equal_to ( const size_t &  column_index,
const Vector< T > &  values 
) const

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

Parameters
column_indexIndex of column.
valueFiltering value.

Definition at line 7684 of file matrix.h.

◆ get_column() [1/3]

Vector< T > get_column ( const size_t &  column_index) const

Returns the nth-column of the matrix.

Parameters
column_indexIndex of column.

Definition at line 2663 of file matrix.h.

◆ get_column() [2/3]

Vector< T > get_column ( const size_t &  column_index,
const Vector< size_t > &  row_indices 
) const

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

Parameters
column_indexIndex of column.
row_indicesRow indices of column.

Definition at line 2736 of file matrix.h.

◆ get_column() [3/3]

Vector< T > get_column ( const string &  column_name) const

Returns the nth-column of the matrix.

Parameters
column_nameName of column.

Definition at line 2695 of file matrix.h.

◆ get_column_index()

size_t get_column_index ( const string &  column_name) const

Returns the column index.

Parameters
column_givenString with the name of the column.

Definition at line 1325 of file matrix.h.

◆ get_columns()

Matrix< T > get_columns ( const Vector< string > &  column_names) const

Returns a matrix with the elements of the columns which name has been given.

Parameters
column_namesVector of columns names.

Definition at line 2723 of file matrix.h.

◆ get_columns_indices()

Vector< size_t > get_columns_indices ( const Vector< string > &  names) const

Returns the indices of the column headers that are passed to the function

Parameters
namesNames of the headers columns to be obteined.

Definition at line 1389 of file matrix.h.

◆ get_first() [1/2]

T get_first ( const size_t &  column_index) const

Returns the first value in a given column.

Parameters
column_indexIndex of column.

Definition at line 4754 of file matrix.h.

◆ get_first() [2/2]

T get_first ( const string &  column_name) const

Returns the first value in a given column.

Parameters
column_nameName of column.

Definition at line 4764 of file matrix.h.

◆ get_first_columns()

Matrix< T > get_first_columns ( const size_t &  number) const

Returns a submatrix with the first columns.

Parameters
numberNumber of the first columns to get.

Definition at line 4742 of file matrix.h.

◆ get_first_rows()

Matrix< T > get_first_rows ( const size_t &  number) const

Returns a submatrix with the first rows.

Parameters
numberNumber of the first rows to get.

Definition at line 4730 of file matrix.h.

◆ get_header()

const string get_header ( const size_t &  index) const

Returns a string with header in the column with index given.

Parameters
indexColumn index.s

Definition at line 1315 of file matrix.h.

◆ get_indices_greater_than()

Matrix< size_t > get_indices_greater_than ( const T &  value) const

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

Parameters
valueValue.

Definition at line 6549 of file matrix.h.

◆ get_indices_less_than()

Matrix< size_t > get_indices_less_than ( const T &  value) const

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

Parameters
valueValue.

Definition at line 6512 of file matrix.h.

◆ get_last() [1/2]

T get_last ( const size_t &  column_index) const

Returns the last value in a given column.

Parameters
column_indexIndex of column.

Definition at line 4776 of file matrix.h.

◆ get_last() [2/2]

T get_last ( const string &  column_name) const

Returns the last value in a given column.

Parameters
column_nameName of column.

Definition at line 4787 of file matrix.h.

◆ get_last_columns()

Matrix< T > get_last_columns ( const size_t &  number) const

Returns a submatrix with the last columns of the original matrix. Note that resizing is here necessary and this method can be very inefficient.

Parameters
numberNumber of columns to get.

Definition at line 4826 of file matrix.h.

◆ get_last_rows()

Matrix< T > get_last_rows ( const size_t &  number) const

Returns a submatrix with the last rows of the original matrix. Note that resizing is here necessary and this method can be very inefficient.

Parameters
numberNumber of rows to get.

Definition at line 4841 of file matrix.h.

◆ get_row() [1/2]

Vector< T > get_row ( const size_t &  index) const

Returns the nth row of the matrix.

Parameters
indexIndex of row.

Definition at line 2563 of file matrix.h.

◆ get_row() [2/2]

Vector< T > get_row ( const size_t &  row_index,
const Vector< size_t > &  columns_indices 
) const

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

Parameters
row_indexIndex of row.
columns_indicesColumn indices of row.

Definition at line 2629 of file matrix.h.

◆ get_rows()

Vector< T > get_rows ( const size_t &  first_index,
const size_t &  last_index 
) const

Returns the nth rows of the matrix in vector fomat.

Parameters
first_indexIndex of the first row.
last_indexIndex of the last row.

Definition at line 2596 of file matrix.h.

◆ get_rows_equal_to()

Vector< size_t > get_rows_equal_to ( const Vector< T > &  vector) const

Returns a vector with each elemnt represent a row index of the matrix that all columns have a given value.

Parameters
valueValue to be found.

Definition at line 2339 of file matrix.h.

◆ get_submatrix()

Matrix< T > get_submatrix ( const Vector< size_t > &  row_indices,
const Vector< size_t > &  columns_indices 
) const

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

Parameters
row_indicesIndices of matrix rows.
columns_indicesIndices of matrix columns.

Definition at line 2405 of file matrix.h.

◆ get_submatrix_columns()

Matrix< T > get_submatrix_columns ( const Vector< size_t > &  columns_indices) const

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

Parameters
columns_indicesIndices of matrix columns.

Definition at line 2512 of file matrix.h.

◆ get_submatrix_rows()

Matrix< T > get_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 2484 of file matrix.h.

◆ has_column_value()

bool has_column_value ( const size_t &  column_index,
const T &  value 
) const

Return true if the selected column has the given value

Parameters
colum_indexColumn selected
valueValue that wants to know if is in the selected column

Definition at line 5810 of file matrix.h.

◆ has_nan_column()

bool has_nan_column ( const size_t &  column_index) const

Returns true if the column of the matrix contains nan, and false otherwise

Parameters
row_indexColumn of the matrix

Definition at line 2800 of file matrix.h.

◆ has_nan_row()

bool has_nan_row ( const size_t &  row_index) const

Returns true if the row of the matrix contains nan, and false otherwise

Parameters
row_indexRow of the matrix

Definition at line 2785 of file matrix.h.

◆ initialize()

void initialize ( const T &  value)

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

Parameters
valueType value.

Definition at line 5458 of file matrix.h.

◆ initialize_diagonal() [1/3]

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

◆ initialize_diagonal() [2/3]

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

◆ initialize_diagonal() [3/3]

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

◆ initialize_identity()

void initialize_identity ( )

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

Definition at line 6068 of file matrix.h.

◆ insert_column() [1/2]

Matrix< T > insert_column ( const size_t &  position,
const Vector< T > &  new_column,
const string &  new_name = "" 
) const

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.
new_nameNew name of column.

Definition at line 3666 of file matrix.h.

◆ insert_column() [2/2]

Matrix< T > insert_column ( const string &  column_name,
const Vector< T > &  new_column,
const string &  new_name = "" 
) const

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

Parameters
column_nameName of before column position.
new_columnVector with the column contents.
new_nameNew name of column.

Definition at line 3733 of file matrix.h.

◆ insert_matrix()

Matrix< T > insert_matrix ( const size_t &  position,
const Matrix< T > &  other_matrix 
) const

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

Parameters
positionPosition of the new matrix.
other_matrixMatrix to be inserted.

Definition at line 3747 of file matrix.h.

◆ insert_row()

Matrix< T > insert_row ( const size_t &  position,
const Vector< T > &  new_row 
) const

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

◆ insert_row_values()

void insert_row_values ( const size_t &  row_index,
const size_t &  column_position,
const Vector< T > &  values 
)

Replace a value chosen for another one given to the function

Parameters
row_indexRow chosen
column_positionColumn chosen
valuesNew values If the vector has more than one element, the function changes the next elements in the row besides the chosen one

Definition at line 3648 of file matrix.h.

◆ is_antisymmetric()

bool is_antisymmetric ( ) 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 7234 of file matrix.h.

◆ is_column_constant()

bool is_column_constant ( const size_t &  column_index) const

Returns true if all the elements have the same value within a defined tolerance, and false otherwise.

Parameters
toleranceTolerance value, so that if abs(max-min) <= tol, then the vector is considered constant.

Definition at line 7440 of file matrix.h.

◆ is_diagonal()

bool is_diagonal ( ) const

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

Definition at line 7268 of file matrix.h.

◆ is_identity()

bool is_identity ( ) 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 7329 of file matrix.h.

◆ is_row_equal_to()

bool is_row_equal_to ( const size_t &  row_index,
const Vector< size_t > &  columns_indices,
const T &  value 
) const

Check if a given row the given columns that are equal to a given value. Returns true if given columns contains a given value, and false otherwise.

Parameters
row_indexIndex of a row.
columns_indicesVector of column indices to check.
valueValue to be found in the row.

Definition at line 2384 of file matrix.h.

◆ is_scalar()

bool is_scalar ( ) 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 7304 of file matrix.h.

◆ is_square()

bool is_square ( ) const

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

Definition at line 7183 of file matrix.h.

◆ is_symmetric()

bool is_symmetric ( ) const

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

Definition at line 7200 of file matrix.h.

◆ load_binary()

void load_binary ( const 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 8343 of file matrix.h.

◆ load_csv()

void load_csv ( const string &  file_name,
const char &  delim = ',',
const bool &  has_columns_names = false,
const string &  missing_label = "NA" 
)

Load a csv file.

Parameters
file_nameName of the file.
delimDelimiter used in the file.
has_columns_namesTrue if the columns have names. False otherwhise.

Definition at line 8061 of file matrix.h.

◆ load_csv_string()

void load_csv_string ( const string &  file_name,
const char &  delim = ',',
const bool &  has_columns_names = true 
)

Load a csv file.

Parameters
file_nameName of the file.
delimDelimiter used in the file.
has_columns_namesTrue if the columns have names. False otherwhise.

Definition at line 8224 of file matrix.h.

◆ matrix_to_string()

string matrix_to_string ( const char &  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 8657 of file matrix.h.

◆ merge_columns() [1/2]

void merge_columns ( const size_t &  column_1_index,
const size_t &  column_2_index,
const char &  separator 
)

This method merges two colums given and separates it by the wished separator

Parameters
column_1_indexIndex of the first column to merge. This is the one which is going to merge.
column_2_indexIndex of the second column to merge. This one is not going to suffer changes.
separatorCharacter to separate the merged columns.

Definition at line 4008 of file matrix.h.

◆ merge_columns() [2/2]

void merge_columns ( const string &  column_1_name,
const string &  column_2_name,
const string &  merged_column_name,
const char &  separator 
)

This method merges two colums given and separates it by the wished separator

Parameters
column_1_nameName of the header of the first column to merge. This is the one which is going to merge.
column_2_nameName of the header of the second column to merge. This one is not going to suffer changes.
merge_column_nameHeader of the new column.
separatorCharacter to separate the merged columns.

Definition at line 3979 of file matrix.h.

◆ multiply_diagonal()

void multiply_diagonal ( const T &  value)

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

Parameters
valueNew multiplying value.

Definition at line 3390 of file matrix.h.

◆ multiply_rows() [1/2]

Vector< Matrix< T > > multiply_rows ( const Matrix< T > &  matrix) const

Returns a vector which contains the rows' multiplication of two matrix.

Parameters
matrixMatrix to multiply the other one.

Definition at line 6431 of file matrix.h.

◆ multiply_rows() [2/2]

Matrix< T > multiply_rows ( const Vector< T > &  vector) const

Multiply the elements of the rows for a vector given to the function Notice that the vector must have the same size that the rows of the matrix

Parameters
vectorVector to multiply the matrix

Definition at line 6394 of file matrix.h.

◆ operator!=() [1/2]

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

◆ operator!=() [2/2]

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

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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

◆ operator*() [1/2]

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

◆ operator*() [2/2]

Matrix< T > operator* ( const T &  scalar) const

Product matrix*scalar arithmetic operator.

Parameters
scalarScalar value to be multiplied to this matrix.

Definition at line 6774 of file matrix.h.

◆ operator*=() [1/2]

void operator*= ( const Matrix< T > &  other_matrix)

Matrix product and assignment operator.

Parameters
other_matrixMatrix to be multiplied to this matrix.

Definition at line 7078 of file matrix.h.

◆ operator*=() [2/2]

void operator*= ( const T &  value)

Scalar product and assignment operator.

Parameters
valueScalar value to be multiplied to this matrix.

Definition at line 7065 of file matrix.h.

◆ operator+() [1/2]

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

◆ operator+() [2/2]

Matrix< T > operator+ ( const T &  scalar) const

Sum matrix+scalar arithmetic operator.

Parameters
scalarScalar value to be added to this matrix.

Definition at line 6680 of file matrix.h.

◆ operator+=() [1/2]

void operator+= ( const Matrix< T > &  other_matrix)

Matrix sum and assignment operator.

Parameters
other_matrixMatrix to be added to this matrix.

Definition at line 6963 of file matrix.h.

◆ operator+=() [2/2]

void operator+= ( const T &  value)

Scalar sum and assignment operator.

Parameters
valueScalar value to be added to this matrix.

Definition at line 6947 of file matrix.h.

◆ operator-() [1/2]

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

◆ operator-() [2/2]

Matrix< T > operator- ( const T &  scalar) const

Difference matrix-scalar arithmetic operator.

Parameters
scalarScalar value to be subtracted to this matrix.

Definition at line 6728 of file matrix.h.

◆ operator-=() [1/2]

void operator-= ( const Matrix< T > &  other_matrix)

Matrix rest and assignment operator.

Parameters
other_matrixMatrix to be subtracted to this matrix.

Definition at line 7022 of file matrix.h.

◆ operator-=() [2/2]

void operator-= ( const T &  value)

Scalar rest and assignment operator.

Parameters
valueScalar value to be subtracted to this matrix.

Definition at line 7006 of file matrix.h.

◆ operator/() [1/3]

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

◆ operator/() [2/3]

Matrix< T > operator/ ( const T &  scalar) const

Cocient Matrix/scalar arithmetic operator.

Parameters
scalarValue of scalar.

Definition at line 6858 of file matrix.h.

◆ operator/() [3/3]

Matrix< T > operator/ ( const Vector< T > &  vector) const

Cocient matrix/vector arithmetic operator.

Parameters
vectorVector to be divided to this matrix.

Definition at line 6875 of file matrix.h.

◆ operator/=() [1/2]

void operator/= ( const Matrix< T > &  other_matrix)

Matrix division and assignment operator.

Parameters
other_matrixMatrix to be divided to this matrix.

Definition at line 7122 of file matrix.h.

◆ operator/=() [2/2]

void operator/= ( const T &  value)

Scalar division and assignment operator.

Parameters
valueScalar value to be divided to this matrix.

Definition at line 7109 of file matrix.h.

◆ operator<() [1/2]

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

◆ operator<() [2/2]

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

◆ operator<=() [1/2]

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

◆ operator<=() [2/2]

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

◆ operator=()

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

◆ operator==() [1/2]

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

◆ operator==() [2/2]

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

◆ operator>() [1/2]

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

◆ operator>() [2/2]

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

◆ operator>=() [1/2]

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

◆ operator>=() [2/2]

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

◆ parse()

void parse ( const 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 8597 of file matrix.h.

◆ print_preview()

void print_preview ( ) const

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

Definition at line 8901 of file matrix.h.

◆ randomize_normal() [1/3]

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

◆ randomize_normal() [2/3]

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

◆ randomize_normal() [3/3]

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

◆ randomize_uniform() [1/3]

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

◆ randomize_uniform() [2/3]

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

◆ randomize_uniform() [3/3]

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

◆ replace()

void replace ( const T &  find_what,
const T &  replace_with 
)

Replace a value for another one given to the function

Parameters
find_whatElement is going to be changed
replace_withNew value

Definition at line 5480 of file matrix.h.

◆ replace_column_contains()

void replace_column_contains ( const string &  column_name,
const string &  find_what,
const string &  replace_with 
)

Replace the elements of a selected column that are equal to a string given for another string given to the function

Parameters
column_nameHeader of the selected column
find_whatString to be changed
replace_withNew string

Definition at line 5749 of file matrix.h.

◆ replace_column_equal_to() [1/2]

void replace_column_equal_to ( const size_t &  column_index,
const T &  find_value,
const T &  replace_value 
)

Replace the elements of a selected column that are equal to a value given for another value given to the function

Parameters
column_indexIndex of the selected column
find_valueValue to be changed
replace_valueNew value

Definition at line 5677 of file matrix.h.

◆ replace_column_equal_to() [2/2]

void replace_column_equal_to ( const string &  column_name,
const T &  find_value,
const T &  replace_value 
)

Replace the elements of a selected column that are equal to a value given for another value given to the function

Parameters
column_nameHeader of the selected column
find_valueValue to be changed
replace_valueNew value

Definition at line 5657 of file matrix.h.

◆ replace_column_not_equal_to() [1/2]

void replace_column_not_equal_to ( const string &  column_name,
const T &  find_value,
const T &  replace_value 
)

Replace the elements of a selected column that are not equal to a value given for another value given to the function

Parameters
column_nameHeader of the selected column
find_valueValue to be changed
replace_valueNew value

Definition at line 5695 of file matrix.h.

◆ replace_column_not_equal_to() [2/2]

void replace_column_not_equal_to ( const string &  column_name,
const Vector< T > &  find_values,
const T &  replace_value 
)

Replace the elements of a selected column that are equal to a value given for another value given to the function

Parameters
column_nameHeader of the selected column
find_valuesValues to be changed
replace_valueNew value

Definition at line 5715 of file matrix.h.

◆ replace_contains()

void replace_contains ( const string &  find_what,
const string &  replace_with 
)

Replace the columns that contains the given substring for another one given to the function

Parameters
find_whatString to be changed
replace_withNew string

Definition at line 5619 of file matrix.h.

◆ replace_contains_in_row()

void replace_contains_in_row ( const size_t &  row_index,
const string &  find_what,
const string &  replace_with 
)

Replace the elements that contains the given substring in a selected row for another one given to the function

Parameters
row_indexrow selected
find_whatString to be changed
replace_withNew string

Definition at line 5639 of file matrix.h.

◆ replace_header()

void replace_header ( const string &  find_what,
const string &  replace_with 
)

Replace the chosen header for anohter one given to the function

Parameters
find_whatHeader to be changed
replace_withNew header

Definition at line 5498 of file matrix.h.

◆ replace_in_column() [1/2]

void replace_in_column ( const size_t &  column_index,
const T &  find_what,
const T &  replace_with 
)

Replace the element of a selected column for another one given to the function

Parameters
column_indexRow selected to change one element
find_whatElement to be changed
replace_withNew element

Definition at line 5530 of file matrix.h.

◆ replace_in_column() [2/2]

void replace_in_column ( const string &  column_name,
const T &  find_what,
const T &  replace_with 
)

Replace the element of a selected column for another one given to the function

Parameters
column_nameHeader of the row selected to change one element
find_whatElement to be changed
replace_withNew element

Definition at line 5548 of file matrix.h.

◆ replace_in_row()

void replace_in_row ( const size_t &  row_index,
const T &  find_what,
const T &  replace_with 
)

/// Replace the element of a selected row for another one given to the function

Parameters
row_indexRow selected to change one element
find_whatElement to be changed
replace_withNew element

Definition at line 5512 of file matrix.h.

◆ replace_substring() [1/3]

void replace_substring ( const size_t &  column_index,
const string &  find_what,
const string &  replace_with 
)

Replace the chosen substring for another one given to the function

Parameters
column_indexColumn selected
find_whatString to be changed
replace_withNew string

Definition at line 5584 of file matrix.h.

◆ replace_substring() [2/3]

void replace_substring ( const string &  find_what,
const string &  replace_with 
)

Replace the chosen substring for another one given to the function

Parameters
find_whatString to be changed
replace_withNew string

Definition at line 5560 of file matrix.h.

◆ replace_substring() [3/3]

void replace_substring ( const string &  column_name,
const string &  find_what,
const string &  replace_with 
)

Replace the chosen substring for another one given to the function

Parameters
column_nameHeader of the column selected
find_whatString to be changed
replace_withNew string

Definition at line 5606 of file matrix.h.

◆ save_binary()

void save_binary ( const string &  file_name) const

Saves the values of the matrix to a binary file.

Parameters
file_nameFile name.

Definition at line 8389 of file matrix.h.

◆ save_csv()

void save_csv ( const string &  file_name,
const char &  separator = ',',
const Vector< string > &  row_names = Vector<string>(),
const string &  nameID = "Id" 
) 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 8434 of file matrix.h.

◆ save_json()

void save_json ( const string &  file_name,
const Vector< string > &  column_names = Vector<string>() 
) const

Saves the values of the matrix to a data file in JSON format.

Parameters
file_nameFile name.
column_namesNames of the columns.

Definition at line 8513 of file matrix.h.

◆ set() [1/4]

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

◆ set() [2/4]

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

◆ set() [3/4]

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

◆ set() [4/4]

void set ( const 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 1574 of file matrix.h.

◆ set_column() [1/4]

void set_column ( const size_t &  column_index,
const T &  value,
const string &  new_name = "" 
)

Sets new value of a single column in the matrix.

Parameters
column_indexIndex of column.
valueNew value of single column.
new_nameNew name of single column.

Definition at line 3208 of file matrix.h.

◆ set_column() [2/4]

void set_column ( const size_t &  column_index,
const Vector< T > &  new_column,
const string &  new_name = "" 
)

Sets new values of a single column in the matrix.

Parameters
column_indexIndex of column.
new_columnNew values of single column.
new_nameNew name of single column.

Definition at line 3133 of file matrix.h.

◆ set_column() [3/4]

void set_column ( const string &  column_name,
const T &  value,
const string &  new_name = "" 
)

Sets new value of a single column in the matrix.

Parameters
column_nameName of column.
valueNew value of single column.
new_nameNew name of single column.

Definition at line 3194 of file matrix.h.

◆ set_column() [4/4]

void set_column ( const string &  column_name,
const Vector< T > &  new_column,
const string &  new_name = "" 
)

Sets new values of a single column in the matrix.

Parameters
column_nameName of column.
new_columnNew values of single column.
new_nameNew name of single column.

Definition at line 3180 of file matrix.h.

◆ set_columns_number()

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

◆ set_diagonal() [1/2]

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

◆ set_diagonal() [2/2]

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

◆ set_header() [1/2]

void set_header ( const size_t &  index,
const string &  index_name 
)

Sets a new header in the matrix.

Parameters
indexColumn index to replace header.
index_nameName of matrix column.

Definition at line 1679 of file matrix.h.

◆ set_header() [2/2]

void set_header ( const Vector< string > &  new_header)

Sets a new header in the matrix.

Parameters
new_headerNames of matrix columns.

Definition at line 1668 of file matrix.h.

◆ set_identity()

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

◆ set_row() [1/2]

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

◆ set_row() [2/2]

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

◆ set_rows_number()

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

◆ set_submatrix_rows()

void set_submatrix_rows ( const size_t &  row_index,
const Matrix< T > &  submatrix 
)

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

Parameters
row_indexIndex of row.
valueNew value of single row.

Definition at line 3086 of file matrix.h.

◆ sort_ascending()

Matrix< T > sort_ascending ( 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 5178 of file matrix.h.

◆ sort_ascending_strings()

Matrix< T > sort_ascending_strings ( const size_t &  column_index) const

Sorts the rows of the matrix in ascending order attending to the values in string format 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 5207 of file matrix.h.

◆ sort_descending()

Matrix< T > sort_descending ( 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 5386 of file matrix.h.

◆ sort_descending_strings()

Matrix< T > sort_descending_strings ( const size_t &  column_index) const

Sorts the rows of the matrix in descending order attending to the values in string format 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 5238 of file matrix.h.

◆ subtract_rows()

Matrix< T > subtract_rows ( const Vector< T > &  vector) const

Subtracts the values of all the rows of this matrix with the values of a given vector. The size of the vector must be equal to the number of columns.

Definition at line 6356 of file matrix.h.

◆ sum_column()

void sum_column ( const size_t &  column_index,
const Vector< T > &  vector 
)

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

Definition at line 6289 of file matrix.h.

◆ sum_diagonal() [1/2]

void sum_diagonal ( const T &  value)

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

◆ sum_diagonal() [2/2]

void sum_diagonal ( const Vector< T > &  new_summing_values)

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

◆ sum_row()

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

◆ sum_rows()

Matrix< T > sum_rows ( const Vector< T > &  vector) const

Sums the values of all the rows of this matrix with the values of a given vector. The size of the vector must be equal to the number of columns.

Definition at line 6319 of file matrix.h.

◆ swap_columns() [1/2]

void swap_columns ( const size_t &  column_1_index,
const size_t &  column_2_index 
)

This method swap two columns

Parameters
column_1_indexIndex of the first column to swap
column_2_indexIndex of the second column to swap

Definition at line 3941 of file matrix.h.

◆ swap_columns() [2/2]

void swap_columns ( const string &  column_1_name,
const string &  column_2_name 
)

This method swap a columns.

Parameters
column_1_nameName of the first column to swap
column_2_nameName of the second column to swap

Definition at line 3963 of file matrix.h.

◆ to_categorical()

Matrix< T > to_categorical ( const size_t &  column_index) const

This method converts a variable into categorical. Note that the new matrix has a different size.

Parameters
column_indexIndex of the column to be converted.

Definition at line 9073 of file matrix.h.

◆ to_std_vector()

vector< T > to_std_vector ( ) 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 8858 of file matrix.h.

◆ to_tensor()

Tensor< T > to_tensor ( ) const

Transform the original matrix into a tensor. Returns a tensor with dimenssion (rows of matrix, columns of matrix).

Definition at line 9113 of file matrix.h.

◆ to_vector()

Vector< T > to_vector ( ) 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 8871 of file matrix.h.

◆ to_vector_matrix()

Vector< Matrix< T > > to_vector_matrix ( const size_t &  vector_size,
const size_t &  new_rows_number,
const size_t &  new_columns_number 
) const

Transform a matrix into a vector of matrix.

Parameters
vector_sizeSize of the vector.
new_rows_numberNumber of the rows of the new matrix.
new_columns_numberNumber of the columns of the new matrix.

Definition at line 9131 of file matrix.h.

◆ to_vector_of_vectors()

Vector< Vector< T > > to_vector_of_vectors ( ) const

Returns a vector of vectors representation of this matrix. The number of subvectors is equal to the number of columns of this matrix. The size of each subvector is equal to the number of rows of this matrix.

Definition at line 8884 of file matrix.h.


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