Vector< T > Class Template Reference

This template represents an array of any kind of numbers or objects. More...

#include <vector.h>

Inheritance diagram for Vector< T >:

Public Member Functions

 Vector ()
 
 Vector (const size_t &)
 
 Vector (const size_t &, const T &)
 
 Vector (const string &)
 
 Vector (const T &, const double &, const T &)
 
template<class InputIterator >
 Vector (const InputIterator &, const InputIterator &)
 Input iterators constructor.
 
 Vector (const vector< T > &)
 
 Vector (const Vector< T > &)
 
 Vector (const initializer_list< T > &)
 
 Vector (const Vector< Vector< T >> &)
 
virtual ~Vector ()
 Destroys the vector.
 
Vector< T > & operator= (const Vector< T > &)
 
bool operator== (const T &) const
 
bool operator!= (const T &) const
 
bool operator> (const T &) const
 
bool operator< (const T &) const
 
bool operator>= (const T &) const
 
bool operator<= (const T &) const
 
void set ()
 Sets the size of this vector to zero.
 
void set (const size_t &)
 
void set (const size_t &, const T &)
 
void set (const string &)
 
void set (const T &, const double &, const T &)
 
void set (const Vector< T > &)
 
const T & get_first () const
 Return the first element of the vector.
 
const T & get_last () const
 Return the last element of the vector.
 
const T & get_before_last () const
 Return the penultimate element of the vector.
 
Vector< T > get_positive_elements () const
 Returns a vector that contains the elements of this vector that are equal to or greater than zero.
 
Vector< T > get_negative_elements () const
 Returns a vector that contains the elements of this vector that are less than zero.
 
void initialize (const T &)
 
void initialize_first (const size_t &, const T &)
 
void initialize_sequential ()
 Initializes all the elements of the vector in a sequential order.
 
void randomize_uniform (const T &, const T &)
 
void randomize_uniform (const Vector< T > &, const Vector< T > &)
 
void randomize_normal (const double &=0.0, const double &=1.0)
 
void randomize_normal (const Vector< double > &, const Vector< double > &)
 
void randomize_binary (const double &=0.5, const double &=0.5)
 
void trim ()
 Removes whitespaces from the start and the end of each element in this vector of strings.
 
Vector< T > trimmed () const
 Returns a vector of strings that has whitespaces removed from the start and the end of each element.
 
Vector< T > fill_from (const size_t &, const Vector< T > &) const
 
bool contains (const T &) const
 
bool contains (const Vector< T > &) const
 
bool contains_greater_than (const T &) const
 
bool has_same_elements (const Vector< T > &) const
 
bool is_in (const T &, const T &) const
 
bool is_constant (const double &=0.0) const
 
bool is_constant_string () const
 Returns true if all the elements in this vector of strings are equal, and false otherwise.
 
bool is_crescent () const
 
bool is_decrescent () const
 
bool is_binary () const
 Returns true if all the elements in the vector have binary values, and false otherwise.
 
bool is_binary_missing_values () const
 Returns true if all the elements in the vector have binary values, and false otherwise.
 
bool is_binary_0_1 () const
 Returns true if all elements are zero or one.
 
bool is_integer () const
 Returns true if all the elements in the vector are integers, and false otherwise.
 
bool is_integer_missing_values () const
 Returns true if all the elements in the vector are integers, and false otherwise.
 
bool is_positive () const
 Returns true if all the elements of this vector are equal or greater than zero, and false otherwise.
 
bool is_negative () const
 Returns true if all the elements of this vector are less than zero, and false otherwise.
 
bool check_period (const double &period) const
 
bool has_nan () const
 Returns true if any element of this vector contains at least one NAN, and false otherwise.
 
Vector< T > get_reverse () const
 
void replace_value (const T &, const T &)
 
size_t count_equal_to (const T &) const
 
size_t count_equal_to (const Vector< T > &) const
 
size_t count_NAN () const
 Returns the number of std NANs that are contained in the vector.
 
size_t count_not_NAN () const
 Returns the number of std not NANs that are contained in the vector.
 
size_t count_not_equal_to (const T &) const
 
size_t count_not_equal_to (const Vector< T > &) const
 
size_t count_positive () const
 Returns the number of elements that are equal or greater than zero.
 
size_t count_negative () const
 Returns the number of elements that are smaller than zero.
 
size_t count_integers (const size_t &) const
 
size_t count_integers_missing_values (const size_t &) const
 
size_t count_greater_than (const T &) const
 
size_t count_less_than (const T &) const
 
size_t count_greater_equal_to (const T &) const
 
size_t count_less_equal_to (const T &) const
 
size_t count_between (const T &, const T &) const
 
size_t count_contains (const string &) const
 
Vector< size_t > count_unique () const
 
size_t get_first_index (const T &) const
 
Vector< size_t > get_indices_equal_to (const T &) const
 
Vector< size_t > get_indices_equal_to (const Vector< T > &) const
 
Vector< size_t > get_indices_not_equal_to (const T &) const
 
Vector< size_t > get_indices_not_equal_to (const Vector< T > &) const
 
Vector< size_t > get_indices_less_than (const T &) const
 
Vector< size_t > get_indices_greater_than (const T &) const
 
Vector< size_t > get_indices_less_equal_to (const T &) const
 
Vector< size_t > get_indices_greater_equal_to (const T &) const
 
Vector< size_t > get_between_indices (const T &, const T &) const
 
Vector< size_t > get_indices_that_contains (const string &) const
 
Vector< T > merge (const string &, const char &) const
 
Vector< Matrix< T > > to_vector_matrix (const size_t &, const size_t &, const size_t &) const
 
Vector< T > filter_equal_to (const T &) const
 
Vector< T > filter_not_equal_to (const T &) const
 
Vector< T > filter_equal_to (const Vector< T > &) const
 
