|
TPCCLIB
|
Working with doubles. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>#include <ctype.h>#include <unistd.h>#include <math.h>#include "tpcextensions.h"Go to the source code of this file.
Functions | |
| int | doubleMatch (const double v1, const double v2, const double lim) |
| int | doubleArrayMatch (const double *a1, const double *a2, const unsigned int n, const double lim) |
| int | doubleMatchRel (const double v1, const double v2, const double lim) |
| double | doubleMachEps () |
| void | doubleCopy (double *t, double *s, const unsigned int n) |
| unsigned int | doubleCopyFinite (double *t, double *s, const unsigned int n) |
| unsigned int | doubleNaNs (double *a, const unsigned int n) |
| unsigned int | doubleRange (double *a, const unsigned int n, double *amin, double *amax) |
| double | doubleSum (double *a, const unsigned int n) |
| double | doubleMean (double *a, const unsigned int n) |
| double | doubleWMean (double *a, double *w, const unsigned int n) |
| int | doubleGetWithUnit (const char *s, double *v, int *u) |
| int | doubleSpanPositives (double *a, const int n) |
| int | doubleCSpanPositives (double *a, const int n) |
| unsigned int | doubleNonzeroes (double *a, const unsigned int n) |
| unsigned int | doubleMaxIndex (double *a, const unsigned int n) |
| unsigned int | doubleAbsMaxIndex (double *a, const unsigned int n) |
| unsigned int | doubleMinIndex (double *a, const unsigned int n) |
| unsigned int | doubleAbsMinIndex (double *a, const unsigned int n) |
| unsigned int | doubleGEIndex (double *a, const unsigned int n, double lim) |
| unsigned int | doubleGTIndex (double *a, const unsigned int n, double lim) |
| double | inverfc (double x) |
Working with doubles.
Definition in file doubleutil.c.
| unsigned int doubleAbsMaxIndex | ( | double * | a, |
| const unsigned int | n ) |
Find the maximum absolute value in given double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 377 of file doubleutil.c.
| unsigned int doubleAbsMinIndex | ( | double * | a, |
| const unsigned int | n ) |
Find the minimum absolute value in given double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 416 of file doubleutil.c.
Referenced by spectralBFExtract().
| int doubleArrayMatch | ( | const double * | a1, |
| const double * | a2, | ||
| const unsigned int | n, | ||
| const double | lim ) |
Verifies that given two double arrays have the same values inside given limits. Values are considered to match also if both are NaNs.
| a1 | First array. |
| a2 | Second array. |
| n | Length of arrays. |
| lim | Limit for absolute difference (if <0 then test will fail every time). |
Definition at line 51 of file doubleutil.c.
| void doubleCopy | ( | double * | t, |
| double * | s, | ||
| const unsigned int | n ) |
Copy double values from the 2nd array to the first.
| t | Target array. |
| s | Source array. |
| n | Length of arrays. |
Definition at line 117 of file doubleutil.c.
Referenced by nloptIATGO(), nloptMPSO(), and nloptSimplexARRS().
| unsigned int doubleCopyFinite | ( | double * | t, |
| double * | s, | ||
| const unsigned int | n ) |
Copy finite double values from the 2nd array to the first.
| t | Target array. |
| s | Source array. |
| n | Length of arrays. |
Definition at line 136 of file doubleutil.c.
| int doubleCSpanPositives | ( | double * | a, |
| const int | n ) |
Returns the length of array consisting of non-positive (<=0 and NaN) values.
| a | Pointer to the array. |
| n | Length of the array. |
Definition at line 320 of file doubleutil.c.
Referenced by spectralBFExtract(), and spectralBFNr().
| unsigned int doubleGEIndex | ( | double * | a, |
| const unsigned int | n, | ||
| double | lim ) |
Get the index of first array value greater or equal than given limit.
| a | Pointer to an array of values. |
| n | The number of samples (length of a[]). |
| lim | The limit value. |
Definition at line 435 of file doubleutil.c.
| int doubleGetWithUnit | ( | const char * | s, |
| double * | v, | ||
| int * | u ) |
Reads numerical value and its unit from argument string.
Both decimal point and comma are accepted. Optional result double value is set to NaN if string was not valid value. Optional unit is set to UNIT_UNKNOWN, if not valid or not found.
| s | String from where double and unit is read; string must not contain any extra space characters. |
| v | Pointer to the double float; enter NULL, if not needed. |
| u | Pointer to int for unit code; enter NULL, if not needed. |
Definition at line 272 of file doubleutil.c.
Referenced by iftCheckKeyValue(), and iftCheckKeyValues().
| unsigned int doubleGTIndex | ( | double * | a, |
| const unsigned int | n, | ||
| double | lim ) |
Get the index of first array value greater than given limit.
| a | Pointer to an array of values. |
| n | The number of samples (length of a[]). |
| lim | The limit value. |
Definition at line 452 of file doubleutil.c.
| double doubleMachEps | ( | ) |
Estimates the machine epsilon, the upper bound on the relative error due to rounding in floating point arithmetic, within one order of magnitude of the true machine epsilon.
Standard C library should also have DBL_EPSILON in float.h.
Definition at line 105 of file doubleutil.c.
Referenced by householder_transform(), nlopt1D(), nloptFixedNr(), nloptLimitFixedNr(), and nloptPowellBrent().
| int doubleMatch | ( | const double | v1, |
| const double | v2, | ||
| const double | lim ) |
Verifies that given two doubles have the same value inside given limits. Values are considered to match also if both are NaNs.
| v1 | First value. |
| v2 | Second value. |
| lim | Limit for absolute difference (if <0 then test will fail every time). |
Definition at line 27 of file doubleutil.c.
Referenced by doubleArrayMatch(), parCompareParameters(), parCompareWSS(), parIsFitRange(), tacCheckX1X2X(), tacCompareConc(), tacCompareTimes(), tacCompareWeights(), and tacReadQView().
| int doubleMatchRel | ( | const double | v1, |
| const double | v2, | ||
| const double | lim ) |
Verifies that given two doubles have the same value inside given relative limit |2*(v1-v2)/(v1+v2)|.
Values are considered to match also if both are NaNs, but not if mean is zero (unless both are exactly zero).
| v1 | First value. |
| v2 | Second value. |
| lim | Limit for relative difference (if <0 then test will fail every time). |
Definition at line 77 of file doubleutil.c.
Referenced by parCompareParameters(), parCompareWSS(), tacCompareConc(), tacCompareTimes(), and tacCompareWeights().
| unsigned int doubleMaxIndex | ( | double * | a, |
| const unsigned int | n ) |
Find the maximum value in given double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 357 of file doubleutil.c.
| double doubleMean | ( | double * | a, |
| const unsigned int | n ) |
Calculate the mean of values in given double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 224 of file doubleutil.c.
| unsigned int doubleMinIndex | ( | double * | a, |
| const unsigned int | n ) |
Find the minimum value in given double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 396 of file doubleutil.c.
| unsigned int doubleNaNs | ( | double * | a, |
| const unsigned int | n ) |
Check the number of NaNs in a double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 156 of file doubleutil.c.
| unsigned int doubleNonzeroes | ( | double * | a, |
| const unsigned int | n ) |
Find the number of non-zero values in given double array. Negative values are counted, but NaNs are not.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 339 of file doubleutil.c.
| unsigned int doubleRange | ( | double * | a, |
| const unsigned int | n, | ||
| double * | amin, | ||
| double * | amax ) |
Get the range of finite values in a double array.
| a | Pointer to double array. |
| n | Length of array. |
| amin | Pointer to the double float where minimum value is stored; enter NULL, if not needed. |
| amax | Pointer to the double float where maximum value is stored; enter NULL, if not needed. |
Definition at line 174 of file doubleutil.c.
| int doubleSpanPositives | ( | double * | a, |
| const int | n ) |
Returns the length of array consisting of only positive (>0 and not NaN) values.
| a | Pointer to the array. |
| n | Length of the array. |
Definition at line 302 of file doubleutil.c.
Referenced by spectralBFExtract(), and spectralBFNr().
| double doubleSum | ( | double * | a, |
| const unsigned int | n ) |
Calculate the sum of values in given double array.
| a | Pointer to double array. |
| n | Length of array. |
Definition at line 206 of file doubleutil.c.
Referenced by spectralBFExtract().
| double doubleWMean | ( | double * | a, |
| double * | w, | ||
| const unsigned int | n ) |
Calculate the weighted mean of values in given double array.
| a | Pointer to double array to calculated weighted mean from. |
| w | Pointer to double array containing the weights. Negative or NaN weight is interpreted as zero weight. |
| n | Length of arrays. |
Definition at line 244 of file doubleutil.c.
Referenced by spectralBFExtract().
| double inverfc | ( | double | x | ) |
Inverse complementary error function erfc^{-1}(x).
Based on the code by Acklam PJ, 2010.
| x | Parameter for the inverse complementary error function. |
Definition at line 473 of file doubleutil.c.