gtsam
3rdparty
GeographicLib
dotnet
examples
ManagedCPP
dotnet/examples/ManagedCPP/example-Accumulator.cpp
Go to the documentation of this file.
1
using namespace
System;
2
using namespace
NETGeographicLib
;
3
4
int
main
(
array<System::String ^>
^
/*args*/
)
5
{
6
try
{
7
// Compare using Accumulator and ordinary summation for a sum of large and
8
// small terms.
9
double
sum = 0;
10
Accumulator
^ acc =
gcnew
Accumulator
();
11
acc->
Assign
( 0.0 );
12
sum += 1e20; sum += 1; sum += 2; sum += 100; sum += 5000; sum += -1e20;
13
acc->
Sum
( 1e20 ); acc->
Sum
( 1 ); acc->
Sum
( 2 ); acc->
Sum
( 100 ); acc->
Sum
( 5000 ); acc->
Sum
( -1e20 );
14
Console::WriteLine(String::Format(
"{0} {1}"
, sum, acc->
Result
()));
15
}
16
catch
(
GeographicErr
^
e
) {
17
Console::WriteLine( String::Format(
"Caught exception: {0}"
,
e
->Message ) );
18
return
-1;
19
}
20
return
0;
21
}
NETGeographicLib::Accumulator::Result
double Result()
Returns the accumulated value.
Definition:
dotnet/NETGeographicLib/Accumulator.cpp:48
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
NETGeographicLib::Accumulator
.NET wrapper for GeographicLib::Accumulator.
Definition:
Accumulator.h:44
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition:
NETGeographicLib.h:132
NETGeographicLib::Accumulator::Assign
void Assign(double a)
Assigns a value to an accumulator.
Definition:
dotnet/NETGeographicLib/Accumulator.cpp:42
array
Definition:
numpy.h:821
NETGeographicLib::Accumulator::Sum
void Sum(double a)
Adds a value to the accumulator.
Definition:
dotnet/NETGeographicLib/Accumulator.cpp:54
NETGeographicLib
Definition:
Accumulator.h:13
main
int main(array< System::String ^> ^)
Definition:
dotnet/examples/ManagedCPP/example-Accumulator.cpp:4
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:31