Commit 70434ca3 authored by snuverink_j's avatar snuverink_j
Browse files

use c++11 std__math methods instead of own classes

parent ee231a93
......@@ -25,8 +25,8 @@
#include "Parser/Statement.h"
#include "Utilities/Options.h"
#include "Utilities/ParseError.h"
#include "Utilities/Round.h"
#include <cmath>
#include <iostream>
#include <vector>
......@@ -100,7 +100,7 @@ void Object::parse(Statement &stat) {
if(Attribute *attr = findAttribute(name)) {
if(stat.delimiter('[')) {
int index = int(Round(Expressions::parseRealConst(stat)));
int index = int(std::round(Expressions::parseRealConst(stat)));
Expressions::parseDelimiter(stat, ']');
if(stat.delimiter('=')) {
......
......@@ -53,8 +53,6 @@
#include "Physics/Physics.h"
#include "Utilities/NumToStr.h"
class Beamline;
class PartData;
using Physics::c;
......@@ -678,7 +676,7 @@ namespace {
zt = ::implicitIntStep(zt, f, gradf, ya * dsc, nx);
} catch(ConvergenceError &cnverr) {
if(++ci > cx) {
std::string msg = "Convergence not achieved within " + NumToStr<int>(cx) + " cuts of step-size!";
std::string msg = "Convergence not achieved within " + std::to_string(cx) + " cuts of step-size!";
throw ConvergenceError("ThickMapper::implicitInt4()", msg);
}
//std::cerr << " cutting step size in half" << std::endl;
......@@ -722,7 +720,7 @@ namespace {
int ni = 0;
while(bcount < PSdim) {
if(ni == nx) {
std::string msg = "Convergence not achieved within " + NumToStr<int>(nx) + " iterations!";
std::string msg = "Convergence not achieved within " + std::to_string(nx) + " iterations!";
throw ConvergenceError("ThickMapper::implicitIntStep()", msg);
}
......
......@@ -31,7 +31,6 @@
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/ParseError.h"
#include "Utilities/Round.h"
#include "Utilities/Util.h"
#include <cmath>
......@@ -404,7 +403,7 @@ void OpalElement::parse(Statement &stat) {
}
if(stat.delimiter('[')) {
int index = int(Round(Expressions::parseRealConst(stat)));
int index = int(std::round(Expressions::parseRealConst(stat)));
Expressions::parseDelimiter(stat, ']');
if(stat.delimiter('=')) {
......
......@@ -51,9 +51,6 @@
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/ParseError.h"
#include "Utilities/CLRangeError.h"
#include "Utilities/Round.h"
#include "Utilities/Truncate.h"
#include "ValueDefinitions/BoolConstant.h"
#include <algorithm>
#include <cassert>
......@@ -183,8 +180,8 @@ namespace Expressions {
// ----------------------------------------------------------------------
static const TFunction1<double, double> table1[] = {
{ "TRUNC", -1, Truncate },
{ "ROUND", -1, Round },
{ "TRUNC", -1, std::trunc },
{ "ROUND", -1, std::round },
{ "FLOOR", -1, std::floor },
{ "CEIL", -1, std::ceil },
{ "SIGN", -1, Sign },
......@@ -448,7 +445,6 @@ namespace Expressions {
return new AList<bool>(array);
}
PtrToArray<double> parseRealArray(Statement &stat) {
PtrToArray<double> result;
PtrToArray<double> second;
......@@ -549,7 +545,7 @@ namespace Expressions {
std::string name = parseString(stat, "Expected <name> or '#'.");
int occurrence = 1;
if(stat.delimiter('[')) {
occurrence = int(Round(parseRealConst(stat)));
occurrence = int(std::round(parseRealConst(stat)));
parseDelimiter(stat, ']');
if(occurrence <= 0) {
......@@ -593,7 +589,7 @@ namespace Expressions {
int index = 0;
if(stat.delimiter('[')) {
index = int(Round(parseRealConst(stat)));
index = int(std::round(parseRealConst(stat)));
parseDelimiter(stat, ']');
if(index <= 0) {
......@@ -1051,7 +1047,7 @@ namespace Expressions {
parseDelimiter(stat, '(');
// Read the array index set.
int frst = int(Round(parseRealConst(stat)));
int frst = int(std::round(parseRealConst(stat)));
int last = 1;
int step = 1;
......@@ -1059,9 +1055,9 @@ namespace Expressions {
last = frst;
frst = 1;
} else if(stat.delimiter(':')) {
last = int(Round(parseRealConst(stat)));
last = int(std::round(parseRealConst(stat)));
if(stat.delimiter(':')) {
step = int(Round(parseRealConst(stat)));
step = int(std::round(parseRealConst(stat)));
}
parseDelimiter(stat, ',');
} else {
......
......@@ -21,8 +21,8 @@
#include "AbstractObjects/Expressions.h"
#include "Utilities/CLRangeError.h"
#include "Utilities/OpalException.h"
#include "Utilities/Round.h"
#include <cerrno>
#include <cmath>
#include <iosfwd>
#include <vector>
......@@ -99,7 +99,7 @@ namespace Expressions {
template <class T> inline
T Indexer<T>::evaluate() const {
std::vector<T> op1 = lft->evaluate();
int op2 = int(Round(rgt->evaluate()));
int op2 = int(std::round(rgt->evaluate()));
if(op2 <= 0 || static_cast<unsigned>(op2) > op1.size()) {
throw CLRangeError("Expressions::Indexer()", "Index out of range.");
......
......@@ -25,8 +25,8 @@
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/ParseError.h"
#include "Utilities/Round.h"
#include <vector>
#include <iostream>
#include <string>
// Class ConstraintCmd
......
......@@ -23,7 +23,6 @@
#include "Algebra/Vector.h"
#include "Attributes/Attributes.h"
#include "Match/Match.h"
#include "Utilities/Round.h"
#include <algorithm>
#include <cmath>
#include <cfloat>
......@@ -80,7 +79,7 @@ void LMDif::execute() {
// Fetch command attributes.
double tol = max(DBL_EPSILON, Attributes::getReal(itsAttr[TOLERANCE]));
int nfcnmax = int(Round(Attributes::getReal(itsAttr[CALLS])));
int nfcnmax = int(std::round(Attributes::getReal(itsAttr[CALLS])));
// Initialize.
double fnorm = 0.0;
......
......@@ -19,8 +19,7 @@
#include "Match/MatchOption.h"
#include "Attributes/Attributes.h"
#include "Match/Match.h"
#include "Utilities/Round.h"
#include <cmath>
// Class MatchOption
// ------------------------------------------------------------------------
......@@ -50,6 +49,6 @@ MatchOption *MatchOption::clone(const std::string &name) {
void MatchOption::execute() {
int level = int(Round(Attributes::getReal(itsAttr[0])));
int level = int(std::round(Attributes::getReal(itsAttr[0])));
Match::block->setPrintLevel(level);
}
\ No newline at end of file
......@@ -24,7 +24,6 @@
#include "Algebra/Vector.h"
#include "Attributes/Attributes.h"
#include "Match/Match.h"
#include "Utilities/Round.h"
#include <algorithm>
#include <cmath>
#include <cfloat>
......@@ -79,7 +78,7 @@ void Migrad::execute() {
// fetch command attributes.
double tol = max(Attributes::getReal(itsAttr[TOLERANCE]), DBL_EPSILON);
int nfcnmax = int(Round(Attributes::getReal(itsAttr[CALLS])));
int nfcnmax = int(std::round(Attributes::getReal(itsAttr[CALLS])));
// Working vectors.
int n = Match::block->countVariables();
......
......@@ -23,7 +23,6 @@
#include "Attributes/Attributes.h"
#include "Match/Match.h"
#include "Utilities/OpalException.h"
#include "Utilities/Round.h"
#include <cfloat>
#include <cmath>
#include <numeric>
......@@ -115,7 +114,7 @@ void Simplex::execute() {
state = CONVERGED;
} else {
// Fetch command attributes.
int nfcnmax = int(Round(Attributes::getReal(itsAttr[CALLS])));
int nfcnmax = int(std::round(Attributes::getReal(itsAttr[CALLS])));
// Set up the simplex.
Fsim = Array1D<double>(n + 1);
......
......@@ -34,8 +34,8 @@
#include "Utilities/OpalException.h"
#include "Utilities/ParseError.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <cassert>
#include <cmath>
#include <ctime>
#include <exception>
#include <iostream>
......@@ -286,7 +286,7 @@ void OpalParser::parseAssign(Statement &stat) const {
int index = 0;
if(stat.delimiter('[')) {
index = int(Round(parseRealConst(stat)));
index = int(std::round(parseRealConst(stat)));
parseDelimiter(stat, ']');
if(index <= 0) {
......
......@@ -28,7 +28,6 @@
#include "Physics/Physics.h"
#include "Structure/Beam.h"
#include "Utilities/OpalException.h"
#include "Utilities/Round.h"
#include <cmath>
#include <fstream>
#include <iomanip>
......@@ -99,7 +98,7 @@ void Dynamic::execute() {
const PartData &reference = beam->getReference();
// Compute transfer map.
int order = std::max(int(Round(Attributes::getReal(itsAttr[ORDER]))), 1);
int order = std::max(int(std::round(Attributes::getReal(itsAttr[ORDER]))), 1);
FTps<double, 6>::setGlobalTruncOrder(order);
LieMapper mapper(*use->fetchLine(), reference, false, false, order);
mapper.execute();
......
......@@ -29,13 +29,11 @@
#include "Physics/Physics.h"
#include "Structure/Beam.h"
#include "Utilities/OpalException.h"
#include "Utilities/Round.h"
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
using std::complex;
// Class Static
// ------------------------------------------------------------------------
......@@ -100,7 +98,7 @@ void Static::execute() {
// Compute transfer map.
// JMJ comment: minimum sensible order is 2
int order = std::max(int(Round(Attributes::getReal(itsAttr[ORDER]))), 2);
int order = std::max(int(std::round(Attributes::getReal(itsAttr[ORDER]))), 2);
LieMapper mapper(*use->fetchLine(), reference, false, false, order);
FTps<double, 6>::setGlobalTruncOrder(order);
std::cout << "mapper.execute(); start " << std::endl;
......@@ -129,11 +127,11 @@ void Static::execute() {
// Print normal form.
// const DragtFinnNormalForm<3> normal(map);
// const FVector<complex<double>,6> &lambda = normal.eigenValues();
// const FVector<std::complex<double>,6> &lambda = normal.eigenValues();
// 21-06-2000, remove const
DragtFinnNormalForm<3> normal(map);
const FVector<complex<double>, 6> &lambda = normal.eigenValues();
const FVector<std::complex<double>, 6> &lambda = normal.eigenValues();
os << "\nEigenvalues of the linear map:\n";
for(int i = 0; i < 4; i++) {
......
......@@ -31,7 +31,7 @@
#include "Tables/Flatten.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
......@@ -96,7 +96,7 @@ void Micado::execute() {
// Get the data for correction.
RangeRep range = Attributes::getRange(itsAttr[RANGE]);
int iterations = int(Round(Attributes::getReal(itsAttr[ITERATIONS])));
int iterations = int(std::round(Attributes::getReal(itsAttr[ITERATIONS])));
bool listm1 = Attributes::getBool(itsAttr[LISTM1]);
bool listm2 = Attributes::getBool(itsAttr[LISTM2]);
bool listc1 = Attributes::getBool(itsAttr[LISTC1]);
......@@ -339,7 +339,7 @@ void Micado::solve(int plane, Matrix<double> &A, Vector<double> &B) {
// Begin of iteration loop.
double tol = Attributes::getReal(itsAttr[TOL]);
int correctors = int(Round(Attributes::getReal(itsAttr[CORRECTORS])));
int correctors = int(std::round(Attributes::getReal(itsAttr[CORRECTORS])));
if(correctors > n || correctors == 0) correctors = n;
int corr = 0;
while(true) {
......
......@@ -32,7 +32,6 @@
#include "Structure/Beam.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <cmath>
#include <iomanip>
#include <iostream>
......
......@@ -30,7 +30,6 @@
#include "Utilities/DomainError.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <iomanip>
#include <iostream>
......
......@@ -30,7 +30,6 @@
#include "Utilities/DomainError.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <iomanip>
#include <iostream>
......
......@@ -35,7 +35,6 @@
#include "Tables/Flatten.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <cmath>
#include <iomanip>
......@@ -597,7 +596,7 @@ void Twiss::execute() {
revBeam = Attributes::getBool(itsAttr[REVBEAM]);
revTrack = Attributes::getBool(itsAttr[REVTRACK]);
revPath = ( revBeam && !revTrack ) || ( !revBeam && revTrack );
order = int(Round(Attributes::getReal(itsAttr[ORDER])));
order = int(std::round(Attributes::getReal(itsAttr[ORDER])));
if(method == "THICK") {
//std::cerr << " method == \"THICK\"" << std::endl;
......
......@@ -39,7 +39,6 @@
#include "Distribution/Distribution.h"
#include "Track/Track.h"
#include "Utilities/OpalException.h"
#include "Utilities/Round.h"
#include "Utilities/Util.h"
#include "Structure/Beam.h"
#include "Structure/BoundaryGeometry.h"
......@@ -57,6 +56,7 @@
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
#include <cmath>
#include <fstream>
#include <iomanip>
......@@ -203,7 +203,7 @@ void TrackRun::execute() {
}
if(method == "THIN" || method == "THICK") {
int turns = int(Round(Attributes::getReal(itsAttr[TURNS])));
int turns = int(std::round(Attributes::getReal(itsAttr[TURNS])));
// Track for the all but last turn.
for(int turn = 1; turn < turns; ++turn) {
......@@ -602,7 +602,7 @@ void TrackRun::setupCyclotronTracker(){
double macrocharge = 0.0;
// multi-bunch parameters
const int specifiedNumBunch = int(std::abs(Round(Attributes::getReal(itsAttr[TURNS]))));
const int specifiedNumBunch = int(std::abs(std::round(Attributes::getReal(itsAttr[TURNS]))));
const double mbPara = Attributes::getReal(itsAttr[PARAMB]);
const std::string mbMode = Util::toUpper(Attributes::getString(itsAttr[MBMODE]));
const double mbEta = Attributes::getReal(itsAttr[MB_ETA]);
......
......@@ -3,9 +3,7 @@ set (_SRCS
OpalException.cpp
OpalFilter.cpp
RegularExpression.cpp
Round.cpp
Timer.cpp
Truncate.cpp
)
include_directories (
......@@ -16,13 +14,10 @@ add_opal_sources(${_SRCS})
set (HDRS
EarlyLeaveException.h
NumToStr.h
OpalException.h
OpalFilter.h
RegularExpression.h
Round.h
Timer.h
Truncate.h
)
install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Utilities")
......
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