|
TPCCLIB
|
Working with floats. 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 | floatMatch (const float v1, const float v2, const float lim) |
| int | floatMatchRel (const float v1, const float v2, const float lim) |
| float | floatMachEps () |
| void | floatCopy (float *t, float *s, const unsigned int n) |
| unsigned int | floatMaxIndex (float *a, const unsigned int n) |
| float | floatSum (float *a, const unsigned int n) |
| float | floatMean (float *a, const unsigned int n) |
| int | floatGetWithUnit (const char *s, float *v, int *u) |
| int | floatSpanPositives (float *a, const int n) |
| int | floatCSpanPositives (float *a, const int n) |
| unsigned int | floatNonzeroes (float *a, const unsigned int n) |
Working with floats.
Definition in file floatutil.c.
| void floatCopy | ( | float * | t, |
| float * | 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 94 of file floatutil.c.
| int floatCSpanPositives | ( | float * | 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 228 of file floatutil.c.
| int floatGetWithUnit | ( | const char * | s, |
| float * | v, | ||
| int * | u ) |
Reads numerical value and its unit from argument string.
Both decimal point and comma are accepted. Optional result float 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 float and unit is read; string must not contain any extra space characters. |
| v | Pointer to the float; enter NULL, if not needed. |
| u | Pointer to int for unit code; enter NULL, if not needed. |
Definition at line 174 of file floatutil.c.
| float floatMachEps | ( | ) |
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 FLT_EPSILON and DBL_EPSILON in float.h.
Definition at line 82 of file floatutil.c.
| int floatMatch | ( | const float | v1, |
| const float | v2, | ||
| const float | lim ) |
Verifies that given two floats 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 floatutil.c.
Referenced by imgCompareConc(), imgCompareTimes(), and imgReadDICOM().
| int floatMatchRel | ( | const float | v1, |
| const float | v2, | ||
| const float | lim ) |
Verifies that given two floats 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 54 of file floatutil.c.
Referenced by imgCompareConc(), and imgCompareTimes().
| unsigned int floatMaxIndex | ( | float * | a, |
| const unsigned int | n ) |
Find the maximum value in given float array.
| a | Pointer to float array. |
| n | Length of array. |
Definition at line 113 of file floatutil.c.
| float floatMean | ( | float * | a, |
| const unsigned int | n ) |
Calculate the mean of values in given float array.
| a | Pointer to float array. |
| n | Length of array. |
Definition at line 150 of file floatutil.c.
| unsigned int floatNonzeroes | ( | float * | a, |
| const unsigned int | n ) |
Find the number of non-zero values in given float array. Negative values are counted, but NaNs are not.
| a | Pointer to float array. |
| n | Length of array. |
Definition at line 247 of file floatutil.c.
Referenced by imgContents().
| int floatSpanPositives | ( | float * | 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 210 of file floatutil.c.
| float floatSum | ( | float * | a, |
| const unsigned int | n ) |
Calculate the sum of values in given float array.
| a | Pointer to float array. |
| n | Length of array. |
Definition at line 132 of file floatutil.c.