# API reference

heliaDSP's C API in 2.0.0 is CMSIS-DSP's C API at the qualified CMSIS-DSP commit, with Arm's function signatures and public types unchanged. CMSIS-DSP is Arm's C library of signal-processing and numerical functions for Cortex-M; the qualified CMSIS-DSP commit is the one commit of Ambiq's upstream-tracking fork [AmbiqAI/CMSIS-DSP](https://github.com/AmbiqAI/CMSIS-DSP) that heliaDSP builds. 2.0.0 adds no operation of its own.

The release is available to the preprocessor as the integer macros `HELIA_DSP_VERSION_MAJOR`, `HELIA_DSP_VERSION_MINOR` and `HELIA_DSP_VERSION_PATCH`, defined for every source that links `nsx::helia_dsp` and, under Zephyr, for every source in an image with `CONFIG_HELIA_DSP=y`; for example `#if HELIA_DSP_VERSION_MAJOR == 2 && HELIA_DSP_VERSION_MINOR >= 1`.

## CMSIS-DSP functions (`arm_*`)

Arm's reference documentation for CMSIS-DSP v1.18.0 is at [arm-software.github.io/CMSIS-DSP/v1.18.0](https://arm-software.github.io/CMSIS-DSP/v1.18.0/index.html). The qualified CMSIS-DSP commit is based on Arm's v1.18.0 plus four commits, so that version is the closest one Arm documents; the declarations in the tree are authoritative for a heliaDSP release. The navigation of Arm's v1.18.0 pages has no entry for the function reference, so the table below links each group's page.

An application includes one header:

```c
#include "arm_math.h"
```

which includes the per-group declarations in `third_party/CMSIS-DSP/Include/dsp/`:

| Header | Functions | Arm's reference |
| --- | --- | --- |
| `basic_math_functions.h` | Element-wise add, subtract, multiply, scale, absolute value, dot product, shifts | [Basic math](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupMath.html) |
| `fast_math_functions.h` | Sine, cosine, square root, exponential, logarithm, division | [Fast math](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupFastMath.html) |
| `complex_math_functions.h` | Complex conjugate, magnitude, multiply, dot product | [Complex math](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupCmplxMath.html) |
| `filtering_functions.h` | FIR (including decimating, interpolating and lattice), biquad cascades, convolution, correlation, LMS | [Filtering](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupFilters.html) |
| `transform_functions.h` | Complex and real FFT, MFCC | [Transforms](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupTransforms.html) |
| `matrix_functions.h` | Matrix add, multiply, transpose, inverse, matrix-vector product, decompositions | [Matrix](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupMatrix.html) |
| `statistics_functions.h` | Mean, variance, RMS, minimum, maximum, entropy | [Statistics](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupStats.html) |
| `support_functions.h` | Copy, fill, type conversion, sorting | [Support](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupSupport.html) |
| `interpolation_functions.h` | Linear, bilinear and spline interpolation | [Interpolation](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupInterpolation.html) |
| `controller_functions.h` | PID controller, Clarke and Park transforms | [Controller](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupController.html) |
| `window_functions.h` | Window functions | [Window](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupWindow.html) |
| `distance_functions.h`, `bayes_functions.h`, `svm_functions.h` | Distance measures, naive Bayes and SVM classifiers | [distance](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupDistance.html), [Bayes](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupBayes.html), [SVM](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupSVM.html) |
| `quaternion_math_functions.h` | Quaternion arithmetic and conversion | [Quaternion math](https://arm-software.github.io/CMSIS-DSP/v1.18.0/group__groupQuaternionMath.html) |

Most groups have an f16 counterpart (`*_f16.h`); the f16 declarations are absent when `DISABLEFLOAT16` is defined. Some declarations differ between Helium builds and other builds, notably the biquad's Helium initializer; [Contracts](https://ambiqai.github.io/helia-dsp/guide/contracts/) lists those for the functions Ambiq has measured or tested.

Function names follow Arm's pattern `arm_<operation>_<type>`, with types `f64`, `f32`, `f16`, `q31`, `q15` and `q7`; `q31`, `q15` and `q7` are fixed-point formats with 31, 15 and 7 fractional bits.

Arm's C++ template library (`dsppp/Include`) is part of the qualified CMSIS-DSP commit; heliaDSP does not test it.

## heliaDSP operations (`helia_*`)

An operation that CMSIS-DSP does not provide, or an implementation that needs a contract different from Arm's, takes a `helia_*` name and heliaDSP-owned types. Its public header is in `helia/include/helia/` and its sources in `helia/src/`. Each operation documents its contract at its declaration: supported sizes and types, data layout, the size of every caller-owned buffer, alignment and padding, which buffers may overlap or are modified, and its numerical behaviour. Selection among implementations of a heliaDSP operation is made before the build: each variant has its own named entry point, and no process function chooses among variants at run time. For the wavelet transform, `helia_dwt_forward_f32` and `helia_dwt_inverse_f32` run the Helium implementation on targets with floating-point MVE unless `AUTOVECTORIZE=ON`, and the optimized scalar implementation otherwise, as fixed when the library is compiled; `helia_dwt_forward_scalar_f32` and `helia_dwt_inverse_scalar_f32` run the optimized scalar implementation, and `helia_dwt_reference_forward_f32` and `helia_dwt_reference_inverse_f32` the reference, on every target. The window statistics follow the same convention with `helia_window_stats_f32`, `helia_window_stats_scalar_f32` and `helia_window_stats_reference_f32`.

The documentation site lists every declaration in these headers, generated from them: [C API](https://ambiqai.github.io/helia-dsp/reference/api/).

| Header | Operation |
| --- | --- |
| `helia/helia_dwt.h` | Forward and inverse periodic discrete wavelet transform, f32, bior4.4 and Coif5: [Discrete wavelet transform](https://ambiqai.github.io/helia-dsp/reference/dwt/) |
| `helia/helia_window_stats.h` | Count, sum, sum of squares, minimum and maximum of an f32 window in one traversal, and the mean, variances and RMS derived from them: [Window statistics](https://ambiqai.github.io/helia-dsp/reference/window_stats/) |

An application includes the operation's header:

```c
#include "helia/helia_dwt.h"
```

## Python

`cmsisdsp`, Arm's Python package, builds from the qualified CMSIS-DSP commit, and `heliadsp` from `helia/python`; both are for function-level prototyping on a host and are described in [Python](https://ambiqai.github.io/helia-dsp/getting-started/python/). In 2.0.0, `heliadsp` exposes only its version and the qualified CMSIS-DSP commit; from 2.1.0 each `helia_*` family is a module `heliadsp.<family>`, listed in the Python section of the family's page.

## Next

- [Contracts](https://ambiqai.github.io/helia-dsp/guide/contracts/)
- [Contributing](https://ambiqai.github.io/helia-dsp/guide/contributing/)