Vector< T > filter_not_equal_to (const Vector< T > &) const
 
Vector< T > filter_positive () const
 Sets all the negative elements in this vector to zero.
 
Vector< T > filter_negative () const
 Sets all the positive elements in this vector to zero.
 
Vector< T > filter_minimum_maximum (const T &, const T &) const
 
Vector< double > perform_Box_Cox_transformation (const double &=1) const
 
Vector< double > calculate_percentage (const size_t &) const
 
Vector< double > calculate_percentage () const
 Returns a vector containing the relative frequencies of the elements.
 
size_t calculate_cumulative_index (const T &) const
 
calculate_sum () const
 Returns the sum of the elements of this vector.
 
calculate_partial_sum (const Vector< size_t > &) const
 
calculate_sum_missing_values () const
 Returns the sum of the elements of this vector, ignoring the given values.
 
calculate_product () const
 Returns the product of the elements of this vector.
 
Vector< size_t > sort_ascending_indices () const
 Returns a vector of the indices of this vector sorted by ascending values.
 
Vector< T > sort_ascending_values () const
 Returns a vector of the elements of this vector sorted by ascending values.
 
Vector< size_t > calculate_lower_indices (const size_t &) const
 
Vector< T > calculate_lower_values (const size_t &) const
 
Vector< size_t > sort_descending_indices () const
 Returns a vector of the indices of this vector sorted by descending values.
 
Vector< T > sort_descending_values () const
 Returns a vector of the elements of this vector sorted by descending values.
 
Vector< size_t > calculate_less_rank () const
 
Vector< size_t > calculate_greater_rank () const
 
Vector< T > sort_rank (const Vector< size_t > &) const
 
Vector< T > operator= (const initializer_list< T > &) const
 
Vector< T > operator+ (const T &) const
 
Vector< T > operator+ (const Vector< T > &) const
 
Vector< T > operator- (const T &) const
 
Vector< T > operator- (const Vector< T > &) const
 
Vector< T > operator* (const T &) const
 
Vector< T > operator* (const Vector< T > &) const
 
Matrix< T > operator* (const Matrix< T > &) const
 
Vector< T > operator/ (const T &) const
 
Vector< T > operator/ (const Vector< T > &) const
 
void operator+= (const T &)
 
void operator+= (const Vector< T > &)
 
void operator-= (const T &)
 
void operator-= (const Vector< T > &)
 
void operator*= (const T &)
 
void operator*= (const Vector< T > &)
 
void operator/= (const T &)
 
void operator/= (const Vector< T > &)
 
Matrix< T > to_diagonal_matrix () const
 
Vector< T > get_subvector (const size_t &, const size_t &) const
 
Vector< T > get_subvector (const Vector< size_t > &) const
 
Vector< T > get_subvector (const Vector< bool > &) const
 
Vector< T > get_subvector_random (const size_t &) const
 
Vector< T > get_first (const size_t &) const
 
Vector< T > get_last (const size_t &) const
 
Vector< T > delete_first (const size_t &) const
 
Vector< T > delete_last (const size_t &) const
 
Vector< T > get_integer_elements (const size_t &) const
 
Vector< T > get_integer_elements_missing_values (const size_t &) const
 Returns a vector with the integers of this vector.
 
void load (const string &)
 
void save (const string &, const char &=' ') const
 
void embed (const size_t &, const Vector< T > &)
 
Vector< T > insert_elements (const size_t &, const Vector< T > &)
 
Vector< T > insert_element (const size_t &, const T &) const
 
Vector< T > delete_index (const size_t &) const
 
Vector< T > delete_indices (const Vector< size_t > &) const
 
Vector< T > delete_value (const T &) const
 
Vector< T > delete_values (const Vector< T > &) const
 
Vector< T > assemble (const Vector< T > &) const
 
Vector< T > get_difference (const Vector< T > &) const
 
Vector< T > get_union (const Vector< T > &) const
 
Vector< T > get_intersection (const Vector< T > &) const
 
Vector< T > get_unique_elements () const
 
void print_unique_string () const
 
void print_unique_number () const
 
Vector< T > calculate_top_string (const size_t &) const
 
Vector< T > calculate_top_number (const size_t &) const
 
void print_top_string (const size_t &) const
 
vector< T > to_std_vector () const
 Returns a std vector with the size and elements of this OpenNN vector.
 
Vector< float > to_float_vector () const
 Returns a new vector with the elements of this vector casted to float.
 
Vector< double > to_double_vector () const
 Returns a new vector with the elements of this vector casted to double.
 
Vector< int > to_int_vector () const
 Returns a new vector with the elements of this vector casted to int.
 
Vector< size_t > to_size_t_vector () const
 Returns a new vector with the elements of this vector casted to size_t.
 
Vector< time_t > to_time_t_vector () const
 Returns a new vector with the elements of this vector casted to time_t.
 
Vector< bool > to_bool_vector () const
 
Matrix< T > to_binary_matrix () const
 
Vector< string > to_string_vector () const
 Returns a new vector with the elements of this vector converted to string.
 
Vector< double > string_to_double () const
 Returns a new vector with the elements of this string vector casted to double.
 
Vector< int > string_to_int () const
 Returns a new vector with the elements of this string vector casted to int.
 
Vector< size_t > string_to_size_t () const
 Returns a new vector with the elements of this string vector casted to size_t.
 
Vector< time_t > string_to_time_t () const
 Returns a new vector with the elements of this string vector casted to time_t.
 
Vector< Vector< T > > split (const size_t &) const
 
Matrix< T > to_row_matrix () const
 
Matrix< T > to_column_matrix () const
 
void parse (const string &)
 
string to_text (const char &=',') const
 Returns a string representation of this vector which can be inserted in a text.
 
