numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::opt::impl::ternary_vector Class Reference

Class of vectors of ternary floating-point numbers. More...

#include <num_collect/opt/impl/ternary_vector.h>

+ Collaboration diagram for num_collect::opt::impl::ternary_vector:

Public Types

using digit_type = std::int8_t
 Type of a digit.
 

Public Member Functions

 ternary_vector ()=default
 Constructor.
 
 ternary_vector (index_type dim)
 Constructor.
 
void change_dim (index_type dim)
 Change the number of dimensions.
 
auto digits (index_type dim) const -> index_type
 Get the number of digits of a dimension.
 
auto dim () const -> index_type
 Get the number of dimensions.
 
template<typename Scalar>
auto elem_as (index_type dim) const -> Scalar
 Get the element of this vector as a floating-point number.
 
auto operator!= (const ternary_vector &right) const -> bool
 Compare with another object.
 
auto operator() (index_type dim, index_type digit) -> digit_type &
 Access a digit.
 
auto operator() (index_type dim, index_type digit) const -> digit_type
 Access a digit.
 
auto operator== (const ternary_vector &right) const -> bool
 Compare with another object.
 
void push_back (index_type dim, digit_type digit)
 Add a digit to a dimension.
 

Static Public Attributes

static constexpr index_type max_digits
 Maximum number of digits per dimension.
 

Private Types

using data_type
 Type of data matrix.
 

Private Attributes

data_type data_ {}
 Data matrix.
 

Static Private Attributes

static constexpr index_type init_digits_per_dimensions = 4
 Initial digits per dimensions.
 

Detailed Description

Class of vectors of ternary floating-point numbers.

Definition at line 39 of file ternary_vector.h.

Member Typedef Documentation

◆ data_type

Initial value:
Eigen::Matrix<digit_type, Eigen::Dynamic, Eigen::Dynamic,
Eigen::RowMajor>
std::int8_t digit_type
Type of a digit.

Type of data matrix.

Definition at line 203 of file ternary_vector.h.

◆ digit_type

Type of a digit.

Definition at line 42 of file ternary_vector.h.

Constructor & Destructor Documentation

◆ ternary_vector()

num_collect::opt::impl::ternary_vector::ternary_vector ( index_type dim)
inlineexplicit

Constructor.

Parameters
[in]dimNumber of digits.

Definition at line 58 of file ternary_vector.h.

Member Function Documentation

◆ change_dim()

void num_collect::opt::impl::ternary_vector::change_dim ( index_type dim)
inline

Change the number of dimensions.

Warning
This won't preserve the digits already inserted.
Parameters
[in]dimNumber of dimensions.

Definition at line 75 of file ternary_vector.h.

◆ digits()

auto num_collect::opt::impl::ternary_vector::digits ( index_type dim) const -> index_type
inlinenodiscard

Get the number of digits of a dimension.

Parameters
[in]dimDimension index.
Returns
Number of digits.

Definition at line 85 of file ternary_vector.h.

◆ dim()

auto num_collect::opt::impl::ternary_vector::dim ( ) const -> index_type
inlinenodiscard

Get the number of dimensions.

Returns
Number of dimensions.

Definition at line 66 of file ternary_vector.h.

◆ elem_as()

template<typename Scalar>
auto num_collect::opt::impl::ternary_vector::elem_as ( index_type dim) const -> Scalar
inlinenodiscard

Get the element of this vector as a floating-point number.

Template Parameters
ScalarType of resulting floating-point number.
Parameters
[in]dimDimension index.
Returns
Calculated floating-point number.

Definition at line 187 of file ternary_vector.h.

◆ operator!=()

auto num_collect::opt::impl::ternary_vector::operator!= ( const ternary_vector & right) const -> bool
inlinenodiscard

Compare with another object.

Parameters
[in]rightRight-hand-side object.
Returns
Whether the two object are different.

Definition at line 175 of file ternary_vector.h.

◆ operator()() [1/2]

auto num_collect::opt::impl::ternary_vector::operator() ( index_type dim,
index_type digit ) -> digit_type&
inlinenodiscard

Access a digit.

Parameters
[in]dimDimension index.
[in]digitDigit index.
Returns
Reference to the digit.

Definition at line 97 of file ternary_vector.h.

◆ operator()() [2/2]

auto num_collect::opt::impl::ternary_vector::operator() ( index_type dim,
index_type digit ) const -> digit_type
inlinenodiscard

Access a digit.

Parameters
[in]dimDimension index.
[in]digitDigit index.
Returns
Reference to the digit.

Definition at line 111 of file ternary_vector.h.

◆ operator==()

auto num_collect::opt::impl::ternary_vector::operator== ( const ternary_vector & right) const -> bool
inlinenodiscard

Compare with another object.

Parameters
[in]rightRight-hand-side object.
Returns
Whether the two object are same.

Definition at line 142 of file ternary_vector.h.

◆ push_back()

void num_collect::opt::impl::ternary_vector::push_back ( index_type dim,
digit_type digit )
inline

Add a digit to a dimension.

Parameters
[in]dimDimension index.
[in]digitDigit.

Definition at line 124 of file ternary_vector.h.

Member Data Documentation

◆ data_

data_type num_collect::opt::impl::ternary_vector::data_ {}
private

Data matrix.

This matrix has the number of digits for each dimension and the buffer of digits.

Definition at line 215 of file ternary_vector.h.

◆ init_digits_per_dimensions

index_type num_collect::opt::impl::ternary_vector::init_digits_per_dimensions = 4
staticconstexprprivate

Initial digits per dimensions.

Definition at line 207 of file ternary_vector.h.

◆ max_digits

index_type num_collect::opt::impl::ternary_vector::max_digits
staticconstexpr
Initial value:
=
static_cast<index_type>(std::numeric_limits<digit_type>::max())
std::ptrdiff_t index_type
Type of indices in this library.
Definition index_type.h:33

Maximum number of digits per dimension.

Definition at line 45 of file ternary_vector.h.


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