Skip to content

Commit

Permalink
fmk - adding #include<cmath> and using std:: before isnan and isinf i…
Browse files Browse the repository at this point in the history
…n nataf_gsa files
  • Loading branch information
fmckenna committed Oct 4, 2024
1 parent a59320d commit d475799
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
3 changes: 2 additions & 1 deletion modules/performUQ/SimCenterUQ/nataf_gsa/betaDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>

using std::vector;

Expand Down Expand Up @@ -194,7 +195,7 @@ void betaDist::checkParams()
double mean = getMean();
vector<double> par = getParam();

if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMSG = "Error running UQ engine: stdandard deviation of " + name + " must be greater than 0 ";
theErrorFile.write(errMSG);
Expand Down
5 changes: 3 additions & 2 deletions modules/performUQ/SimCenterUQ/nataf_gsa/chiSquaredDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include "nlopt.hpp"
#include "boost/math/distributions/normal.hpp" // for normal_distribution

Expand Down Expand Up @@ -151,7 +152,7 @@ void chiSquaredDist::checkParams()
double mean = getMean();
vector<double> par = getParam();

if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMSG = "Error running UQ engine: stdandard deviation of " + name + " must be greater than 0 ";
theErrorFile.write(errMSG);
Expand Down Expand Up @@ -250,4 +251,4 @@ double nnlChiSq(unsigned n, const double* x, double* grad, void* my_func_data)
}
return nll;

}
}
3 changes: 2 additions & 1 deletion modules/performUQ/SimCenterUQ/nataf_gsa/exponentialDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include "nlopt.hpp"

using std::vector;
Expand Down Expand Up @@ -154,7 +155,7 @@ exponentialDist::~exponentialDist() {}
void exponentialDist::checkParams()
{
double std = getStd();
if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMSG = "Error running UQ engine: stdandard deviation of " + name + " should be greater than 0 ";
theErrorFile.write(errMSG);
Expand Down
3 changes: 2 additions & 1 deletion modules/performUQ/SimCenterUQ/nataf_gsa/gammaDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cmath>
#include "nlopt.hpp"
#include "boost/math/distributions/normal.hpp" // for normal_distribution

Expand Down Expand Up @@ -173,7 +174,7 @@ gammaDist::~gammaDist() {}
void gammaDist::checkParams()
{
double std = getStd();
if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMSG = "Error running UQ engine: stdandard deviation of " + name + " should be greater than 0 ";
theErrorFile.write(errMSG);
Expand Down
3 changes: 2 additions & 1 deletion modules/performUQ/SimCenterUQ/nataf_gsa/gumbelDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cmath>
#include "nlopt.hpp"
//#include <gsl/gsl>

Expand Down Expand Up @@ -220,7 +221,7 @@ void gumbelDist::checkParams()
double mean = getMean();
vector<double> par = getParam();

if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMsg = "Error running UQ engine: stdandard deviation of " + name + " distribution must be greater than 0 ";
theErrorFile.write(errMsg);
Expand Down
3 changes: 2 additions & 1 deletion modules/performUQ/SimCenterUQ/nataf_gsa/lognormalDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cmath>
#include "nlopt.hpp"

#include <iomanip>
Expand Down Expand Up @@ -139,7 +140,7 @@ lognormalDist::~lognormalDist() {}
void lognormalDist::checkParams()
{
double std = getStd();
if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMsg = "Error running UQ engine: stdandard deviation of " + name + " should be greater than 0 ";
theErrorFile.write(errMsg);
Expand Down
5 changes: 3 additions & 2 deletions modules/performUQ/SimCenterUQ/nataf_gsa/runGSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

#include "runGSA.h"
#include "ERANataf.h"
#include <cmath>
#include <iterator>
using namespace arma::newarp;

Expand Down Expand Up @@ -895,7 +896,7 @@ void runGSA::runSingleCombGSA(vector<vector<double>> gmat, int Ko, vector<int> c

for (int nq = 0; nq < nqoi_eff; nq++) {
//printf("GSA nq=%i, Si=%.2f, %c \n", nq + 1, Si[nq], Opt);
if (isinf(Si[nq]) || isnan(Si[nq]))
if (std::isinf(Si[nq]) || std::isnan(Si[nq]))
{
Si[nq] = -100;
}
Expand Down Expand Up @@ -1117,7 +1118,7 @@ void runGSA::runSingleGSA(vector<double> gvec,int Ko,char Opt, vector<double>& S

printf("GSA i=%i, Si=%.2f, K=%i, %c \n", nc + 1, Si[nc], Kos, Opt);

if (isinf(Si[nc]) || isnan(Si[nc]))
if (std::isinf(Si[nc]) || std::isnan(Si[nc]))
{
Si[nc] = -100;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cmath>
#include "nlopt.hpp"
#include <iomanip>

Expand Down Expand Up @@ -202,7 +203,7 @@ void truncExponentialDist::checkParams()
double mean = getMean();
vector<double> par = getParam();

if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMsg = "Error running UQ engine: stdandard deviation of " + name + " distribution must be greater than 0 ";
theErrorFile.write(errMsg);
Expand Down
3 changes: 2 additions & 1 deletion modules/performUQ/SimCenterUQ/nataf_gsa/weibullDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cmath>
#include "nlopt.hpp"
#include <iomanip>
// bet is lamb, an, - follow ERA notation
Expand Down Expand Up @@ -185,7 +186,7 @@ void weibullDist::checkParams()
double mean = getMean();
vector<double> par = getParam();

if (isnan(std) || isinf(std) || std <= 0)
if (std::isnan(std) || std::isinf(std) || std <= 0)
{
std::string errMsg = "Error running UQ engine: stdandard deviation of " + name + " must be greater than 0 ";
theErrorFile.write(errMsg);
Expand Down

0 comments on commit d475799

Please sign in to comment.