Stratax
Scientific computing containers and operations
Toggle main menu visibility
Loading...
Searching...
No Matches
Creation.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstddef>
4
5
#include <
stratax/containers/Matrix.hpp
>
6
#include <
stratax/containers/Tensor.hpp
>
7
#include <
stratax/containers/Vector.hpp
>
8
#include <
stratax/core/Concepts.hpp
>
9
#include <
stratax/core/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
}
Concepts.hpp
Matrix.hpp
Shape.hpp
Tensor.hpp
Vector.hpp
stratax::container::Tensor
Definition
Tensor.hpp:30
stratax::core::Shape
Stores a list of dimension lengths for an array shape.
Definition
Shape.hpp:20
Numeric
Matches all scalar types supported by Stratax numeric containers.
Definition
Concepts.hpp:152
creation
Definition
Creation.hpp:11
creation::zeros
stratax::container::Tensor< T > zeros(const stratax::core::Shape &shape)
Creates a tensor filled with zeros.
Definition
Creation.hpp:23
creation::full
stratax::container::Tensor< T > full(const stratax::core::Shape &shape, const T &value)
Creates a tensor filled with a constant value.
Definition
Creation.hpp:54
creation::identity
stratax::container::Tensor< T > identity(const std::size_t size)
Creates a square identity tensor.
Definition
Creation.hpp:69
creation::ones
stratax::container::Tensor< T > ones(const stratax::core::Shape &shape)
Creates a tensor filled with ones.
Definition
Creation.hpp:38
include
stratax
containers
Creation.hpp
Generated by
1.17.0