string to_text (const string &=",") const
 Returns a string representation of this vector which can be inserted in a text.
 
string vector_to_string (const char &, const char &) const
 
string vector_to_string (const char &) const
 
string vector_to_string () const
 Returns a string representation of this vector.
 
string stack_vector_to_string () const
 Returns a new vector with the elements of this stack vector casted to string.
 
Vector< string > write_string_vector (const size_t &=5) const
 
Matrix< T > to_matrix (const size_t &, const size_t &) const
 
Tensor< T > to_tensor (const Vector< size_t > &) const
 

Static Public Member Functions

static Vector< T > assemble (const Vector< Vector< T >> &)
 

Detailed Description

template<typename T>
class OpenNN::Vector< T >

This template represents an array of any kind of numbers or objects.

It inherits from the vector of the standard library, and implements additional utilities.

Definition at line 54 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/9]

Vector ( )
explicit

Default constructor. It creates a vector of size zero.

Definition at line 429 of file vector.h.

◆ Vector() [2/9]

Vector ( const size_t &  new_size)
explicit

Size constructor. It creates a vector of a given number of elements.

Parameters
new_sizeSize of vector.

Definition at line 437 of file vector.h.

◆ Vector() [3/9]

Vector ( const size_t &  new_size,
const T &  value 
)
explicit

Size and initialization constructor. It creates a vector of size n, and initializes all the elements to a given value.

Parameters
new_sizeSize of Vector.
valueInitialization value of Type.

Definition at line 448 of file vector.h.

◆ Vector() [4/9]

Vector ( const string &  file_name)
explicit

File constructor. It creates a vector object by loading its members from a data file.

Parameters
file_nameName of vector data file.

Definition at line 457 of file vector.h.

◆ Vector() [5/9]

Vector ( const T &  first,
const double &  step,
const T &  last 
)
explicit

Sequential constructor. It creates a vector of size n=(last-first)/step, and initializes the items sequentially. Depending on the starting, step and finishing values, this method can produce a variety of sizes and data, related by n~(last-first)/step.

Parameters
firstFirst value of the vector.
stepSequence step.
lastLast value of the vector.

Definition at line 472 of file vector.h.

◆ Vector() [6/9]

Vector ( const vector< T > &  other_vector)

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

Parameters
other_vectorVector to be copied.

Definition at line 498 of file vector.h.

◆ Vector() [7/9]

Vector ( const Vector< T > &  other_vector)

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

Parameters
other_vectorVector to be copied.

Definition at line 490 of file vector.h.

◆ Vector() [8/9]

Vector ( const initializer_list< T > &  list)

List constructor. It creates a vector object by loading its members from a list.

Parameters
listNumber of vector list.

Definition at line 506 of file vector.h.

◆ Vector() [9/9]

Vector ( const Vector< Vector< T >> &  vectors)

Vector of vectors constructor. It creates a Vector object from Vector of Vectors by loading members into a vectors.

Parameters
vectorsVector of vectors.

Definition at line 514 of file vector.h.

Member Function Documentation

◆ assemble() [1/2]

Vector< T > assemble ( const Vector< T > &  other_vector) const

Assemble two vectors.

Parameters
other_vectorVector to be assembled to this vector.

Definition at line 3819 of file vector.h.

◆ assemble() [2/2]

Vector< T > assemble ( const Vector< Vector< T >> &  vectors)
static

Assemble a vector of vectors to this vector.

Parameters
vectorsVector of vectors to be assembled to this vector.

Definition at line 3861 of file vector.h.

◆ calculate_cumulative_index()

size_t calculate_cumulative_index ( const T &  value) const

This method applies only to cumulative vectors. It returns the index of the first element which is greater than a given value.

Parameters
valueValue to be found.

Definition at line 2391 of file vector.h.

◆ calculate_greater_rank()

Vector< size_t > calculate_greater_rank ( ) const

Returns a vector with the rank of the elements of this vector. The smallest element will have rank size-1, and the greatest element will have 0. That is, small values correspond to big ranks.

Definition at line 2683 of file vector.h.

◆ calculate_less_rank()

Vector< size_t > calculate_less_rank ( ) const

Returns a vector with the rank of the elements of this vector. The smallest element will have rank 0, and the greatest element will have size-1. That is, small values correspond with small ranks.

Definition at line 2643 of file vector.h.

◆ calculate_lower_indices()

Vector< size_t > calculate_lower_indices ( const size_t &  indices_number) const

Returns a vector with the indices of the smallest value elements of this vector. Note that the size of the new vector is given by the number of elements chosen.

Parameters
indices_numberNumber of subvector size with lower indices.

Definition at line 2579 of file vector.h.

◆ calculate_lower_values()

Vector< T > calculate_lower_values ( const size_t &  indices_number) const

Returns a vector with the smallest value elements of this vector. Note that the size of the new vector is given by the number of elements chosen.

Parameters
indices_numberNumber of subvector size with lower values elements.

Definition at line 2590 of file vector.h.

◆ calculate_partial_sum()

T calculate_partial_sum ( const Vector< size_t > &  indices) const

Returns the sum of the elements with the given indices.

Parameters
indicesIndices of the elementes to sum.

Definition at line 2477 of file vector.h.

◆ calculate_percentage()

Vector< double > calculate_percentage ( const size_t &  total_sum) const

Returns a vector containing the relative frequencies of the elements.

Parameters
total_sumSum of all the elements of the vector

Definition at line 2329 of file vector.h.

◆ calculate_top_number()

Vector< T > calculate_top_number ( const size_t &  rank) const

Return a vector which contains the elements of a given number vector according to the number of times that they appear in these vector For instance, if the given vector is ({"1", "1", "2", "2", "3", "2"}), it returns ({"2", "1", "3"})

Parameters
rankNumber of top elements that are printed

Definition at line 4117 of file vector.h.

