Stratax 0.4.0rc1
Loading...
Searching...
No Matches
Creation.hpp File Reference

Value-filled owning container creation. More...

Include dependency graph for Creation.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<DType T>
stratax::container::Tensor< T > stratax::creation::zeros (const stratax::core::Shape &shape)
 Creates a tensor filled with additive identity values.
 
template<DType T>
stratax::container::Vector< T > stratax::creation::zeros (std::size_t size)
 Creates a vector filled with additive identity values.
 
template<DType T>
stratax::container::Matrix< T > stratax::creation::zeros (std::size_t rows, std::size_t cols)
 Creates a matrix filled with additive identity values.
 
template<DType T>
stratax::container::Tensor< T > stratax::creation::ones (const stratax::core::Shape &shape)
 Creates a tensor filled with multiplicative identity values.
 
template<DType T>
stratax::container::Vector< T > stratax::creation::ones (std::size_t size)
 Creates a vector filled with multiplicative identity values.
 
template<DType T>
stratax::container::Matrix< T > stratax::creation::ones (std::size_t rows, std::size_t cols)
 Creates a matrix filled with multiplicative identity values.
 
template<DType T>
stratax::container::Tensor< T > stratax::creation::full (const stratax::core::Shape &shape, const T &value)
 Creates a tensor filled with a specified value.
 
template<DType T>
stratax::container::Vector< T > stratax::creation::full (std::size_t size, const T &value)
 Creates a vector filled with a specified value.
 
template<DType T>
stratax::container::Matrix< T > stratax::creation::full (std::size_t rows, std::size_t cols, const T &value)
 Creates a matrix filled with a specified value.
 
template<DType T>
stratax::container::Matrix< T > stratax::creation::identity (std::size_t size)
 Creates a square identity matrix.
 

Detailed Description

Value-filled owning container creation.

Definition in file Creation.hpp.

Function Documentation

◆ full() [1/3]

template<DType T>
stratax::container::Tensor< T > stratax::creation::full ( const stratax::core::Shape &  shape,
const T &  value 
)

Creates a tensor filled with a specified value.

Template Parameters
TSupported element dtype, including bool.
Parameters
shapeShape of the resulting tensor.
valueValue copied into every element.
Returns
Owning tensor with shape filled with value.
Exceptions
Exceptions::DimensionErrorIf element-count or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(shape.elements() + shape.rank()).

Definition at line 124 of file Creation.hpp.

◆ full() [2/3]

template<DType T>
stratax::container::Matrix< T > stratax::creation::full ( std::size_t  rows,
std::size_t  cols,
const T &  value 
)

Creates a matrix filled with a specified value.

Template Parameters
TSupported element dtype, including bool.
Parameters
rowsNumber of result rows.
colsNumber of result columns.
valueValue copied into every element.
Returns
Owning matrix of shape {rows, cols} filled with value.
Exceptions
Exceptions::DimensionErrorIf element-count or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(rows * cols).

Definition at line 158 of file Creation.hpp.

◆ full() [3/3]

template<DType T>
stratax::container::Vector< T > stratax::creation::full ( std::size_t  size,
const T &  value 
)

Creates a vector filled with a specified value.

Template Parameters
TSupported element dtype, including bool.
Parameters
sizeNumber of elements in the resulting vector.
valueValue copied into every element.
Returns
Owning rank-one vector containing size copies of value.
Exceptions
std::bad_allocIf result allocation fails.
Complexity
O(size).

Definition at line 140 of file Creation.hpp.

◆ identity()

template<DType T>
stratax::container::Matrix< T > stratax::creation::identity ( std::size_t  size)

Creates a square identity matrix.

Off-diagonal elements are initialized to T{} and each diagonal element is assigned T{1}.

Template Parameters
TSupported element dtype, including bool.
Parameters
sizeNumber of rows and columns.
Returns
Owning matrix of shape {size, size} containing the identity.
Exceptions
Exceptions::DimensionErrorIf size * size or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(size * size).

Definition at line 178 of file Creation.hpp.

◆ ones() [1/3]

template<DType T>
stratax::container::Tensor< T > stratax::creation::ones ( const stratax::core::Shape &  shape)

Creates a tensor filled with multiplicative identity values.

Template Parameters
TSupported element dtype, including bool.
Parameters
shapeShape of the resulting tensor.
Returns
Owning tensor with shape whose elements equal T{1}.
Exceptions
Exceptions::DimensionErrorIf element-count or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(shape.elements() + shape.rank()).

Definition at line 75 of file Creation.hpp.

◆ ones() [2/3]

template<DType T>
stratax::container::Matrix< T > stratax::creation::ones ( std::size_t  rows,
std::size_t  cols 
)

Creates a matrix filled with multiplicative identity values.

Template Parameters
TSupported element dtype, including bool.
Parameters
rowsNumber of result rows.
colsNumber of result columns.
Returns
Owning matrix of shape {rows, cols} filled with T{1}.
Exceptions
Exceptions::DimensionErrorIf element-count or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(rows * cols).

Definition at line 107 of file Creation.hpp.

◆ ones() [3/3]

template<DType T>
stratax::container::Vector< T > stratax::creation::ones ( std::size_t  size)

Creates a vector filled with multiplicative identity values.

Template Parameters
TSupported element dtype, including bool.
Parameters
sizeNumber of elements in the resulting vector.
Returns
Owning rank-one vector containing size copies of T{1}.
Exceptions
std::bad_allocIf result allocation fails.
Complexity
O(size).

Definition at line 90 of file Creation.hpp.

◆ zeros() [1/3]

template<DType T>
stratax::container::Tensor< T > stratax::creation::zeros ( const stratax::core::Shape &  shape)

Creates a tensor filled with additive identity values.

Template Parameters
TSupported element dtype, including bool.
Parameters
shapeShape of the resulting tensor.
Returns
Owning tensor with shape whose elements equal T{}.
Exceptions
Exceptions::DimensionErrorIf element-count or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(shape.elements() + shape.rank()).

Definition at line 27 of file Creation.hpp.

◆ zeros() [2/3]

template<DType T>
stratax::container::Matrix< T > stratax::creation::zeros ( std::size_t  rows,
std::size_t  cols 
)

Creates a matrix filled with additive identity values.

Template Parameters
TSupported element dtype, including bool.
Parameters
rowsNumber of result rows.
colsNumber of result columns.
Returns
Owning matrix of shape {rows, cols} filled with T{}.
Exceptions
Exceptions::DimensionErrorIf element-count or stride arithmetic overflows.
std::bad_allocIf result allocation fails.
Complexity
O(rows * cols).

Definition at line 59 of file Creation.hpp.

◆ zeros() [3/3]

template<DType T>
stratax::container::Vector< T > stratax::creation::zeros ( std::size_t  size)

Creates a vector filled with additive identity values.

Template Parameters
TSupported element dtype, including bool.
Parameters
sizeNumber of elements in the resulting vector.
Returns
Owning rank-one vector containing size copies of T{}.
Exceptions
std::bad_allocIf result allocation fails.
Complexity
O(size).

Definition at line 42 of file Creation.hpp.