1#ifndef TATOOINE_TENSOR_H
2#define TATOOINE_TENSOR_H
14template <arithmetic_or_complex ValueType, std::size_t... Dims>
17 base_tensor<tensor<ValueType, Dims...>, ValueType, Dims...> {
38 auto constexpr at(
integral auto const... is) ->
decltype(
auto) {
41 auto constexpr at(
integral auto const... is)
const ->
decltype(
auto) {
61 template <
typename... Is>
64 auto constexpr operator()(Is
const... is) ->
decltype(
auto) {
68 template <
typename... Is>
71 auto constexpr operator()(Is
const... is)
const ->
decltype(
auto) {
84 template <convertible_to<ValueType>... Ts>
86 sizeof...(Ts))
explicit constexpr tensor(Ts
const&... ts)
97 template <
typename FillReal>
98 requires is_arithmetic<ValueType>
101 template <
typename RandomReal,
typename Engine>
102 requires is_arithmetic<ValueType>
106 template <arithmetic RandomReal,
typename Engine>
110 template <arithmetic RandomReal,
typename Engine>
111 requires is_arithmetic<ValueType>
115 template <arithmetic RandomReal,
typename Engine>
116 requires is_arithmetic<ValueType>
120 template <static_tensor OtherTensor>
121 requires(same_dimensions<this_type, OtherTensor>())
122 explicit constexpr tensor(OtherTensor&& other)
125 template <static_tensor OtherTensor>
126 requires(same_dimensions<this_type, OtherTensor>())
127 constexpr auto operator=(OtherTensor&& other) ->
tensor& {
131 if (
this == &other.internal_tensor()) {
132 for (std::size_t col = 0; col <
dimension(1) - 1; ++col) {
133 for (std::size_t row = col + 1; row <
dimension(0); ++row) {
134 std::swap(
at(row, col),
at(col, row));
140 this->
assign(std::forward<OtherTensor>(other));
148 static constexpr auto fill(ValueType
const& t) {
152 template <
typename RandEng = std::mt19937_64>
154 RandEng&& eng = RandEng{std::random_device{}()}) {
158 template <
typename RandEng = std::mt19937_64>
159 static constexpr auto randn(ValueType mean = 0, ValueType stddev = 1,
160 RandEng&& eng = RandEng{std::random_device{}()}) {
164 template <
typename OtherT>
169 template <
typename F>
175 template <
typename F,
typename OtherTensor,
typename OtherT>
183template <std::size_t... Dimensions>
Definition: static_multidim_array.h:19
constexpr auto internal_container() -> auto &
Definition: static_multidim_array.h:253
constexpr void unary_operation(F &&f)
Definition: static_multidim_array.h:268
Definition: concepts.h:91
Definition: concepts.h:21
Definition: tensor_concepts.h:93
Definition: algorithm.h:6
constexpr auto max(A &&a, B &&b)
Definition: math.h:20
constexpr auto min(A &&a, B &&b)
Definition: math.h:15
Definition: base_tensor.h:23
static auto constexpr rank()
Definition: base_tensor.h:41
auto constexpr assign(Other &&other) -> void
Definition: base_tensor.h:82
ValueType value_type
Definition: base_tensor.h:24
static auto constexpr num_components()
Definition: base_tensor.h:43
static auto constexpr indices()
Definition: base_tensor.h:56
auto constexpr dimension() const
Definition: contracted_dynamic_tensor.h:36
Definition: binary_operation.h:10
constexpr auto operator()(integral_range auto const &indices) const -> const auto &
Definition: tensor.h:75
auto constexpr at(integral auto const ... is) const -> decltype(auto)
Definition: tensor.h:41
static constexpr auto zeros()
Definition: tensor.h:144
auto operator<(tensor< OtherT, Dims... > const &other) const
Definition: tensor.h:165
static constexpr auto randn(ValueType mean=0, ValueType stddev=1, RandEng &&eng=RandEng{std::random_device{}()})
Definition: tensor.h:159
static auto constexpr dimension(std::size_t const i)
Definition: base_tensor.h:49
constexpr auto operator=(tensor const &) -> tensor &=default
auto unary_operation(F &&f) -> auto &
Definition: tensor.h:170
auto constexpr at(einstein_notation::index auto const ... is) -> decltype(auto)
Definition: tensor.h:44
static constexpr auto fill(ValueType const &t)
Definition: tensor.h:148
auto binary_operation(F &&f, base_tensor< OtherTensor, OtherT, Dims... > const &other) -> decltype(auto)
Definition: tensor.h:176
static constexpr auto ones()
Definition: tensor.h:146
constexpr tensor(tensor const &)=default
constexpr auto at(integral_range auto const &indices) const -> auto const &
Definition: tensor.h:53
constexpr auto at(integral_range auto const &indices) -> auto &
Definition: tensor.h:57
constexpr tensor(Ts const &... ts)
Definition: tensor.h:86
constexpr tensor(tag::zeros_t zeros)
Definition: tensor.h:90
constexpr auto operator()(integral_range auto const &indices) -> auto &
Definition: tensor.h:80
auto constexpr at(integral auto const ... is) -> decltype(auto)
Definition: tensor.h:38
constexpr tensor(random::normal< RandomReal, Engine > &rand)
Definition: tensor.h:117
tensor< ValueType, Dims... > this_type
Definition: tensor.h:19
constexpr tensor(random::normal< RandomReal, Engine > &&rand)
Definition: tensor.h:112
constexpr tensor()=default
constexpr tensor(tag::fill< FillReal > f)
Definition: tensor.h:99
auto constexpr at(einstein_notation::index auto const ... is) const -> decltype(auto)
Definition: tensor.h:48
constexpr tensor(random::uniform< RandomReal, Engine > &&rand)
Definition: tensor.h:103
constexpr tensor(OtherTensor &&other)
Definition: tensor.h:122
constexpr auto operator=(tensor &&other) noexcept -> tensor &=default
static constexpr auto randu(ValueType min=0, ValueType max=1, RandEng &&eng=RandEng{std::random_device{}()})
Definition: tensor.h:153
typename tensor_parent_type::value_type value_type
Definition: tensor.h:21
constexpr tensor(tag::ones_t ones)
Definition: tensor.h:94
constexpr tensor(random::uniform< RandomReal, Engine > &rand)
Definition: tensor.h:107
constexpr tensor(tensor &&other) noexcept=default
type_list_at< this_type, I > at
Definition: type_list.h:269
Definition: index_order.h:17