Stratax 0.2.0
Loading...
Searching...
No Matches
Creation.hpp
1#pragma once
2
3#include <cstddef>
4
5#include <stratax/core/containers/Matrix.hpp>
6#include <stratax/core/containers/Tensor.hpp>
7#include <stratax/core/containers/Vector.hpp>
8#include <stratax/core/Concepts.hpp>
9#include <stratax/core/containers/Shape.hpp>
10
11namespace creation {
12
21template<typename T>
22requires Numeric<T>
23stratax::container::Tensor<T> zeros(const stratax::core::Shape& shape)
24{
25 return stratax::container::Tensor<T>(shape, T{});
26}
27
36template<typename T>
37requires Numeric<T>
38stratax::container::Tensor<T> ones(const stratax::core::Shape& shape)
39{
40 return stratax::container::Tensor<T>(shape, T{1});
41}
42
52template<typename T>
53requires Numeric<T>
54stratax::container::Tensor<T> full(const stratax::core::Shape& shape, const T& value)
55{
56 return stratax::container::Tensor<T>(shape, value);
57}
58
67template<typename T>
68requires Numeric<T>
69stratax::container::Tensor<T> identity(const std::size_t size)
70{
71 auto I = zeros<T>({size, size});
72 for (std::size_t i = 0; i < size; ++i)
73 {
74 I(i, i) = T{1};
75 }
76
77 return I;
78}
79
80}