diff --git a/include/BSMPT/utility/utility.h b/include/BSMPT/utility/utility.h index bffad273..6d413010 100644 --- a/include/BSMPT/utility/utility.h +++ b/include/BSMPT/utility/utility.h @@ -133,7 +133,8 @@ std::vector operator+(const std::vector &a, const std::vector &b) template std::vector operator-(const std::vector &a, const std::vector &b) { - assert(a.size() == b.size()); + if (a.size() != b.size()) + throw("Vector cannot be subtracted. Must have the same size."); std::vector result; result.reserve(a.size()); @@ -184,7 +185,9 @@ std::vector operator/(const std::vector &a, const T2 &b) template T operator*(const std::vector &a, const std::vector &b) { - assert(a.size() == b.size()); + if (a.size() != b.size()) + throw( + "Dot product between vectors cannot be done. Must have the same size."); std::vector result; result.reserve(a.size()); @@ -207,7 +210,9 @@ template std::vector operator*(const std::vector> &a, const std::vector &b) { - assert(a.size() == b.size()); + if (a.size() != b.size()) + throw("Multiplication of matrix with vector cannot be done. Must have the " + "same size."); std::vector result; result.reserve(a.size());