Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
OPAL
src
Commits
70434ca3
Commit
70434ca3
authored
Mar 09, 2020
by
snuverink_j
Browse files
use c++11 std__math methods instead of own classes
parent
ee231a93
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
36 additions
and
59 deletions
+36
-59
src/AbstractObjects/Object.cpp
src/AbstractObjects/Object.cpp
+2
-2
src/Algorithms/ThickMapper.cpp
src/Algorithms/ThickMapper.cpp
+2
-4
src/Elements/OpalElement.cpp
src/Elements/OpalElement.cpp
+1
-2
src/Expressions/Expressions.cpp
src/Expressions/Expressions.cpp
+7
-11
src/Expressions/Indexer.h
src/Expressions/Indexer.h
+2
-2
src/Match/ConstraintCmd.cpp
src/Match/ConstraintCmd.cpp
+2
-2
src/Match/LMDif.cpp
src/Match/LMDif.cpp
+1
-2
src/Match/MatchOption.cpp
src/Match/MatchOption.cpp
+2
-3
src/Match/Migrad.cpp
src/Match/Migrad.cpp
+1
-2
src/Match/Simplex.cpp
src/Match/Simplex.cpp
+1
-2
src/OpalParser/OpalParser.cpp
src/OpalParser/OpalParser.cpp
+2
-2
src/PhysicsActions/Dynamic.cpp
src/PhysicsActions/Dynamic.cpp
+1
-2
src/PhysicsActions/Static.cpp
src/PhysicsActions/Static.cpp
+4
-6
src/Tables/Micado.cpp
src/Tables/Micado.cpp
+3
-3
src/Tables/Period.cpp
src/Tables/Period.cpp
+0
-1
src/Tables/ThreadAll.cpp
src/Tables/ThreadAll.cpp
+0
-1
src/Tables/ThreadBpm.cpp
src/Tables/ThreadBpm.cpp
+0
-1
src/Tables/Twiss.cpp
src/Tables/Twiss.cpp
+1
-2
src/Track/TrackRun.cpp
src/Track/TrackRun.cpp
+4
-4
src/Utilities/CMakeLists.txt
src/Utilities/CMakeLists.txt
+0
-5
No files found.
src/AbstractObjects/Object.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Expressions
::
parseRealConst
(
stat
)));
int
index
=
int
(
std
::
r
ound
(
Expressions
::
parseRealConst
(
stat
)));
Expressions
::
parseDelimiter
(
stat
,
']'
);
if
(
stat
.
delimiter
(
'='
))
{
...
...
src/Algorithms/ThickMapper.cpp
View file @
70434ca3
...
...
@@ -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 "
+
NumToS
tr
<
in
t
>
(
cx
)
+
" cuts of step-size!"
;
std
::
string
msg
=
"Convergence not achieved within "
+
std
::
to_s
trin
g
(
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 "
+
NumToS
tr
<
in
t
>
(
nx
)
+
" iterations!"
;
std
::
string
msg
=
"Convergence not achieved within "
+
std
::
to_s
trin
g
(
nx
)
+
" iterations!"
;
throw
ConvergenceError
(
"ThickMapper::implicitIntStep()"
,
msg
);
}
...
...
src/Elements/OpalElement.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Expressions
::
parseRealConst
(
stat
)));
int
index
=
int
(
std
::
r
ound
(
Expressions
::
parseRealConst
(
stat
)));
Expressions
::
parseDelimiter
(
stat
,
']'
);
if
(
stat
.
delimiter
(
'='
))
{
...
...
src/Expressions/Expressions.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
parseRealConst
(
stat
)));
occurrence
=
int
(
std
::
r
ound
(
parseRealConst
(
stat
)));
parseDelimiter
(
stat
,
']'
);
if
(
occurrence
<=
0
)
{
...
...
@@ -593,7 +589,7 @@ namespace Expressions {
int
index
=
0
;
if
(
stat
.
delimiter
(
'['
))
{
index
=
int
(
R
ound
(
parseRealConst
(
stat
)));
index
=
int
(
std
::
r
ound
(
parseRealConst
(
stat
)));
parseDelimiter
(
stat
,
']'
);
if
(
index
<=
0
)
{
...
...
@@ -1051,7 +1047,7 @@ namespace Expressions {
parseDelimiter
(
stat
,
'('
);
// Read the array index set.
int
frst
=
int
(
R
ound
(
parseRealConst
(
stat
)));
int
frst
=
int
(
std
::
r
ound
(
parseRealConst
(
stat
)));
int
last
=
1
;
int
step
=
1
;
...
...
@@ -1059,9 +1055,9 @@ namespace Expressions {
last
=
frst
;
frst
=
1
;
}
else
if
(
stat
.
delimiter
(
':'
))
{
last
=
int
(
R
ound
(
parseRealConst
(
stat
)));
last
=
int
(
std
::
r
ound
(
parseRealConst
(
stat
)));
if
(
stat
.
delimiter
(
':'
))
{
step
=
int
(
R
ound
(
parseRealConst
(
stat
)));
step
=
int
(
std
::
r
ound
(
parseRealConst
(
stat
)));
}
parseDelimiter
(
stat
,
','
);
}
else
{
...
...
src/Expressions/Indexer.h
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
rgt
->
evaluate
()));
int
op2
=
int
(
std
::
r
ound
(
rgt
->
evaluate
()));
if
(
op2
<=
0
||
static_cast
<
unsigned
>
(
op2
)
>
op1
.
size
())
{
throw
CLRangeError
(
"Expressions::Indexer()"
,
"Index out of range."
);
...
...
src/Match/ConstraintCmd.cpp
View file @
70434ca3
...
...
@@ -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
...
...
src/Match/LMDif.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
CALLS
])));
int
nfcnmax
=
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
CALLS
])));
// Initialize.
double
fnorm
=
0.0
;
...
...
src/Match/MatchOption.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
0
])));
int
level
=
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
0
])));
Match
::
block
->
setPrintLevel
(
level
);
}
\ No newline at end of file
src/Match/Migrad.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
CALLS
])));
int
nfcnmax
=
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
CALLS
])));
// Working vectors.
int
n
=
Match
::
block
->
countVariables
();
...
...
src/Match/Simplex.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
CALLS
])));
int
nfcnmax
=
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
CALLS
])));
// Set up the simplex.
Fsim
=
Array1D
<
double
>
(
n
+
1
);
...
...
src/OpalParser/OpalParser.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
parseRealConst
(
stat
)));
index
=
int
(
std
::
r
ound
(
parseRealConst
(
stat
)));
parseDelimiter
(
stat
,
']'
);
if
(
index
<=
0
)
{
...
...
src/PhysicsActions/Dynamic.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
ORDER
]))),
1
);
int
order
=
std
::
max
(
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
ORDER
]))),
1
);
FTps
<
double
,
6
>::
setGlobalTruncOrder
(
order
);
LieMapper
mapper
(
*
use
->
fetchLine
(),
reference
,
false
,
false
,
order
);
mapper
.
execute
();
...
...
src/PhysicsActions/Static.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
ORDER
]))),
2
);
int
order
=
std
::
max
(
int
(
std
::
r
ound
(
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
<<
"
\n
Eigenvalues of the linear map:
\n
"
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
...
...
src/Tables/Micado.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
ITERATIONS
])));
int
iterations
=
int
(
std
::
r
ound
(
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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
CORRECTORS
])));
int
correctors
=
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
CORRECTORS
])));
if
(
correctors
>
n
||
correctors
==
0
)
correctors
=
n
;
int
corr
=
0
;
while
(
true
)
{
...
...
src/Tables/Period.cpp
View file @
70434ca3
...
...
@@ -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>
...
...
src/Tables/ThreadAll.cpp
View file @
70434ca3
...
...
@@ -30,7 +30,6 @@
#include "Utilities/DomainError.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <iomanip>
#include <iostream>
...
...
src/Tables/ThreadBpm.cpp
View file @
70434ca3
...
...
@@ -30,7 +30,6 @@
#include "Utilities/DomainError.h"
#include "Utilities/OpalException.h"
#include "Utilities/Options.h"
#include "Utilities/Round.h"
#include <iomanip>
#include <iostream>
...
...
src/Tables/Twiss.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
ORDER
])));
order
=
int
(
std
::
r
ound
(
Attributes
::
getReal
(
itsAttr
[
ORDER
])));
if
(
method
==
"THICK"
)
{
//std::cerr << " method == \"THICK\"" << std::endl;
...
...
src/Track/TrackRun.cpp
View file @
70434ca3
...
...
@@ -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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
TURNS
])));
int
turns
=
int
(
std
::
r
ound
(
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
(
R
ound
(
Attributes
::
getReal
(
itsAttr
[
TURNS
]))));
const
int
specifiedNumBunch
=
int
(
std
::
abs
(
std
::
r
ound
(
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
]);
...
...
@@ -633,7 +633,7 @@ void TrackRun::setupCyclotronTracker(){
}
else
{
/**
getFrequency() gets RF frequency [MHz], NOT isochronous
revolution frequency of particle!
getFrequency() gets RF frequency [MHz], NOT isochronous revolution frequency of particle!
getCurrent() gets beamcurrent [A]
*/
...
...
src/Utilities/CMakeLists.txt
View file @
70434ca3
...
...
@@ -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"
)
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment