Stratax 0.4.0rc1
Loading...
Searching...
No Matches
Creation.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <cstddef>
7
13
14namespace stratax::creation {
15
25template<DType T>
26[[nodiscard]]
31
40template<DType T>
41[[nodiscard]]
43{
44 return stratax::container::Vector<T>(size, T{});
45}
46
57template<DType T>
58[[nodiscard]]
59stratax::container::Matrix<T> zeros(std::size_t rows, std::size_t cols)
60{
61 return stratax::container::Matrix<T>(rows, cols, T{});
62}
63
73template<DType T>
74[[nodiscard]]
79
88template<DType T>
89[[nodiscard]]
91{
92 return stratax::container::Vector<T>(size, T{1});
93}
94
105template<DType T>
106[[nodiscard]]
107stratax::container::Matrix<T> ones(std::size_t rows, std::size_t cols)
108{
109 return stratax::container::Matrix<T>(rows, cols, T{1});
110}
111
122template<DType T>
123[[nodiscard]]
125{
126 return stratax::container::Tensor<T>(shape, value);
127}
128
138template<DType T>
139[[nodiscard]]
140stratax::container::Vector<T> full(std::size_t size, const T& value)
141{
142 return stratax::container::Vector<T>(size, value);
143}
144
156template<DType T>
157[[nodiscard]]
158stratax::container::Matrix<T> full(std::size_t rows, std::size_t cols, const T& value)
159{
160 return stratax::container::Matrix<T>(rows, cols, value);
161}
162
176template<DType T>
177[[nodiscard]]
179{
180 stratax::container::Matrix<T> result(size, size, T{});
181
182 for (std::size_t i = 0; i < size; ++i)
183 {
184 result(i, i) = T{1};
185 }
186
187 return result;
188}
189
190}
Dtype and array interface concepts.
stratax::container::Tensor< T > ones(const stratax::core::Shape &shape)
Creates a tensor filled with multiplicative identity values.
Definition Creation.hpp:75
stratax::container::Tensor< T > zeros(const stratax::core::Shape &shape)
Creates a tensor filled with additive identity values.
Definition Creation.hpp:27
stratax::container::Matrix< T > identity(std::size_t size)
Creates a square identity matrix.
Definition Creation.hpp:178
stratax::container::Tensor< T > full(const stratax::core::Shape &shape, const T &value)
Creates a tensor filled with a specified value.
Definition Creation.hpp:124
Rank-two owning arrays.
Immutable dimension metadata and checked row-major strides.
Arbitrary-rank owning arrays; rank zero is empty.
Rank-one owning arrays.
Two-dimensional owning array of supported dtype values.
Definition Matrix.hpp:49
Arbitrary-rank owning array of supported dtype values.
Definition Tensor.hpp:54
One-dimensional owning array of supported dtype values.
Definition Vector.hpp:47
Stores the dimensions of a multidimensional array.
Definition Shape.hpp:36