diff options
Diffstat (limited to 'modules/codec/c++/data_math.hpp')
| -rw-r--r-- | modules/codec/c++/data_math.hpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/codec/c++/data_math.hpp b/modules/codec/c++/data_math.hpp index 1a56bd0..9d07eb3 100644 --- a/modules/codec/c++/data_math.hpp +++ b/modules/codec/c++/data_math.hpp @@ -131,8 +131,21 @@ public: return c; } + data<schema::Tensor<Inner, Dims...>, encode::Native> operator-() const { + data<schema::Tensor<Inner, Dims...>, encode::Native> c; + + rank_iterator<Dims...>::in_fixed_bounds([&](const data<schema::FixedArray<schema::UInt64, sizeof...(Dims)>, encode::Native>& index) -> error_or<void>{ + c.at(index) = -at(index); + return make_void(); + }); + + return c; + } + + + template<typename InnerChange> - data<schema::Tensor<InnerChange, Dims...>, encode::Native> cast_to(){ + data<schema::Tensor<InnerChange, Dims...>, encode::Native> cast_to() const { data<schema::Tensor<InnerChange, Dims...>, encode::Native> native_change; rank_iterator<Dims...>::in_fixed_bounds([&](const data<schema::FixedArray<schema::UInt64, sizeof...(Dims)>, encode::Native>& index) -> error_or<void>{ native_change.at(index) = at(index).template cast_to<InnerChange>(); |
