Skip to content

File syn_vector.h

FileList > src > syntropic > util > syn_vector.h

Go to the source code of this file

Fixed-point Q16.16 Vector operations and signal statistics — zero heap allocation.

  • #include "../common/syn_defs.h"
  • #include "syn_qmath.h"
  • #include <stdbool.h>
  • #include <stdint.h>

Public Functions

Type Name
void syn_vec_add (const q16_t * a, const q16_t * b, q16_t * out, uint16_t n)
Elementwise vector addition out = a + b.
void syn_vec_clamp (const q16_t * v, q16_t min_val, q16_t max_val, q16_t * out, uint16_t n)
Elementwise vector clamping: min_val <= out[i] <= max_val.
q16_t syn_vec_max (const q16_t * v, uint16_t n)
Find maximum value in vector.
q16_t syn_vec_mean (const q16_t * v, uint16_t n)
Calculate arithmetic mean (average) of vector.
q16_t syn_vec_min (const q16_t * v, uint16_t n)
Find minimum value in vector.
q16_t syn_vec_rms (const q16_t * v, uint16_t n)
Calculate Root Mean Square (RMS) of vector.
void syn_vec_scale (const q16_t * v, q16_t scale, q16_t * out, uint16_t n)
Elementwise vector scalar multiplication out = v * scale.
void syn_vec_sub (const q16_t * a, const q16_t * b, q16_t * out, uint16_t n)
Elementwise vector subtraction out = a - b.
q16_t syn_vec_variance (const q16_t * v, uint16_t n)
Calculate variance of vector elements.

Public Functions Documentation

function syn_vec_add

Elementwise vector addition out = a + b.

void syn_vec_add (
    const q16_t * a,
    const q16_t * b,
    q16_t * out,
    uint16_t n
) 

Parameters:

  • a Pointer to input vector A.
  • b Pointer to input vector B.
  • out Pointer to destination output vector.
  • n Number of elements in vectors.

function syn_vec_clamp

Elementwise vector clamping: min_val <= out[i] <= max_val.

void syn_vec_clamp (
    const q16_t * v,
    q16_t min_val,
    q16_t max_val,
    q16_t * out,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • min_val Minimum lower limit threshold.
  • max_val Maximum upper limit threshold.
  • out Pointer to destination output vector.
  • n Number of elements in vector.

function syn_vec_max

Find maximum value in vector.

q16_t syn_vec_max (
    const q16_t * v,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • n Number of elements.

Returns:

Maximum value in vector, or 0 if n == 0.


function syn_vec_mean

Calculate arithmetic mean (average) of vector.

q16_t syn_vec_mean (
    const q16_t * v,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • n Number of elements.

Returns:

Mean value in Q16.16, or 0 if n == 0.


function syn_vec_min

Find minimum value in vector.

q16_t syn_vec_min (
    const q16_t * v,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • n Number of elements.

Returns:

Minimum value in vector, or 0 if n == 0.


function syn_vec_rms

Calculate Root Mean Square (RMS) of vector.

q16_t syn_vec_rms (
    const q16_t * v,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • n Number of elements.

Returns:

RMS value in Q16.16 format.


function syn_vec_scale

Elementwise vector scalar multiplication out = v * scale.

void syn_vec_scale (
    const q16_t * v,
    q16_t scale,
    q16_t * out,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • scale Scalar multiplier in Q16.16.
  • out Pointer to destination output vector.
  • n Number of elements in vector.

function syn_vec_sub

Elementwise vector subtraction out = a - b.

void syn_vec_sub (
    const q16_t * a,
    const q16_t * b,
    q16_t * out,
    uint16_t n
) 

Parameters:

  • a Pointer to input vector A.
  • b Pointer to input vector B.
  • out Pointer to destination output vector.
  • n Number of elements in vectors.

function syn_vec_variance

Calculate variance of vector elements.

q16_t syn_vec_variance (
    const q16_t * v,
    uint16_t n
) 

Parameters:

  • v Pointer to input vector.
  • n Number of elements.

Returns:

Variance in Q16.16 format.



The documentation for this class was generated from the following file src/syntropic/util/syn_vector.h