The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
numerical.h File Reference

Numerical Library. More...

#include <stdbool.h>
+ Include dependency graph for numerical.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _numerical_state
 
struct  _sum_helper_t
 this represents a partial Neumaier sum More...
 

Macros

#define ValueSumHelper(a)   (a.crt + a.sum)
 
#define CmpSumHelpers(a, b)
 

Typedefs

typedef uint64_t seed_type
 Numerical seed type.
 
typedef struct _numerical_state numerical_state_t
 

Functions

void numerical_init (void)
 
double NeumaierSum (unsigned cnt, double addendums[cnt])
 
struct _sum_helper_t PartialNeumaierSum (struct _sum_helper_t sh, double addendum)
 

Detailed Description

Numerical Library.

Piece-Wise Deterministic Random Number Generators.

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Alessandro Pellegrini
Date
March 16, 2011

Definition in file numerical.h.

Macro Definition Documentation

#define CmpSumHelpers (   a,
 
)
Value:
({\
double __a_s = a.sum + a.crt;\
double __b_s = b.sum + b.crt;\
(__a_s > __b_s) - (__b_s > __a_s);\
})

Definition at line 65 of file numerical.h.

Typedef Documentation

This structure keeps track of the per-LP members required to rollback the internal state of the simulation library.

Function Documentation

double NeumaierSum ( unsigned  cnt,
double  addendums[cnt] 
)

Calculates a sum within double variables with bounded approximation error

This implements a variant of the Kahan summation algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm This is used in the topology module to calculate minimum costs and weighted probabilities since the classic iterated floating point sum may result in unbounded errors originated from the limited precision of the underlying floating point representation.

Author
Andrea Piccione
Parameters
cntthe number of addendums to sum
addendumsa pointer to a sequence of cnt doubles
Returns
the sum between the addendums with bounded error

Definition at line 432 of file numerical.c.

struct _sum_helper_t PartialNeumaierSum ( struct _sum_helper_t  sh,
double  addendum 
)

Calculates a partial sum within double variables with bounded approximation error

This has similar utilization to <NeumaierSum>() with the difference that this can be used to calculate partial sums, adding doubles one by one.

Author
Andrea Piccione
Parameters
sha struct _sum_helper_t holding the partial result typically from a previous sum
addendumthe double floating point value to add
Returns
a struct _sum_helper_t holding the sum between sh and addendum

Definition at line 463 of file numerical.c.