Instrument Neutral Distributed Interface INDI 2.2.5
Macros | Functions
DSP API Buffer statistics functions

Macros

#define dsp_stats_min(buf, len)
 Gets the minimum value of the input stream.
 
#define dsp_stats_max(buf, len)
 Gets the maximum value of the input stream.
 
#define dsp_stats_mid(buf, len)
 Gets the middle value of the input stream.
 
#define dsp_stats_minimum_index(buf, len)
 Gets minimum value's position into the buffer.
 
#define dsp_stats_maximum_index(buf, len)
 Gets maximum value's position into the buffer.
 
#define dsp_stats_mean(buf, len)
 A mean calculator.
 
#define dsp_stats_stddev(buf, len)
 Standard deviation of the inut stream.
 
#define dsp_stats_val_count(buf, len, val)
 Counts value occurrences into stream.
 
#define dsp_stats_val_sum(buf, len)
 Cumulative sum of all the values on the stream.
 
#define dsp_stats_range_count(buf, len, lo, hi)
 Counts value ranging occurrences into stream.
 
#define dsp_stats_compare(in1, in2, len)
 Compare two buffers.
 

Functions

DLL_EXPORT double * dsp_stats_histogram (dsp_stream_p stream, int size)
 Histogram of the inut stream.
 

Detailed Description

Macro Definition Documentation

◆ dsp_stats_compare

#define dsp_stats_compare (   in1,
  in2,
  len 
)
Value:
({\
__typeof(in1[0]) out = 0;\
for(int i = 0; i < len; i++) {\
out += in1[i] - (__typeof(in1[0]))in2[i];\
}\
out;\
})

Compare two buffers.

Parameters
in1the first input buffer
in2the second input buffer
lenthe length in elements of the buffer.
Returns
the sum of the subtraction of each element of both streams

Definition at line 763 of file dsp.h.

◆ dsp_stats_max

#define dsp_stats_max (   buf,
  len 
)
Value:
({\
int i;\
__typeof(buf[0]) max = (__typeof(buf[0]))buf[0];\
for(i = 0; i < len; i++) {\
max = Max(buf[i], max);\
}\
max;\
})
double max(void)
#define Max(a, b)
if max() is not present you can use this one
Definition dsp.h:187

Gets the maximum value of the input stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the maximum value.

Definition at line 596 of file dsp.h.

◆ dsp_stats_maximum_index

#define dsp_stats_maximum_index (   buf,
  len 
)
Value:
({\
int i;\
__typeof(buf[0]) max = dsp_stats_max(buf, len);\
for(i = 0; i < len; i++) {\
if(buf[i] == max) break;\
}\
i;\
})
#define dsp_stats_max(buf, len)
Gets the maximum value of the input stream.
Definition dsp.h:596

Gets maximum value's position into the buffer.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the position index of the maximum value.

Definition at line 647 of file dsp.h.

◆ dsp_stats_mean

#define dsp_stats_mean (   buf,
  len 
)
Value:
({\
int __dsp__i;\
double __dsp__mean = 0;\
for(__dsp__i = 0; __dsp__i < len; __dsp__i++) {\
__dsp__mean += buf[__dsp__i];\
}\
__dsp__mean /= len;\
__dsp__mean;\
})

A mean calculator.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the mean value of the stream.

Definition at line 665 of file dsp.h.

◆ dsp_stats_mid

#define dsp_stats_mid (   buf,
  len 
)
Value:
({\
int i;\
__typeof(buf[0]) min = dsp_stats_min(buf, len);\
(__typeof(buf[0]))(min - dsp_stats_max(buf, len)) / 2.0 + min;\
})
#define dsp_stats_min(buf, len)
Gets the minimum value of the input stream.
Definition dsp.h:578
#define min(a, b)

Gets the middle value of the input stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the middle value.

Definition at line 614 of file dsp.h.

◆ dsp_stats_min

#define dsp_stats_min (   buf,
  len 
)
Value:
({\
int i;\
__typeof(buf[0]) min = (__typeof(buf[0]))buf[0];\
for(i = 0; i < len; i++) {\
min = Min(buf[i], min);\
}\
min;\
})
#define Min(a, b)
if min() is not present you can use this one
Definition dsp.h:180

Gets the minimum value of the input stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the minimum value.

Definition at line 578 of file dsp.h.

◆ dsp_stats_minimum_index

#define dsp_stats_minimum_index (   buf,
  len 
)
Value:
({\
int i;\
__typeof(buf[0]) min = dsp_stats_min(buf, len);\
for(i = 0; i < len; i++) {\
if(buf[i] == min) break;\
}\
i;\
})

Gets minimum value's position into the buffer.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the position index of the minimum value.

Definition at line 629 of file dsp.h.

◆ dsp_stats_range_count

#define dsp_stats_range_count (   buf,
  len,
  lo,
  hi 
)
Value:
({\
int x;\
int count = 0;\
for(x = 0; x < len; x++) {\
if(buf[x] < hi && buf[x] >= lo)\
count ++;\
}\
count;\
})

Counts value ranging occurrences into stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
lothe bottom margin value.
hithe upper margin value.
Returns
the count of the values ranging between the margins of the stream.

Definition at line 743 of file dsp.h.

◆ dsp_stats_stddev

#define dsp_stats_stddev (   buf,
  len 
)
Value:
({\
double __dsp__mean = dsp_stats_mean(buf, len);\
int __dsp__x;\
double __dsp__stddev = 0;\
for(__dsp__x = 0; __dsp__x < len; __dsp__x++) {\
__dsp__stddev += fabs(buf[__dsp__x] - __dsp__mean);\
}\
__dsp__stddev /= len;\
__dsp__stddev;\
})
#define dsp_stats_mean(buf, len)
A mean calculator.
Definition dsp.h:665

Standard deviation of the inut stream.

Parameters
bufthe inout buffer
lenthe length of the buffer

Definition at line 683 of file dsp.h.

◆ dsp_stats_val_count

#define dsp_stats_val_count (   buf,
  len,
  val 
)
Value:
({\
int x;\
int count = 0;\
for(x = 0; x < len; x++) {\
if(buf[x] == val)\
count ++;\
}\
count;\
})

Counts value occurrences into stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
valthe value to count.
Returns
the count of the value of the stream.

Definition at line 704 of file dsp.h.

◆ dsp_stats_val_sum

#define dsp_stats_val_sum (   buf,
  len 
)
Value:
({\
int x;\
double sum = 0;\
for(x = 0; x < len; x++) {\
sum += buf[x];\
}\
sum;\
})

Cumulative sum of all the values on the stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
Returns
the count of the value of the stream.

Definition at line 723 of file dsp.h.

Function Documentation

◆ dsp_stats_histogram()

DLL_EXPORT double * dsp_stats_histogram ( dsp_stream_p  stream,
int  size 
)

Histogram of the inut stream.

Parameters
streamthe stream on which execute
sizethe length of the median.
Returns
the output stream if successful elaboration. NULL if an error is encountered.

Definition at line 22 of file stats.c.