Commit 2e057976 authored by Damien L-G's avatar Damien L-G

Throw an invalid argument exception rather instead of having the assertion

parent 8ae6021b
Pipeline #57 canceled with stages
......@@ -3,7 +3,8 @@
#include <gsl/gsl_spline2d.h>
#include <cassert>
#include <exception>
#include <sstream>
#include <vector>
namespace noname {
......@@ -55,7 +56,16 @@ public:
Spline2D(std::vector<double> const &x, std::vector<double> const &y,
std::vector<double> const &z)
: _spline{Interp2DTypeTraits<T>::value(), x.size(), y.size()} {
assert(z.size() == x.size() * y.size());
if (z.size() != x.size() * y.size()) {
std::stringstream ss;
ss << "za the array of function values passed to the function that "
"initializes the interpolation object has size "
<< z.size() << " != " << x.size() << " * " << y.size() << " where "
<< x.size() << " and " << y.size()
<< " are the size of the array xa and ya of the x and y grid points "
"respectively";
throw std::invalid_argument(ss.str());
}
gsl_spline2d_init(_spline, x.data(), y.data(), z.data(), x.size(),
y.size());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment