Skip to content

Commit

Permalink
overload + and - operations for valarray_base
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-pwn committed May 3, 2024
1 parent 65e1680 commit 4d117b8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cp-algo/linalg/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ namespace cp_algo::linalg {
}
};

template<class vec, typename base>
vec operator+(valarray_base<vec, base> const& a, valarray_base<vec, base> const& b) {
return *static_cast<std::valarray<base> const*>(&a)
+ *static_cast<std::valarray<base> const*>(&b);
}
template<class vec, typename base>
vec operator-(valarray_base<vec, base> const& a, valarray_base<vec, base> const& b) {
return *static_cast<std::valarray<base> const*>(&a)
- *static_cast<std::valarray<base> const*>(&b);
}

template<class vec, typename base>
struct vec_base: valarray_base<vec, base> {
using Base = valarray_base<vec, base>;
Expand Down

0 comments on commit 4d117b8

Please sign in to comment.