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 "libtpcmisc.h"
Go to the source code of this file.
Functions | |
int | doubleMatch (const double v1, const double v2, 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 | doubleMaxIndex (double *a, const unsigned int n) |
double | doubleSum (double *a, const unsigned int n) |
double | doubleMean (double *a, const unsigned int n) |
int | doubleSpanPositives (double *a, const int n) |
int | doubleCSpanPositives (double *a, const int n) |
double | inverfc (double x) |
void | statSortDouble (double *data, unsigned int n, int order) |
void | statSortFloat (float *data, unsigned int n, int order) |
Working with doubles.
Definition in 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 93 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 186 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 83 of file doubleutil.c.
Referenced by householder_transform().
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 28 of file doubleutil.c.
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 55 of file doubleutil.c.
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 111 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 148 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 168 of file doubleutil.c.
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 130 of file doubleutil.c.
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 205 of file doubleutil.c.
Referenced by imgGaussianFIRFilter().
void statSortDouble | ( | double * | data, |
unsigned int | n, | ||
int | order ) |
Sort the given double array into ascending or descending order.
data | Pointer to data array of size n |
n | Length of data array |
order | Ascending (0) or descending (<>0) order |
Definition at line 267 of file doubleutil.c.
void statSortFloat | ( | float * | data, |
unsigned int | n, | ||
int | order ) |
Sort the given float array into ascending or descending order.
data | Pointer to data array of size n |
n | Length of data array |
order | Ascending (0) or descending (<>0) order |
Definition at line 301 of file doubleutil.c.