Stratax
0.2.0
Toggle main menu visibility
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
11
namespace
creation {
12
21
template
<
typename
T>
22
requires
Numeric<T>
23
stratax::container::Tensor<T> zeros(
const
stratax::core::Shape& shape)
24
{
25
return
stratax::container::Tensor<T>(shape, T{});
26
}
27
36
template
<
typename
T>
37
requires
Numeric<T>
38
stratax::container::Tensor<T> ones(
const
stratax::core::Shape& shape)
39
{
40
return
stratax::container::Tensor<T>(shape, T{1});
41
}
42
52
template
<
typename
T>
53
requires
Numeric<T>
54
stratax::container::Tensor<T> full(
const
stratax::core::Shape& shape,
const
T& value)
55
{
56
return
stratax::container::Tensor<T>(shape, value);
57
}
58
67
template
<
typename
T>
68
requires
Numeric<T>
69
stratax::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
}
include
stratax
core
algorithms
Creation.hpp
Generated by
1.17.0