SynchroPMU
C implementation of the Phasor Measurement Unit Estimator based on the Iterative Interpolated DFT Synchrophasor Estimation Algorithm
Loading...
Searching...
No Matches
func_stubs.h File Reference

Function and type stubs for PMU estimator. More...

#include <math.h>
#include <complex.h>
Include dependency graph for func_stubs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define M_PI_p   M_PI
 Mathematical constant PI (can be overridden)
 
#define float_p   float
 Floating-point type stub (default: float)
 
#define complex_p   _Complex
 Complex number type stub (default: _Complex)
 
#define uint_p   unsigned int
 Unsigned integer type stub (default: unsigned int)
 
#define bool_p   _Bool
 Boolean type stub (default: _Bool)
 
#define pmue_fft_r(in_ptr, out_ptr, out_len, n_bins)   dft_r(in_ptr, out_ptr, out_len, n_bins)
 FFT for real input stub.
 
#define pmue_cabs(x)   cabs(x)
 Complex absolute value (magnitude) stub.
 
#define pmue_fabs(x)   fabs(x)
 Floating-point absolute value stub.
 
#define pmue_carg(x)   carg(x)
 Complex argument (phase angle) stub.
 
#define pmue_cos(x)   cos(x)
 Cosine function stub.
 
#define pmue_sin(x)   sin(x)
 Sine function stub.
 
#define pmue_cexp(x)   cexp(x)
 Complex exponential function stub.
 

Detailed Description

Function and type stubs for PMU estimator.

This header file provides a flexible stubbing mechanism for arithmetic functions and data types used in the PMU estimator. It allows users to replace standard library implementations with custom versions or external library functions.

The stubbing system enables:

  • Custom implementations of mathematical functions
  • Integration with hardware-accelerated libraries
  • Type substitution for different platforms or precision requirements
  • Easy testing and mocking of mathematical operations

Usage

To use a custom implementation, define the macro before including this header:

#define pmue_sin(x) my_custom_sin(x)
#include "func_stubs.h"
Function and type stubs for PMU estimator.

Or define your function and use it directly:

float_p my_custom_fft(float_p* in_ptr, float_p complex_p* out_ptr,
uint_p out_len, uint_p n_bins) {
// Your custom FFT implementation
}
#define pmue_fft_r(in_ptr, out_ptr, out_len, n_bins) \
my_custom_fft((in_ptr), (out_ptr), (out_len), (n_bins))
#define complex_p
Complex number type stub (default: _Complex)
Definition func_stubs.h:59
#define float_p
Floating-point type stub (default: float)
Definition func_stubs.h:56
#define uint_p
Unsigned integer type stub (default: unsigned int)
Definition func_stubs.h:62
Author
Chemseddine Allioua, Brahim Mazighi

Macro Definition Documentation

◆ bool_p

#define bool_p   _Bool

Boolean type stub (default: _Bool)

◆ complex_p

#define complex_p   _Complex

Complex number type stub (default: _Complex)

◆ float_p

#define float_p   float

Floating-point type stub (default: float)

◆ M_PI_p

#define M_PI_p   M_PI

Mathematical constant PI (can be overridden)

◆ pmue_cabs

#define pmue_cabs ( x)    cabs(x)

Complex absolute value (magnitude) stub.

Parameters
xComplex number
Returns
Magnitude of complex number

Can be replaced with custom implementation:

#define pmue_cabs(x) my_cabs(x)
// Your implementation here
}

◆ pmue_carg

#define pmue_carg ( x)    carg(x)

Complex argument (phase angle) stub.

Parameters
xComplex number
Returns
Phase angle in radians

Can be replaced with custom implementation:

#define pmue_carg(x) my_carg(x)
float_p my_carg(complex_p x) {
// Your implementation here
}

◆ pmue_cexp

#define pmue_cexp ( x)    cexp(x)

Complex exponential function stub.

Parameters
xComplex number
Returns
e raised to the power of x

Can be replaced with custom implementation:

#define pmue_cexp(x) my_cexp(x)
// Your implementation here
}

◆ pmue_cos

#define pmue_cos ( x)    cos(x)

Cosine function stub.

Parameters
xAngle in radians
Returns
Cosine of x

Can be replaced with custom implementation:

#define pmue_cos(x) my_cos(x)
float_p my_cos(float_p x) {
// Your implementation here
}

◆ pmue_fabs

#define pmue_fabs ( x)    fabs(x)

Floating-point absolute value stub.

Parameters
xReal number
Returns
Absolute value

Can be replaced with custom implementation:

#define pmue_fabs(x) my_fabs(x)
float_p my_fabs(float_p x) {
// Your implementation here
}

◆ pmue_fft_r

#define pmue_fft_r ( in_ptr,
out_ptr,
out_len,
n_bins )   dft_r(in_ptr, out_ptr, out_len, n_bins)

FFT for real input stub.

Parameters
in_ptrInput array pointer (real values)
out_ptrOutput array pointer (complex values)
out_lenOutput array length
n_binsNumber of frequency bins
Returns
Status code

Example custom implementation:

#define pmue_fft_r(in_ptr, out_ptr, out_len, n_bins) \
my_fft((in_ptr), (out_ptr), (out_len), (n_bins))
int my_fft(float_p* in_ptr, float_p complex_p* out_ptr,
uint_p out_len, uint_p n_bins) {
// Your FFT implementation here
}

◆ pmue_sin

#define pmue_sin ( x)    sin(x)

Sine function stub.

Parameters
xAngle in radians
Returns
Sine of x

Can be replaced with custom implementation:

#define pmue_sin(x) my_sin(x)
float_p my_sin(float_p x) {
// Your implementation here
}

◆ uint_p

#define uint_p   unsigned int

Unsigned integer type stub (default: unsigned int)