Python Accumulator API
Running-sum accumulators backed by dp_acc_f32_t and dp_acc_cf64_t.
Used as the integrate-and-dump register in polyphase resamplers.
Source:
src/doppler/accumulator/__init__.py
Classes
| Class | Accumulator type | Coefficient type | Use when |
|---|---|---|---|
AccF32 |
float32 | float32 | real-valued sums, power estimation |
AccCf64 |
complex128 | float32 | polyphase resampler I&D path |
Examples
AccF32 — running sum
from doppler.accumulator import AccF32
acc = AccF32()
acc.push(1.0)
acc.push(2.5)
print(acc.get()) # 3.5 — read without clearing
print(acc.dump()) # 3.5 — read and zero
print(acc.dump()) # 0.0 — cleared by previous dump
AccF32 — multiply-accumulate (dot product)
madd(x, h) computes acc += sum(x[k] * h[k]) in C — the inner loop
of a polyphase FIR branch.
from doppler.accumulator import AccF32
import numpy as np
x = np.array([1, 2, 3, 4], dtype=np.float32)
h = np.array([0.25, 0.25, 0.25, 0.25], dtype=np.float32)
acc = AccF32()
acc.madd(x, h)
print(acc.dump()) # 2.5 = mean([1,2,3,4])
AccCf64 — complex accumulator for resampler I&D
from doppler.accumulator import AccCf64
import numpy as np
x = np.array([1+2j, 3+4j], dtype=np.complex128)
h = np.array([0.5, 0.5], dtype=np.float32)
acc = AccCf64()
acc.madd(x, h)
print(acc.dump()) # (2+3j) = mean([1+2j, 3+4j])
add vs push
push(v)— add a scalar to the accumulator.add(x)— add all elements of a NumPy array to the accumulator.
acc = AccF32()
acc.push(1.0) # acc = 1.0
acc.add(np.array([2.0, 3.0], dtype=np.float32)) # acc = 6.0
AccF32
Float32 running-sum accumulator.
Wraps dp_acc_f32_t. Maintains a scalar running sum that can be
read, read-and-zeroed, or reset. :meth:madd is the hot path for
polyphase resampler branch sums: acc += dot(x, h).
Examples:
Scalar push and dump:
>>> from doppler.accumulator import AccF32
>>> acc = AccF32()
>>> acc.push(1.0)
>>> acc.push(2.0)
>>> acc.dump()
3.0
>>> acc.dump()
0.0
Multiply-accumulate (dot product):
>>> import numpy as np
>>> acc = AccF32()
>>> x = np.array([1, 2, 3, 4], dtype=np.float32)
>>> h = np.array([1, 0, 0, 0], dtype=np.float32)
>>> acc.madd(x, h)
>>> acc.dump()
1.0
push
push(x: float) -> None
Add a scalar float to the accumulator.
add
add(x: NDArray[float32]) -> None
Add all elements of a float32 array to the accumulator.
madd
madd(x: NDArray[float32], h: NDArray[float32]) -> None
Multiply-accumulate: acc += dot(x, h).
get
get() -> float
Read the current sum without clearing.
dump
dump() -> float
Read the current sum and zero the accumulator.
reset
reset() -> None
Zero the accumulator without reading.
destroy
destroy() -> None
Release C resources explicitly.
AccCf64
Complex128 accumulator with float32 coefficients.
Wraps dp_acc_cf64_t. Designed for the polyphase resampler
integrate-and-dump path: input samples are complex128, tap
coefficients are float32.
Examples:
>>> import numpy as np
>>> from doppler.accumulator import AccCf64
>>> acc = AccCf64()
>>> x = np.array([1+2j, 3+4j], dtype=np.complex128)
>>> h = np.array([0.5, 0.5], dtype=np.float32)
>>> acc.madd(x, h)
>>> acc.dump()
(2+3j)
push
push(x: complex) -> None
Add a complex128 scalar to the accumulator.
add
add(x: NDArray[complex128]) -> None
Add all elements of a complex128 array to the accumulator.
madd
madd(x: NDArray[complex128], h: NDArray[float32]) -> None
Multiply-accumulate: acc += dot(x, h) with f32 taps.
get
get() -> complex
Read the current sum without clearing.
dump
dump() -> complex
Read the current sum and zero the accumulator.
reset
reset() -> None
Zero the accumulator without reading.
destroy
destroy() -> None
Release C resources explicitly.