Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309442
ScannerSTools.cpp
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
ScannerSTools.cpp
View Options
#include
"ScannerSTools.h"
using
namespace
std
;
//Overloaded output operator for the random number generator
ostream
&
operator
<<
(
ostream
&
os
,
RandGen
&
rgen
){
os
<<
rgen
.
seed
<<
"
\t
"
<<
rgen
.
T
<<
"
\t
"
<<
rgen
.
r
;
return
os
;
}
//Overloaded input operator for the VecTriplet class
istream
&
operator
>>
(
istream
&
in
,
VecTriplet
&
T
){
unsigned
N
;
double
min
,
max
;
in
>>
N
;
// read the number of fields
if
(
in
){
//If read is good...
for
(
size_t
i
=
0
;
i
!=
N
;
++
i
){
in
>>
min
>>
max
;
// read next two lines with phimin[i], phimax[i]
if
(
in
){
//if read good, push back into vectors
T
.
Vecmin
.
push_back
(
min
);
T
.
Vecmax
.
push_back
(
max
);
T
.
Vec
.
push_back
((
min
+
max
)
/
2.
);
//Create vector at the same time, initialised to middle point
}
else
break
;
}
}
else
{
cerr
<<
"ERROR in istream & operator >>(istream & in, VecTriplet & T): Bad read of VecTriplet. Check Dimensions in mathematica file."
<<
endl
;
exit
(
-
1
);
// In case of error crash program
}
return
in
;
}
//Overloaded output operator for class VecTriplet
ostream
&
operator
<<
(
ostream
&
os
,
const
VecTriplet
&
T
){
os
<<
T
.
Vecmin
.
size
()
<<
"
\t
"
;
// outupt number of fields
for
(
VecTriplet
::
const_iterator
iter
=
T
.
Vec
.
begin
(),
itermin
=
T
.
Vecmin
.
begin
(),
itermax
=
T
.
Vecmax
.
begin
();
itermin
!=
T
.
Vecmin
.
end
();)
os
<<
*
itermin
++
<<
"
\t
"
<<
*
itermax
++<<
"
\t
"
<<
*
iter
++
<<
"
\t
"
;
// output phimin and phimax ranges one by one
return
os
;
}
//Overloaded output operator for class Monomial
ostream
&
operator
<<
(
ostream
&
os
,
const
Monomial
&
M
){
os
<<
M
.
coeff
<<
" "
;
// outupt coefficient
Monomial
::
const_iterator
beg
=
M
.
pows
.
begin
(),
end
=
M
.
pows
.
end
();
for
(
Monomial
::
const_iterator
iter
=
beg
;
iter
!=
end
;
++
iter
)
if
(
*
iter
!=
0
)
os
<<
"phi"
<<
iter
-
beg
<<
"^"
<<*
iter
<<
" "
;
// output phimin and phimax ranges one by one
return
os
;
}
//Overloaded input operator for the Monomial class
istream
&
operator
>>
(
istream
&
in
,
Monomial
&
M
){
in
>>
M
.
coeff
;
// read the coefficient
if
(
in
){
//If read is good...
for
(
Monomial
::
iterator
iter
=
M
.
pows
.
begin
();
iter
!=
M
.
pows
.
end
();){
in
>>*
(
iter
++
);
// read monomial
if
(
not
in
){
cerr
<<
"ERROR in istream & operator >>(istream & in, Monomial & M): Bad read of Monomial. Check dimensions in mathematica file."
<<
endl
;
exit
(
-
1
);
// In case of error crash program
}
}
}
else
{
cerr
<<
"ERROR in istream & operator >>(istream & in, Monomial & M): Bad read of Monomial. Check Dimensions in mathematica file."
<<
endl
;
exit
(
-
1
);
// In case of error crash program
}
return
in
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Dec 21, 3:23 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3996022
Default Alt Text
ScannerSTools.cpp (2 KB)
Attached To
rSCANNERSSVN scannerssvn
Event Timeline
Log In to Comment