Skip to content

File acc_cf64_core.h

FileList > acc_cf64 > acc_cf64_core.h

Go to the source code of this file

AccCf64 component API. More...

  • #include "clib_common.h"
  • #include "jm_perf.h"
  • #include "dp_state.h"

Classes

Type Name
struct acc_cf64_state_t
AccCf64 state.

Public Functions

Type Name
void acc_cf64_add2d (acc_cf64_state_t * state, const double complex * x, size_t x_len)
Sum all elements of a (logically) 2-D complex array into the accumulator. The array is treated as a flat C-order buffer of x_len complex128 samples regardless of the original shape; the caller is responsible for passing the total element count.
acc_cf64_state_t * acc_cf64_create (double _Complex acc)
Double-precision complex scalar accumulator. Maintains one running complex sum ( acc ) across calls tostep ,steps ,madd ,add2d , andmadd2d . The signal path is double-precision complex (128-bit per sample); coefficient arrays formadd /madd2d are single-precision float to match typical FIR weight storage. Useget to read without side-effects ordump to read and zero atomically.
void acc_cf64_destroy (acc_cf64_state_t * state)
Release all memory owned by an AccCf64 instance. Passing NULL is safe; the function is a no-op in that case. After this call the pointer must not be used.
double complex acc_cf64_dump (acc_cf64_state_t * state)
Return the accumulated sum and atomically reset it to zero. This is the canonical "drain" primitive: read the period total, then start a fresh accumulation interval without a separate reset call. Both real and imaginary parts are zeroed unconditionally.
double complex acc_cf64_get (acc_cf64_state_t * state)
Return the current accumulated sum without resetting state. Identical to reading the acc property directly; retained as an explicit method so call sites that need the value can be uniform withdump without a conditional.
double _Complex acc_cf64_get_acc (const acc_cf64_state_t * state)
Return the current accumulator value without modifying state. Use this when you need to read the running sum mid-accumulation without disturbing it. For a read-and-reset in one call use acc_cf64_dump .
void acc_cf64_get_state (const acc_cf64_state_t * state, void * blob)
void acc_cf64_madd (acc_cf64_state_t * state, const double complex * x, size_t x_len, const float * h, size_t h_len)
Dot-product accumulate with complex signal and float weights: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . The signal arrayx is double-precision complex; the coefficient arrayh is single-precision float (widened to double before multiplication). The shorter of the two arrays limits iteration.
void acc_cf64_madd2d (acc_cf64_state_t * state, const double complex * x, size_t x_len, const float * h, size_t h_len)
Dot-product accumulate over a flat 2-D complex buffer: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . Combinesadd2d andmadd semantics for 2-D data — a complex signal grid is weighted element-wise by a real coefficient buffer and folded into the running sum.
void acc_cf64_reset (acc_cf64_state_t * state)
Zero the accumulator, restoring the same state as a fresh AccCf64(0j) — regardless of the value supplied toacc_cf64_create . Both the real and imaginary parts are set to 0.0. Subsequentget /dump calls return0j until new samples are processed.
void acc_cf64_set_acc (acc_cf64_state_t * state, double _Complex acc)
Overwrite the accumulator with a new complex value. Useful for seeding the accumulator to a known baseline before processing a new segment without a full reset .
int acc_cf64_set_state (acc_cf64_state_t * state, const void * blob)
size_t acc_cf64_state_bytes (const acc_cf64_state_t * state)
JM_FORCEINLINE JM_HOT void acc_cf64_step (acc_cf64_state_t * state, double complex x)
Add one complex sample to the running sum ( acc += x ). This is the hot-path entry for sample-by-sample processing. For block inputs preferacc_cf64_steps to amortise call overhead.
void acc_cf64_steps (acc_cf64_state_t * state, const double complex * input, size_t n)
Add all samples in input to the running sum. Equivalent to callingacc_cf64_step for each element; iterates element-by-element over double-precision complex samples.

Macros

Type Name
define ACC_CF64_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('A', 'C', 'C', 'C')
define ACC_CF64_STATE_VERSION 1u

Detailed Description

Lifecycle: create -> (step / steps / reset)* -> destroy

Example:

acc_cf64_state_t *obj = acc_cf64_create(0.0 + 0.0 * I);
acc_cf64_step(obj, 1.0 + 0.5 * I);
double complex v = acc_cf64_get(obj);  // v == 1.0 + 0.5 * I
acc_cf64_destroy(obj);