◆ calculate_top_string()

Vector< T > calculate_top_string ( const size_t &  rank) const

Return a vector which contains the elements of a given string vector according to the number of times that they appear in these vector For instance, if the given vector is ({"a", "a", "b", "b", "c", "b"}), it returns ({"b", "a", "c"})

Parameters
rankNumber of top elements that are printed

Definition at line 4089 of file vector.h.

◆ check_period()

bool check_period ( const double &  period) const

Returns true if all the elemnts are separated by the same period, and false otherwise.

Parameters
periodValue of period by which the elements are separeted.

Definition at line 1343 of file vector.h.

◆ contains() [1/2]

bool contains ( const T &  value) const

Returns true if the vector contains a given value, and false otherwise.

Parameters
valueValue to be compared.

Definition at line 1123 of file vector.h.

◆ contains() [2/2]

bool contains ( const Vector< T > &  values) const

Returns true if the vector contains a certain value from a given set, and false otherwise.

Parameters
valuesVector values to be compared.

Definition at line 1155 of file vector.h.

◆ contains_greater_than()

bool contains_greater_than ( const T &  value) const

Returns true if all elements of the vector is greater than given value, and false otherwise.

Parameters
valueValue to be compared.

Definition at line 1138 of file vector.h.

◆ count_between()

size_t count_between ( const T &  minimum,
const T &  maximum 
) const

Returns the number of elements which are equal or greater than a minimum given value and equal or less than a maximum given value.

Parameters
minimumMinimum value.
maximumMaximum value.

Definition at line 2148 of file vector.h.

◆ count_contains()

size_t count_contains ( const string &  find_what) const

Returns the number of occurrences of a given substring in the vector.

Parameters
find_whatSubstring to be found.

Definition at line 2167 of file vector.h.

◆ count_equal_to() [1/2]

size_t count_equal_to ( const T &  value) const

Returns the number of elements that are equal to a given value is contained in the vector.

Parameters
valueValue to be counted.

Definition at line 1498 of file vector.h.

◆ count_equal_to() [2/2]

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

Returns the number of elements that are equal to a given values is contained in the vector.

Parameters
valuesVector of values to be counted.

Definition at line 1508 of file vector.h.

◆ count_greater_equal_to()

size_t count_greater_equal_to ( const T &  value) const

Returns the number of elements that are greater than or equal to a given value.

Parameters
valueValue to be compared.

Definition at line 2112 of file vector.h.

◆ count_greater_than()

size_t count_greater_than ( const T &  value) const

Returns the number of elements that are greater than a given value.

Parameters
valueValue to be compared.

Definition at line 2068 of file vector.h.

◆ count_integers()

size_t count_integers ( const size_t &  maximum_integers) const

Returns the number of different integers in the vector or 0 if the number of different integers in the vector is greater than a given number, also returns 0 if the vector does not contain any integers.

Parameters
maximum_integersMaximum number of different integers to count.

Definition at line 1788 of file vector.h.

◆ count_integers_missing_values()

size_t count_integers_missing_values ( const size_t &  maximum_integers) const

Returns the number of different integers in the vector or 0 if the number of different integers in the vector is greater than a given number, also returns 0 if the vector does not contain any integers.

Parameters
maximum_integersMaximum number of different integers to count.

Definition at line 1824 of file vector.h.

◆ count_less_equal_to()

size_t count_less_equal_to ( const T &  value) const

Returns the number of elements that are less than or equal to a given value.

Parameters
valueValue to be compared.

Definition at line 2134 of file vector.h.

◆ count_less_than()

size_t count_less_than ( const T &  value) const

Returns the number of elements that are less than a given value.

Parameters
valueValue to be compared.

Definition at line 2090 of file vector.h.

◆ count_not_equal_to() [1/2]

size_t count_not_equal_to ( const T &  value) const

Returns the number of elements that are not equal to a given value is contained in the vector.

Parameters
valueValue to be counted.

Definition at line 1567 of file vector.h.

◆ count_not_equal_to() [2/2]

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

Returns the number of elements that are not equal to a given value is contained in the vector.

Parameters
valuesValues vector to be counted.

Definition at line 1588 of file vector.h.

◆ count_unique()

Vector< size_t > count_unique ( ) const

Returns a vector with the numbers of the unique elements, in the order given by the get_unique_elements method. For instance, if the input vector is(a, b, a), the output vector is(2, 1).

Definition at line 3993 of file vector.h.

◆ delete_first()

Vector< T > delete_first ( const size_t &  elements_number) const

Erases the first elements of the vector.

Parameters
elements_numberNumber of elements to be deleted.

Definition at line 792 of file vector.h.

◆ delete_index()

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

Returns a new vector which is a copy of this vector but with a given element removed. Therefore, the size of the new vector is the size of this vector minus one.

Parameters
indexIndex of element to be removed.

Definition at line 3676 of file vector.h.

◆ delete_indices()

Vector< T > delete_indices ( const Vector< size_t > &  indices) const

Returns a new vector which is a copy of this vector but with a given elements removed. Therefore, the size of the new vector is the size of this vector minus the indices vector size.

Parameters
indicesVector with the indices of the elements to be removed.

Definition at line 3716 of file vector.h.

◆ delete_last()

Vector< T > delete_last ( const size_t &  elements_number) const

Erases the last elements of the vector.

Parameters
elements_numberNumber of elements to be deleted.

Definition at line 804 of file vector.h.

◆ delete_value()

Vector< T > delete_value ( const T &  value) const

Construct a copy of this vector but without a certain value. Note that the new vector might have a different size than this vector.

Parameters
valueValue of elements to be removed.

Definition at line 3770 of file vector.h.

◆ delete_values()

Vector< T > delete_values ( const Vector< T > &  values) const

