diff options
Diffstat (limited to 'modules/codec/c++')
| -rw-r--r-- | modules/codec/c++/data.hpp | 4 | ||||
| -rw-r--r-- | modules/codec/c++/data_math.hpp | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index ae9d8eb..79a6ab8 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -171,6 +171,10 @@ public: constexpr data<Schema, encode::Native> operator-(const data<Schema, encode::Native>& rhs)const{ return {get() - rhs.get()}; } + + constexpr data<Schema, encode::Native> operator-() const { + return {-get()}; + } constexpr data<Schema, encode::Native>& operator++() { set(get() + static_cast<typename native_data_type<Schema>::type>(1)); diff --git a/modules/codec/c++/data_math.hpp b/modules/codec/c++/data_math.hpp index 48dae91..9d07eb3 100644 --- a/modules/codec/c++/data_math.hpp +++ b/modules/codec/c++/data_math.hpp @@ -131,6 +131,19 @@ 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() const { data<schema::Tensor<InnerChange, Dims...>, encode::Native> native_change; |
