Stratax 0.2.0
Loading...
Searching...
No Matches
Conversions.hpp File Reference

Go to the source code of this file.

Functions

bool is_vector_shape (const stratax::core::Shape &shape)
bool is_matrix_shape (const stratax::core::Shape &shape)
stratax::core::Shape matrix_shape (const stratax::core::Shape &shape)
template<Array A>
stratax::container::Vector< typename A::value_type > to_vector (const A &arr)
 Converts an array-like object to a vector.
template<Array A>
stratax::container::Matrix< typename A::value_type > to_matrix (const A &arr)
 Converts an array-like object to a matrix.
template<Array A>
stratax::container::Tensor< typename A::value_type > to_tensor (const A &arr)
 Converts an array-like object to a tensor.
template<typename To, typename From>
requires Numeric<To> && Numeric<From>
stratax::container::Vector< To > astype (const stratax::container::Vector< From > &vec)
 Casts a vector to a different numeric value type.
template<typename To, typename From>
requires Numeric<To> && Numeric<From>
stratax::container::Matrix< To > astype (const stratax::container::Matrix< From > &mat)
 Casts a matrix to a different numeric value type.
template<typename To, typename From>
requires Numeric<To> && Numeric<From>
stratax::container::Tensor< To > astype (const stratax::container::Tensor< From > &tensor)
 Casts a tensor to a different numeric value type.

Function Documentation

◆ astype() [1/3]

template<typename To, typename From>
requires Numeric<To> && Numeric<From>
stratax::container::Matrix< To > astype ( const stratax::container::Matrix< From > & mat)

Casts a matrix to a different numeric value type.

Template Parameters
ToTarget numeric type.
FromSource numeric type.
Parameters
matSource matrix.
Returns
Matrix with each element cast to the target type.

Definition at line 195 of file Conversions.hpp.

◆ astype() [2/3]

template<typename To, typename From>
requires Numeric<To> && Numeric<From>
stratax::container::Tensor< To > astype ( const stratax::container::Tensor< From > & tensor)

Casts a tensor to a different numeric value type.

Template Parameters
ToTarget numeric type.
FromSource numeric type.
Parameters
tensorSource tensor.
Returns
Tensor with each element cast to the target type.

Definition at line 219 of file Conversions.hpp.

◆ astype() [3/3]

template<typename To, typename From>
requires Numeric<To> && Numeric<From>
stratax::container::Vector< To > astype ( const stratax::container::Vector< From > & vec)

Casts a vector to a different numeric value type.

Template Parameters
ToTarget numeric type.
FromSource numeric type.
Parameters
vecSource vector.
Returns
Vector with each element cast to the target type.

Definition at line 171 of file Conversions.hpp.

◆ is_matrix_shape()

bool is_matrix_shape ( const stratax::core::Shape & shape)
inline

Definition at line 34 of file Conversions.hpp.

◆ is_vector_shape()

bool is_vector_shape ( const stratax::core::Shape & shape)
inline

Definition at line 14 of file Conversions.hpp.

◆ matrix_shape()

stratax::core::Shape matrix_shape ( const stratax::core::Shape & shape)
inline

Definition at line 54 of file Conversions.hpp.

◆ to_matrix()

template<Array A>
stratax::container::Matrix< typename A::value_type > to_matrix ( const A & arr)

Converts an array-like object to a matrix.

Template Parameters
ASource array type.
Parameters
arrSource array.
Returns
Matrix containing the same values and shape.
Exceptions
Exceptions::DimensionErrorIf the source is not matrix-shaped.

Definition at line 118 of file Conversions.hpp.

◆ to_tensor()

template<Array A>
stratax::container::Tensor< typename A::value_type > to_tensor ( const A & arr)

Converts an array-like object to a tensor.

Template Parameters
ASource array type.
Parameters
arrSource array.
Returns
Tensor containing the same values and shape.

Definition at line 147 of file Conversions.hpp.

◆ to_vector()

template<Array A>
stratax::container::Vector< typename A::value_type > to_vector ( const A & arr)

Converts an array-like object to a vector.

Template Parameters
ASource array type.
Parameters
arrSource array.
Returns
Vector containing the same values and shape.
Exceptions
Exceptions::DimensionErrorIf the source is not rank 1.

Definition at line 87 of file Conversions.hpp.