Construct a copy of this vector but without a given values. Note that the new vector might have a different size than this vector.

Parameters
valuesVector values to be removed.

Definition at line 3802 of file vector.h.

◆ embed()

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

Insert another vector starting from a given position. Note that the size of the new vector may be different.

Parameters
positionInsertion position.
other_vectorVector to be inserted.

Definition at line 3569 of file vector.h.

◆ fill_from()

Vector< T > fill_from ( const size_t &  from_index,
const Vector< T > &  fill_with 
) const

This method obtains values until a given index from this vector, then assembles these values and the given values to fill in. It returns a new vector of dimension n+n'.

Parameters
from_indexIndex of elements to be obtained.
fill_withValues vector to fill.

Definition at line 1102 of file vector.h.

◆ filter_equal_to() [1/2]

Vector< T > filter_equal_to ( const T &  value) const

Returns a vector with the elements that are equal to a given value is contained in the vector.

Parameters
valueComparison value.

Definition at line 1643 of file vector.h.

◆ filter_equal_to() [2/2]

Vector< T > filter_equal_to ( const Vector< T > &  values) const

Returns a indices vector with contains the elements that are equal to a given values.

Parameters
valuesValues vector with the comparison values.

Definition at line 1669 of file vector.h.

◆ filter_minimum_maximum()

Vector< T > filter_minimum_maximum ( const T &  minimum,
const T &  maximum 
) const

Returns a vector with the elements that are equal or greater than a given minimum value and less or equal to a given maximum value of this vector.

Parameters
minimumMinimum value to be filtered.
maximumMaximum value to be filtered.

Definition at line 2211 of file vector.h.

◆ filter_not_equal_to() [1/2]

Vector< T > filter_not_equal_to ( const T &  value) const

Returns a vector with the elements of this vector that are different from a given value.

Parameters
valueComparison value.

Definition at line 1681 of file vector.h.

◆ filter_not_equal_to() [2/2]

Vector< T > filter_not_equal_to ( const Vector< T > &  values) const

Returns a vector with the elements of this vector that are different from a given values.

Parameters
valuesVector with the comparison values.

Definition at line 1708 of file vector.h.

◆ get_between_indices()

Vector< size_t > get_between_indices ( const T &  minimum,
const T &  maximum 
) const

Returns a indices vector in which the elements of this vector take some value between the given values.

Parameters
minimumType value that represent the lower bound.
maximumType value that represent the upper bound.

Definition at line 1862 of file vector.h.

◆ get_difference()

Vector< T > get_difference ( const Vector< T > &  other_vector) const

Returns a vector which is the difference of this vector and another vector. For instance, if this vector is(1,2,3) and the other vector is(1,4,3,3), the difference is (2), the element in the first vector which is not present in the second.

Parameters
other_vectorOther vector to be compared.

Definition at line 3895 of file vector.h.

◆ get_first()

Vector< T > get_first ( const size_t &  elements_number) const

Returns a vector with the first n elements of this vector.

Parameters
elements_numberSize of the new vector.

Definition at line 3352 of file vector.h.

◆ get_first_index()

size_t get_first_index ( const T &  value) const

Finds the first element in the vector with a given value, and returns its index.

Parameters
valueValue to be found.

Definition at line 2367 of file vector.h.

◆ get_indices_equal_to() [1/2]

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

Returns the indices vector of the elements that are equal to a given value.

Parameters
valueValue to be compared.

Definition at line 1978 of file vector.h.

◆ get_indices_equal_to() [2/2]

Vector< size_t > get_indices_equal_to ( const Vector< T > &  values) const

Returns the indices vector of the elements that are equal to given values.

Parameters
valuesVector of values to be compared.

Definition at line 1890 of file vector.h.

◆ get_indices_greater_equal_to()

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

Returns a vector with the indices of the elements of this vector are greater or equal to a given value.

Parameters
valueValue to be compared.

Definition at line 2281 of file vector.h.

◆ get_indices_greater_than()

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

Returns the indices vector of the elements that are grater than a given value.

Parameters
valueValue to be compared.

Definition at line 2041 of file vector.h.

◆ get_indices_less_equal_to()

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

Returns a vector with the indices of the elements of this vector are less or equal to a given value.

Parameters
valueValue to be compared.

Definition at line 2259 of file vector.h.

◆ get_indices_less_than()

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

Returns the indices vector of the elements that are less than a given value.

Parameters
valueValue to be compared.

Definition at line 2013 of file vector.h.

◆ get_indices_not_equal_to() [1/2]

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

Returns the indices vector of the elements that are not equal to a given value.

Parameters
valueValue to be compared.

Definition at line 1924 of file vector.h.

◆ get_indices_not_equal_to() [2/2]

Vector< size_t > get_indices_not_equal_to ( const Vector< T > &  values) const

Returns the indices vector of the elements that are not equal to given values.

Parameters
valuesVector of values to be compared.

Definition at line 1950 of file vector.h.

◆ get_indices_that_contains()

Vector< size_t > get_indices_that_contains ( const string &  find_what) const

Returns a vector with the indices of the elements of this vector that contain a given string.

Parameters
find_whatString to be found in the vector.

Definition at line 2237 of file vector.h.

◆ get_integer_elements()

Vector< T > get_integer_elements ( const size_t &  maximum_integers) const

Returns a vector with the diferent integers of the vector or return 0 if this number is greater than maximum number of integers.

Parameters
maximum_integersMaximum number of integers to get.

Definition at line 3422 of file vector.h.

◆ get_intersection()

Vector< T > get_intersection ( const Vector< T > &  other_vector) const

Returns a vector with the intersection of this vector and another vector. For instance, if this vector is(a, b, c) and the other vector is(b, c, d, e), the new vector will be (b, c).

Parameters
other_vectorAnother vector.

Definition at line 3955 of file vector.h.