Public Functions Documentation

function acc_cf64_add2d

Sum all elements of a (logically) 2-D complex array into the accumulator. The array is treated as a flat C-order buffer of x_len complex128 samples regardless of the original shape; the caller is responsible for passing the total element count.

void acc_cf64_add2d (
    acc_cf64_state_t * state,
    const double complex * x,
    size_t x_len
) 

Parameters:

  • state Must be non-NULL.
  • x Input array (complex128, any shape — passed as flat buffer).
  • x_len Number of elements in x.
    >>> import numpy as np
    >>> from doppler.accumulator import AccCf64
    >>> obj = AccCf64(0j)
    >>> grid = np.array([[1+0j, 2+0j], [3+0j, 4+0j]], dtype=np.complex128)
    >>> obj.add2d(grid)
    >>> obj.get()
    (10+0j)
    

function acc_cf64_create

Double-precision complex scalar accumulator. Maintains one running complex sum ( acc ) across calls tostep ,steps ,madd ,add2d , andmadd2d . The signal path is double-precision complex (128-bit per sample); coefficient arrays formadd /madd2d are single-precision float to match typical FIR weight storage. Useget to read without side-effects ordump to read and zero atomically.

acc_cf64_state_t * acc_cf64_create (
    double _Complex acc
) 

Parameters:

  • acc Initial accumulator value (default: 0j).

Returns:

Heap-allocated state, or NULL on allocation failure.

Note:

Caller must call acc_cf64_destroy() when done.

>>> from doppler.accumulator import AccCf64
>>> obj = AccCf64(0j)
>>> obj.get_acc()
0j
>>> obj.set_acc(3+4j)
>>> obj.get_acc()
(3+4j)
>>> obj.reset()
>>> obj.get_acc()
0j


function acc_cf64_destroy

Release all memory owned by an AccCf64 instance. Passing NULL is safe; the function is a no-op in that case. After this call the pointer must not be used.

void acc_cf64_destroy (
    acc_cf64_state_t * state
) 


function acc_cf64_dump

Return the accumulated sum and atomically reset it to zero. This is the canonical "drain" primitive: read the period total, then start a fresh accumulation interval without a separate reset call. Both real and imaginary parts are zeroed unconditionally.

double complex acc_cf64_dump (
    acc_cf64_state_t * state
) 

Returns:

Value of acc just before the reset (complex).

>>> from doppler.accumulator import AccCf64
>>> obj = AccCf64(0j)
>>> obj.step(3+2j)
>>> obj.step(1+1j)
>>> obj.dump()
(4+3j)
>>> obj.get()
0j


function acc_cf64_get

Return the current accumulated sum without resetting state. Identical to reading the acc property directly; retained as an explicit method so call sites that need the value can be uniform withdump without a conditional.

double complex acc_cf64_get (
    acc_cf64_state_t * state
) 

Returns:

Current value of acc (complex).

>>> from doppler.accumulator import AccCf64
>>> obj = AccCf64(0j)
>>> obj.step(2+0j)
>>> obj.step(0+3j)
>>> obj.get()
(2+3j)


function acc_cf64_get_acc

Return the current accumulator value without modifying state. Use this when you need to read the running sum mid-accumulation without disturbing it. For a read-and-reset in one call use acc_cf64_dump .

double _Complex acc_cf64_get_acc (
    const acc_cf64_state_t * state
) 

Returns:

Current value of acc (complex).

>>> from doppler.accumulator import AccCf64
>>> obj = AccCf64(0j)
>>> obj.step(1+2j)
>>> obj.get_acc()
(1+2j)


function acc_cf64_get_state

void acc_cf64_get_state (
    const acc_cf64_state_t * state,
    void * blob
) 

function acc_cf64_madd

Dot-product accumulate with complex signal and float weights: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . The signal arrayx is double-precision complex; the coefficient arrayh is single-precision float (widened to double before multiplication). The shorter of the two arrays limits iteration.

void acc_cf64_madd (
    acc_cf64_state_t * state,
    const double complex * x,
    size_t x_len,
    const float * h,
    size_t h_len
) 

