Stratax 0.3.1
Loading...
Searching...
No Matches
Creation.hpp
1#pragma once
2
3#include <cstddef>
4
5#include <stratax/core/dtypes/Concepts.hpp>
6#include <stratax/containers/Matrix.hpp>
7#include <stratax/containers/Tensor.hpp>
8#include <stratax/containers/Vector.hpp>
9#include <stratax/core/Shape.hpp>
10
11namespace stratax::creation {
12
22template<DType T>
23[[nodiscard]]
25{
26 return stratax::container::Tensor<T>(shape, T{});
27}
28
37template<DType T>
38[[nodiscard]]
39stratax::container::Vector<T> zeros(std::size_t size)
40{
41 return stratax::container::Vector<T>(size, T{});
42}
43
54template<DType T>
55[[nodiscard]]
56stratax::container::Matrix<T> zeros(std::size_t rows, std::size_t cols)
57{
58 return stratax::container::Matrix<T>(rows, cols, T{});
59}
60
70template<DType T>
71[[nodiscard]]
73{
74 return stratax::container::Tensor<T>(shape, T{1});
75}
76
85template<DType T>
86[[nodiscard]]
87stratax::container::Vector<T> ones(std::size_t size)
88{
89 return stratax::container::Vector<T>(size, T{1});
90}
91
102template<DType T>
103[[nodiscard]]
104stratax::container::Matrix<T> ones(std::size_t rows, std::size_t cols)
105{
106 return stratax::container::Matrix<T>(rows, cols, T{1});
107}
108
119template<DType T>
120[[nodiscard]]
121stratax::container::Tensor<T> full(const stratax::core::Shape& shape, const T& value)
122{
123 return stratax::container::Tensor<T>(shape, value);
124}
125
135template<DType T>
136[[nodiscard]]
137stratax::container::Vector<T> full(std::size_t size, const T& value)
138{
139 return stratax::container::Vector<T>(size, value);
140}
141
153template<DType T>
154[[nodiscard]]
155stratax::container::Matrix<T> full(std::size_t rows, std::size_t cols, const T& value)
156{
157 return stratax::container::Matrix<T>(rows, cols, value);
158}
159
173template<DType T>
174[[nodiscard]]
175stratax::container::Matrix<T> identity(std::size_t size)
176{
177 stratax::container::Matrix<T> result(size, size, T{});
178
179 for (std::size_t i = 0; i < size; ++i)
180 {
181 result(i, i) = T{1};
182 }
183
184 return result;
185}
186
187}
Two-dimensional owning array of numeric values.
Definition Matrix.hpp:46
Arbitrary-rank owning array of numeric values.
Definition Tensor.hpp:50
One-dimensional owning array of numeric values.
Definition Vector.hpp:44
Stores the dimensions of a multidimensional array.
Definition Shape.hpp:33