◆ get_last()

Vector< T > get_last ( const size_t &  elements_number) const

Returns a vector with the last n elements of this vector.

Parameters
elements_numberSize of the new vector.

Definition at line 3387 of file vector.h.

◆ get_reverse()

Vector< T > get_reverse ( ) const

Returns the reverse vector. Note that the new vector has different order.

Definition at line 1479 of file vector.h.

◆ get_subvector() [1/3]

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

Returns another vector whose elements are the elements of this vector between two given indices. Note that the new vector will be smaller than this vector, the size is given by n = last_index - first_index

Parameters
first_indexIndex of lower element from whose the new vector begins.
last_indexIndex of upper element from whose the new vector endata_set.

Definition at line 3240 of file vector.h.

◆ get_subvector() [2/3]

Vector< T > get_subvector ( const Vector< bool > &  selection) const

Returns a subvector that contains the true boolean.

Parameters
selectionBoolean vector.

Definition at line 3324 of file vector.h.

◆ get_subvector() [3/3]

Vector< T > get_subvector ( const Vector< size_t > &  indices) const

Returns another vector whose elements are given by some elements of this vector. Note that the new vector will be smaller than this vector, the size is given by the size of the given index vector.

Parameters
indicesIndices of this vector whose elements are required.

Definition at line 3285 of file vector.h.

◆ get_subvector_random()

Vector< T > get_subvector_random ( const size_t &  new_size) const

Returns a subvector obtained from the elements of this vector randomly.

Parameters
new_sizeSize of new vector.

Definition at line 3336 of file vector.h.

◆ get_union()

Vector< T > get_union ( const Vector< T > &  other_vector) const

Returns a vector which is the union of this vector and another vector. For instance, if this vector is(1,2,3) and the other vector is(2,3,4), the union is(1,2,3,4), the elements that are present in the two vectors.

Parameters
other_vectorVector to be joined.

Definition at line 3933 of file vector.h.

◆ get_unique_elements()

Vector< T > get_unique_elements ( ) const

Returns a vector with the unique values of the vector sorted. For instance, if the vector is (a, b, a), the new vector will be (a, b).

Definition at line 3975 of file vector.h.

◆ has_same_elements()

bool has_same_elements ( const Vector< T > &  other_vector) const

Returns true if Vector contains the same elements than other vector, and false otherwise.

Parameters
other_vectorVector to be compared.

Definition at line 1184 of file vector.h.

◆ initialize()

void initialize ( const T &  value)

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

Parameters
valueType value.

Definition at line 816 of file vector.h.

◆ initialize_first()

void initialize_first ( const size_t &  first,
const T &  value 
)

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

Parameters
firstNumber of elements what are going to be initializated.
valueValue given to replace the original ones.

Definition at line 826 of file vector.h.

◆ insert_element()

Vector< T > insert_element ( const size_t &  index,
const T &  value 
) const

Returns a new vector with a new element inserted in a given position.

Parameters
indexPosition of the new element.
valueValue of the new element to be inserted.

Definition at line 3627 of file vector.h.

◆ is_constant()

bool is_constant ( const double &  tolerance = 0.0) 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 1231 of file vector.h.

◆ is_crescent()

bool is_crescent ( ) const

Returns true if all the elements in the vector have values which increase with the index, and false otherwise.

Definition at line 1276 of file vector.h.

◆ is_decrescent()

bool is_decrescent ( ) const

Returns true if all the elements in the vector have values which decrease with the index, and false otherwise.

Definition at line 1293 of file vector.h.

◆ is_in()

bool is_in ( const T &  minimum,
const T &  maximum 
) const

Returns true if the value of all the elements fall in some given range, and false otherwise.

Parameters
minimumMinimum value of the range.
maximumMaximum value of the range.

Definition at line 1211 of file vector.h.

◆ load()

void load ( const string &  file_name)

Loads the members of a vector from an data file. Please be careful with the file format, which is specified in the OpenNN manual.

Parameters
file_nameName of vector file.

Definition at line 3486 of file vector.h.

◆ merge()

Vector< T > merge ( const string &  substring,
const char &  separator 
) const

Insert a string at the end of each element in this vector.

Parameters
substringSubstring to be appended.
separatorDelimiter char between both strings.

Definition at line 2190 of file vector.h.

◆ operator!=()

bool operator!= ( const T &  value) const

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

Parameters
valueType value to be compared with.

Definition at line 585 of file vector.h.

◆ operator*() [1/3]

Matrix< T > operator* ( const Matrix< T > &  matrix) const
inline

Element by row product vector*matrix arithmetic operator.

Parameters
matrixmatrix to be multiplied to this vector.

Definition at line 2920 of file vector.h.

◆ operator*() [2/3]

Vector< T > operator* ( const T &  scalar) const
inline

Product vector*scalar arithmetic operator.

Parameters
scalarScalar value to be multiplied to this vector.

Definition at line 2869 of file vector.h.

◆ operator*() [3/3]

Vector< T > operator* ( const Vector< T > &  other_vector) const
inline

Element by element product vector*vector arithmetic operator.

Parameters
other_vectorvector to be multiplied to this vector.

Definition at line 2886 of file vector.h.

◆ operator*=() [1/2]

void operator*= ( const T &  value)

Scalar product and assignment operator.

Parameters
valueScalar value to be multiplied to this vector.

Definition at line 3095 of file vector.h.

◆ operator*=() [2/2]

void operator*= ( const Vector< T > &  other_vector)

Vector product and assignment operator.

Parameters
other_vectorVector to be multiplied to this vector.

Definition at line 3109 of file vector.h.

◆ operator+() [1/2]

Vector< T > operator+ ( const T &  scalar) const
inline

Sum vector+scalar arithmetic operator.

Parameters
scalarScalar value to be added to this vector.

