Stratax
Scientific computing containers and operations
Loading...
Searching...
No Matches
Conversions.hpp File Reference

Go to the source code of this file.

Functions

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 129 of file Conversions.hpp.

References stratax::container::Matrix< T >::shape(), and stratax::container::Matrix< T >::size().

◆ 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 153 of file Conversions.hpp.

References stratax::container::Tensor< T >::shape(), and stratax::container::Tensor< T >::size().

◆ 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 105 of file Conversions.hpp.

References stratax::container::Vector< T >::shape(), and stratax::container::Vector< T >::size().

◆ 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 rank 2.

Definition at line 54 of file Conversions.hpp.

References stratax::core::validation::require_rank().

◆ 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 81 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 25 of file Conversions.hpp.

References stratax::core::validation::require_rank().