Skip to content

Commit

Permalink
Add check for infinite nodes in LayeredModelBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
uphoffc committed Mar 3, 2021
1 parent 0189ebe commit 81baddf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/easi/component/LayeredModelBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#ifndef EASI_COMPONENT_LAYEREDMODELBUILDER_H_
#define EASI_COMPONENT_LAYEREDMODELBUILDER_H_

#include <cmath>
#include <map>
#include <string>
#include <sstream>
Expand Down Expand Up @@ -101,6 +102,13 @@ void LayeredModelBuilder::setNodes(Nodes const& nodes) {
}

Component* LayeredModelBuilder::getResult() {
for (auto it = m_nodes.begin(); it != m_nodes.end(); ++it) {
if (std::isnan(it->first)) {
throw std::invalid_argument("Not a number nodes are forbidden.");
} else if (m_interpolationType == Linear && std::isinf(it->first)) {
throw std::invalid_argument("Infinite nodes are forbidden for interpolation = linear.");
}
}
Nodes::iterator lower = m_nodes.end();
Nodes::iterator upper;
for (upper = m_nodes.begin(); upper != m_nodes.end(); ++upper) {
Expand Down

0 comments on commit 81baddf

Please sign in to comment.