Definition at line 2766 of file vector.h.

◆ operator+() [2/2]

Vector< T > operator+ ( const Vector< T > &  other_vector) const
inline

Sum vector+vector arithmetic operator.

Parameters
other_vectorVector to be added to this vector.

Definition at line 2783 of file vector.h.

◆ operator+=() [1/2]

void operator+= ( const T &  value)

Scalar sum and assignment operator.

Parameters
valueScalar value to be added to this vector.

Definition at line 3007 of file vector.h.

◆ operator+=() [2/2]

void operator+= ( const Vector< T > &  other_vector)

Vector sum and assignment operator.

Parameters
other_vectorVector to be added to this vector.

Definition at line 3020 of file vector.h.

◆ operator-() [1/2]

Vector< T > operator- ( const T &  scalar) const
inline

Difference vector-scalar arithmetic operator.

Parameters
scalarScalar value to be subtracted to this vector.

Definition at line 2817 of file vector.h.

◆ operator-() [2/2]

Vector< T > operator- ( const Vector< T > &  other_vector) const
inline

Difference vector-vector arithmetic operator.

Parameters
other_vectorvector to be subtracted to this vector.

Definition at line 2834 of file vector.h.

◆ operator-=() [1/2]

void operator-= ( const T &  value)

Scalar rest and assignment operator.

Parameters
valueScalar value to be subtracted to this vector.

Definition at line 3051 of file vector.h.

◆ operator-=() [2/2]

void operator-= ( const Vector< T > &  other_vector)

Vector rest and assignment operator.

Parameters
other_vectorVector to be subtracted to this vector.

Definition at line 3064 of file vector.h.

◆ operator/() [1/2]

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

Cocient vector/scalar arithmetic operator.

Parameters
scalarScalar value to be divided to this vector.

Definition at line 2956 of file vector.h.

◆ operator/() [2/2]

Vector< T > operator/ ( const Vector< T > &  other_vector) const

Cocient vector/vector arithmetic operator.

Parameters
other_vectorvector to be divided to this vector.

Definition at line 2973 of file vector.h.

◆ operator/=() [1/2]

void operator/= ( const T &  value)

Scalar division and assignment operator.

Parameters
valueScalar value to be divided to this vector.

Definition at line 3138 of file vector.h.

◆ operator/=() [2/2]

void operator/= ( const Vector< T > &  other_vector)

Vector division and assignment operator.

Parameters
other_vectorVector to be divided to this vector.

Definition at line 3152 of file vector.h.

◆ operator<()

bool operator< ( const T &  value) const

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

Parameters
valueType value to be compared with.

Definition at line 624 of file vector.h.

◆ operator<=()

bool operator<= ( const T &  value) const

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

Parameters
valueType value to be compared with.

Definition at line 666 of file vector.h.

◆ operator=()

Vector< T > operator= ( const initializer_list< T > &  list) const
inline

Sets all the entries to a given list.

Parameters
listList of values.

Definition at line 2756 of file vector.h.

◆ operator==()

bool operator== ( const T &  value) const

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

Parameters
valueType value to be compared with.

Definition at line 567 of file vector.h.

◆ operator>()

bool operator> ( const T &  value) const

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

Parameters
valueType value to be compared with.

Definition at line 604 of file vector.h.

◆ operator>=()

bool operator>= ( const T &  value) const

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

Parameters
valueType value to be compared with.

Definition at line 645 of file vector.h.

◆ parse()

void parse ( const string &  str)

This method takes a string representation of a vector and sets this vector to have size equal to the number of words and values equal to that words.

Parameters
strString to be parsed.

Definition at line 4575 of file vector.h.

◆ perform_Box_Cox_transformation()

Vector< double > perform_Box_Cox_transformation ( const double &  lambda = 1) const

Returns vector with the Box-Cox transformation.

Parameters
lambdaExponent of the Box-Cox transformation.

Definition at line 2303 of file vector.h.

◆ print_top_string()

void print_top_string ( const size_t &  rank) const

Prints to the screen the unique elements of this vector, the number of that elements and the corresponding percentage. It sorts the elements from greater than smaller and only prints the top ones.

Parameters
rankNumber of top elements that are printed.

Definition at line 4145 of file vector.h.

◆ print_unique_number()

void print_unique_number ( ) const

Prints to the screen the unique elements of the number vector, the number of that elements and the corresponding percentage. It sorts the elements from greater than smaller. For instance, for the vector({1, 2, 1}), it will print 2: 1(33.3%), 1: 2(66.6%).

Definition at line 4054 of file vector.h.

◆ print_unique_string()

void print_unique_string ( ) const

Prints to the screen the unique elements of the string vector, the number of that elements and the corresponding percentage. It sorts the elements from greater than smaller. For instance, for the vector({"a", "b", "a"}), it will print a: 2(66.6%), b: 1(33.3%).

Definition at line 4018 of file vector.h.

◆ randomize_binary()

void randomize_binary ( const double &  negatives_ratio = 0.5,
const double &  positives_ratio = 0.5 
)

Assigns random values to each element in the vector. These are taken from normal distributions with given positives and negatives ratio.

Parameters
negatives_ratio.
positives_ratio.

Definition at line 1012 of file vector.h.

◆ randomize_normal() [1/2]

void randomize_normal ( const double &  mean = 0.0,
const double &  standard_deviation = 1.0 
)

Assigns random values to each element in the vector. These are taken from a normal distribution with single mean and standard deviation values for all the elements.

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

Definition at line 932 of file vector.h.

◆ randomize_normal() [2/2]

void randomize_normal ( const Vector< double > &  mean,
const Vector< double > &  standard_deviation 
)

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

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

Definition at line 965 of file vector.h.

◆ randomize_uniform() [1/2]

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

Assigns a random value comprised between a minimum value and a maximum value to each element in the vector.

