Skip to content
Snippets Groups Projects
Commit 88b53c6c authored by Martin Beseda's avatar Martin Beseda
Browse files

FIX: Fixed bug with division by 0.

parent 66ed16af
No related branches found
No related tags found
No related merge requests found
......@@ -108,7 +108,15 @@ namespace lib4neuro {
"is of different dimensionality!");
}
double frac = (upper_bound - lower_bound) / (size - 1);
double frac;
if(size < 1) {
THROW_INVALID_ARGUMENT_ERROR("Size of added data has to be >=1 !");
} else if (size == 1) {
frac = 1;
} else {
frac = (upper_bound - lower_bound) / (size - 1);
}
std::vector<double> inp, out;
out = {output};
......@@ -128,9 +136,17 @@ namespace lib4neuro {
std::vector<std::vector<double>> grid;
std::vector<double> tmp;
double frac;
if(no_elems_in_one_dim < 1) {
THROW_INVALID_ARGUMENT_ERROR("Number of elements in one dimension has to be >=1 !");
}
for (unsigned int i = 0; i < bounds.size(); i += 2) {
frac = (bounds[i] + bounds[i + 1]) / (no_elems_in_one_dim - 1);
if (no_elems_in_one_dim == 1) {
frac = 1;
} else {
frac = (bounds[i] - bounds[i+1]) / (no_elems_in_one_dim - 1);
}
tmp.clear();
for (double j = bounds[i]; j <= bounds[i + 1]; j += frac) {
tmp.emplace_back(j);
......
......@@ -94,7 +94,7 @@ namespace lib4neuro {
* Constructor for an empty DataSet
*/
LIB4NEURO_API DataSet();
/**
* Constructor reading data from the file
* @param file_path Path to the file with stored data set
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment