File interp_table_core.h¶
FileList > inc > interp_table > interp_table_core.h
Go to the source code of this file
Periodically-extended interpolated lookup table. More...
#include "clib_common.h"#include "jm_perf.h"
Classes¶
| Type | Name |
|---|---|
| struct | interp_table_state_t InterpolatedTable state. |
Public Functions¶
| Type | Name |
|---|---|
| interp_table_state_t * | interp_table_create (const double _Complex * table, size_t table_len, int method) Create an InterpolatedTable instance. |
| void | interp_table_destroy (interp_table_state_t * state) Destroy an interp_table instance and release all memory. |
| size_t | interp_table_execute (interp_table_state_t * state, const double * in, size_t n_in, double _Complex * out, size_t max_out) Evaluate the table at each of n_in points via periodic interpolation. |
| size_t | interp_table_execute_max_out (interp_table_state_t * state) No fixed cap execute()'s output is always sized to exactly match its own input length, so an out= buffer only ever needs to be at least that many elements (never a larger, unrelated minimum). |
| void | interp_table_reset (interp_table_state_t * state) No-op: InterpolatedTable is purely a function of (table, method, point) with no running state to reset. |
Detailed Description¶
Wraps a fixed complex table of one period and evaluates it at any real (possibly fractional, possibly out-of-range) position via periodic (mod-length) wraparound indexing plus one of three interpolation methods: nearest-below ("floor"), nearest-neighbor ("nearest"), or a linear fit between the two bracketing table points ("linear", the default). Purely a function of (table, method, point) no running state, so create()/execute() is all there is to the lifecycle.
Lifecycle: create -> execute* -> destroy
>>> from doppler.interp import InterpolatedTable
>>> import numpy as np
>>> table = InterpolatedTable(
... np.array([0.0, 1.0, 2.0], dtype=np.complex128))
>>> table.execute(np.array([1.1]))
array([1.1+0.j])
Public Functions Documentation¶
function interp_table_create¶
Create an InterpolatedTable instance.
interp_table_state_t * interp_table_create (
const double _Complex * table,
size_t table_len,
int method
)
Copies table internally; the caller's own array can be freed or modified afterward with no effect on this instance.
Parameters:
tableComplex table, one period, lengthtable_len.table_lenNumber of elements intable(> 0).method0 = floor, 1 = nearest, 2 = linear.
Returns:
Heap-allocated state, or NULL on allocation failure or table_len == 0.
Note:
Caller must call interp_table_destroy() when done.
>>> from doppler.interp import InterpolatedTable
>>> import numpy as np
>>> t = InterpolatedTable(
... np.array([0.0, 1.0, 2.0], dtype=np.complex128),
... method="linear")
>>> t.n
3
function interp_table_destroy¶
Destroy an interp_table instance and release all memory.
Parameters:
stateMay be NULL.
function interp_table_execute¶
Evaluate the table at each of n_in points via periodic interpolation.
size_t interp_table_execute (
interp_table_state_t * state,
const double * in,
size_t n_in,
double _Complex * out,
size_t max_out
)
Each point is wrapped mod the table length (any real value, any sign) and evaluated per the configured method:
* floor: nearest index below (table[floor(point) mod n])
* nearest: closer of the floor/next index (0.5 ties pick floor)
* linear: linear fit across the two bracketing indices
Parameters:
stateMust be non-NULL.inPoints to evaluate, lengthn_in.n_inNumber of points.outOutput buffer; must hold at least n_in values.max_outCapacity ofoutin elements. Emission stops there, so the return value is the number actually written.
Returns:
min(n_in, max_out) interpolated points.
>>> from doppler.interp import InterpolatedTable
>>> import numpy as np
>>> ramp = InterpolatedTable(
... np.array([0.0, 1.0, 2.0], dtype=np.complex128))
>>> ramp.execute(np.array([0.5, 1.1]))
array([0.5+0.j, 1.1+0.j])
function interp_table_execute_max_out¶
No fixed cap execute()'s output is always sized to exactly match its own input length, so anout= buffer only ever needs to be at least that many elements (never a larger, unrelated minimum).
function interp_table_reset¶
No-op: InterpolatedTable is purely a function of (table, method, point) with no running state to reset.
Present only to satisfy the common object interface; each execute() depends solely on its inputs, so a call before or after reset() returns identical samples.
Parameters:
stateMust be non-NULL.
The documentation for this class was generated from the following file native/inc/interp_table/interp_table_core.h