Parameters:

  • state Must be non-NULL.
  • x Complex signal samples (complex128 array).
  • x_len Number of elements in x.
  • h Real coefficient / weight array (float32 array).
  • h_len Number of elements in h.
    >>> import numpy as np
    >>> from doppler.accumulator import AccCf64
    >>> obj = AccCf64(0j)
    >>> x = np.array([1+0j, 2+0j, 3+0j, 4+0j], dtype=np.complex128)
    >>> h = np.array([0.5, 0.5, 0.5, 0.5], dtype=np.float32)
    >>> obj.madd(x, h)
    >>> obj.get()
    (5+0j)
    

function acc_cf64_madd2d

Dot-product accumulate over a flat 2-D complex buffer: acc += sum(x[i] * h[i]) fori in0 .. min(x_len, h_len) - 1 . Combinesadd2d andmadd semantics for 2-D data — a complex signal grid is weighted element-wise by a real coefficient buffer and folded into the running sum.

void acc_cf64_madd2d (
    acc_cf64_state_t * state,
    const double complex * x,
    size_t x_len,
    const float * h,
    size_t h_len
) 

Parameters:

  • state Must be non-NULL.
  • x Complex signal samples (complex128, flat buffer).
  • x_len Number of elements in x.
  • h Real coefficient / weight array (float32).
  • h_len Number of elements in h.
    >>> import numpy as np
    >>> from doppler.accumulator import AccCf64
    >>> obj = AccCf64(0j)
    >>> x = np.array([1+0j, 2+0j, 3+0j, 4+0j], dtype=np.complex128)
    >>> h = np.array([0.5, 0.5, 0.5, 0.5], dtype=np.float32)
    >>> obj.madd2d(x, h)
    >>> obj.get()
    (5+0j)
    

function acc_cf64_reset

Zero the accumulator, restoring the same state as a fresh AccCf64(0j) — regardless of the value supplied toacc_cf64_create . Both the real and imaginary parts are set to 0.0. Subsequentget /dump calls return0j until new samples are processed.

void acc_cf64_reset (
    acc_cf64_state_t * state
) 

>>> from doppler.accumulator import AccCf64
>>> obj = AccCf64(0j)
>>> obj.step(3+2j)
>>> obj.reset()
>>> obj.get_acc()
0j

function acc_cf64_set_acc

Overwrite the accumulator with a new complex value. Useful for seeding the accumulator to a known baseline before processing a new segment without a full reset .

void acc_cf64_set_acc (
    acc_cf64_state_t * state,
    double _Complex acc
) 

Parameters:

  • state Must be non-NULL.
  • acc New accumulator value (complex).
    >>> from doppler.accumulator import AccCf64
    >>> obj = AccCf64(0j)
    >>> obj.set_acc(5+6j)
    >>> obj.get_acc()
    (5+6j)
    

function acc_cf64_set_state

int acc_cf64_set_state (
    acc_cf64_state_t * state,
    const void * blob
) 

function acc_cf64_state_bytes

size_t acc_cf64_state_bytes (
    const acc_cf64_state_t * state
) 

function acc_cf64_step

Add one complex sample to the running sum ( acc += x ). This is the hot-path entry for sample-by-sample processing. For block inputs preferacc_cf64_steps to amortise call overhead.

JM_FORCEINLINE  JM_HOT void acc_cf64_step (
    acc_cf64_state_t * state,
    double complex x
) 

Parameters:

  • state Must be non-NULL.
  • x Input sample (complex).
    >>> from doppler.accumulator import AccCf64
    >>> obj = AccCf64(0j)
    >>> obj.step(3+2j)
    >>> obj.get()
    (3+2j)
    

function acc_cf64_steps

Add all samples in input to the running sum. Equivalent to callingacc_cf64_step for each element; iterates element-by-element over double-precision complex samples.

void acc_cf64_steps (
    acc_cf64_state_t * state,
    const double complex * input,
    size_t n
) 

Parameters:

  • state Must be non-NULL.
  • input Input samples (complex128 array).
  • n Number of elements in input.
    >>> import numpy as np
    >>> from doppler.accumulator import AccCf64
    >>> obj = AccCf64(0j)
    >>> obj.steps(np.array([1+0j, 2+1j, 3+2j], dtype=np.complex128))
    >>> obj.get()
    (6+3j)
    

Macro Definition Documentation

define ACC_CF64_STATE_MAGIC

#define ACC_CF64_STATE_MAGIC `DP_FOURCC ('A', 'C', 'C', 'C')`

define ACC_CF64_STATE_VERSION

#define ACC_CF64_STATE_VERSION `1u`


The documentation for this class was generated from the following file native/inc/acc_cf64/acc_cf64_core.h