Parameters
minimumMinimum initialization value.
maximumMaximum initialization value.

Definition at line 847 of file vector.h.

◆ randomize_uniform() [2/2]

void randomize_uniform ( const Vector< T > &  minimums,
const Vector< T > &  maximums 
)

Assigns a random value comprised between given minimum and a maximum values to every element in the vector.

Parameters
minimumsMinimum initialization values.
maximumsMaximum initialization values.

Definition at line 881 of file vector.h.

◆ replace_value()

void replace_value ( const T &  find_value,
const T &  replace_value 
)

Returns a new vector where a given value has been replaced by another value.

Parameters
find_valueValue to be replaced.
replace_valueReplacement value.

Definition at line 3661 of file vector.h.

◆ save()

void save ( const string &  file_name,
const char &  separator = ' ' 
) const

Saves to a data file the elements of the vector. The file format is as follows: element_0 element_1 ... element_N-1

Parameters
file_nameName of vector data file.
separatorChar delimiter.

Definition at line 3529 of file vector.h.

◆ set() [1/5]

void set ( const size_t &  new_size)

Sets a new size to the vector. It does not initialize the data.

Parameters
new_sizeSize for the vector.

Definition at line 690 of file vector.h.

◆ set() [2/5]

void set ( const size_t &  new_size,
const T &  new_value 
)

Sets a new size to the vector and initializes all its elements with a given value.

Parameters
new_sizeSize for the vector.
new_valueValue to initialize.

Definition at line 701 of file vector.h.

◆ set() [3/5]

void set ( const string &  file_name)

Sets all the elements of a vector object by loading them from a data file. The format is specified in the OpenNN manual.

Parameters
file_nameName of data file.

Definition at line 713 of file vector.h.

◆ set() [4/5]

void set ( const T &  first,
const double &  step,
const T &  last 
)

Makes this vector to have elements starting from a given value, continuing with a step value and finishing with a given value. Depending on the starting, step and finishing values, this method can produce a variety of sizes and data.

Parameters
firstStarting value.
stepStep value.
lastFinishing value.

Definition at line 727 of file vector.h.

◆ set() [5/5]

void set ( const Vector< T > &  other_vector)

Sets the members of this object with the values of another vector.

Parameters
other_vectorObject to set this vector.

Definition at line 748 of file vector.h.

◆ sort_rank()

Vector< T > sort_rank ( const Vector< size_t > &  rank) const

Returns a vector sorted according to a given rank.

Parameters
rankGiven rank.

Definition at line 2721 of file vector.h.

◆ split()

Vector< Vector< T > > split ( const size_t &  n) const

Returns a vector of vectors whit vectors size n. This method split vector in several vectors.

Parameters
nVectors size.

Definition at line 4484 of file vector.h.

◆ to_binary_matrix()

Matrix< T > to_binary_matrix ( ) const

Returns an array in binary form, where the unique elements of this vector take the value 1 and the rest of elements 0. Note that the size of the matrix has rows as elements have the vector, and columns the number of unique elements that the vector has.

Definition at line 4328 of file vector.h.

◆ to_bool_vector()

Vector< bool > to_bool_vector ( ) const

Returns a boolean vector with the same size, where returns true if that value is unique and false otherwise.

Definition at line 4287 of file vector.h.

◆ to_column_matrix()

Matrix< T > to_column_matrix ( ) const

Returns a column matrix with number of rows equal to the size of this vector and number of columns equal to one.

Definition at line 4556 of file vector.h.

◆ to_diagonal_matrix()

Matrix< T > to_diagonal_matrix ( ) const

Returns a squared matrix in which the entries outside the main diagonal are all zero. The elements in the diagonal are the elements in this vector.

Definition at line 3222 of file vector.h.

◆ to_matrix()

Matrix< T > to_matrix ( const size_t &  rows_number,
const size_t &  columns_number 
) const

Returns a matrix with given numbers of rows and columns and with the elements of this vector ordered by rows. The number of rows multiplied by the number of columns must be equal to the size of this vector.

Parameters
rows_numberNumber of rows in the new matrix.
columns_numberNumber of columns in the new matrix.

Definition at line 4784 of file vector.h.

◆ to_row_matrix()

Matrix< T > to_row_matrix ( ) const

Returns a row matrix with number of rows equal to one and number of columns equal to the size of this vector.

Definition at line 4536 of file vector.h.

◆ to_tensor()

Tensor< T > to_tensor ( const Vector< size_t > &  dimensions) const

Returns a Tensor representation of this vector.

Parameters
dimensionsNumbers of tensor dimensions.

Definition at line 4823 of file vector.h.

◆ to_vector_matrix()

Vector< Matrix< T > > to_vector_matrix ( const size_t &  rows_number,
const size_t &  columns_number,
const size_t &  channels_number 
) const

This method converts this vector into an matrix vector.

Parameters
rows_numberNumber of rows in the matrix.
columns_numberNumber of columns in the matrix.
channels_numberNumber of elements in the matrix vector.

Definition at line 5035 of file vector.h.

◆ vector_to_string() [1/2]

string vector_to_string ( const char &  separator) const

Returns a string representation of this vector.

Parameters
separatorChar between the elements(, -, /, etc).

Definition at line 4640 of file vector.h.

◆ vector_to_string() [2/2]

string vector_to_string ( const char &  separator,
const char &  quotation 
) const

Returns a string representation of this vector.

Parameters
separatorChar between the elements(, -, /, etc).
quotationQuotation char for the elements(", ').

Definition at line 4614 of file vector.h.

◆ write_string_vector()

Vector< string > write_string_vector ( const size_t &  precision = 5) const

This method retuns a vector of strings with size equal to the size of this vector and elements equal to string representations of the elements of this vector.

Definition at line 4756 of file vector.h.


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