Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65783566
main.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jun 6, 05:01
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Jun 8, 05:01 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18126674
Attached To
R7571 SP4E-TB-TL-FR
main.cc
View Options
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <memory>
#include "arithmetic.hh"
#include "pi.hh"
#include "series.hh"
#include "print.hh"
#include "write.hh"
#include "dumper.hh"
/* -------------------------------------------------------------------------- */
int
main
(
int
argc
,
char
**
argv
)
{
// Parse method type
std
::
string
method
=
"ar"
;
// default value
if
(
argc
>
1
)
{
method
=
argv
[
1
];
}
// Parse number of iterations
unsigned
int
N
=
10
;
// default value
if
(
argc
>
2
)
{
N
=
atoi
(
argv
[
2
]);
}
// Parse frequency
unsigned
int
freq
=
1
;
// default value
if
(
argc
>
3
)
{
freq
=
atoi
(
argv
[
3
]);
}
// Instanciate appropriate series object
std
::
unique_ptr
<
Series
>
series
;
// doesn't point to anything yet
if
(
method
==
"ar"
)
{
series
.
reset
(
new
ComputeArithmetic
);
}
else
if
(
method
==
"pi"
)
{
series
.
reset
(
new
ComputePi
);
}
// Compute series
std
::
cout
<<
series
->
getName
()
<<
"("
<<
N
<<
") = "
<<
series
->
compute
(
N
)
<<
std
::
endl
;
// Print series values from 1 to N onto screen (with specific frequency)
PrintSeries
printer
(
*
series
,
N
,
freq
);
printer
.
dump
();
// Dump series values from 1 to N into file
WriteSeries
writer
(
*
series
,
N
,
","
);
writer
.
dump
();
return
EXIT_SUCCESS
;
}
Event Timeline
Log In to Comment