JWS C Library
C language utility library
matblock_math.h File Reference

Declarations for mathematical matrix block operations. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include "jwsc/base/error.h"
#include "jwsc/math/complex.h"
#include "jwsc/matblock/matblock.h"
Include dependency graph for matblock_math.h:

Go to the source code of this file.

Functions

add_scalar_to_matblock

Adds a scalar to a matrix block.

void add_scalar_to_matblock_f (Matblock_f **m_out, const Matblock_f *m_in, float a)
 Adds a scalar to a single precision matrix block.
void add_scalar_to_matblock_d (Matblock_d **m_out, const Matblock_d *m_in, double a)
 Adds a scalar to a double precision matrix block.
void add_scalar_to_matblock_cf (Matblock_cf **m_out, const Matblock_cf *m_in, Complex_f z)
 Adds a scalar to a single precision complex matrix block.
void add_scalar_to_matblock_cd (Matblock_cd **m_out, const Matblock_cd *m_in, Complex_d z)
 Adds a scalar to a double precision complex matrix block.
multiply_matblock_by_scalar

Multiplies a matrix block by a scalar.

void multiply_matblock_by_scalar_f (Matblock_f **m_out, const Matblock_f *m_in, float a)
 Multiplies a single precision matrix block by a scalar.
void multiply_matblock_by_scalar_d (Matblock_d **m_out, const Matblock_d *m_in, double a)
 Multiplies a double precision matrix block by a scalar.
void multiply_matblock_by_scalar_cf (Matblock_cf **m_out, const Matblock_cf *m_in, Complex_f z)
 Multiplies a single precision complex matrix block by a scalar.
void multiply_matblock_by_scalar_cd (Matblock_cd **m_out, const Matblock_cd *m_in, Complex_d z)
 Multiplies a double precision complex matrix block by a scalar.
multiply_matblocks_elt_wise

Multiplies a two matrix blocks element by element.

Errormultiply_matblocks_elt_wise_f (Matblock_f **m_out, const Matblock_f *m_1, const Matblock_f *m_2)
 Multiples two single precision matrix blocks element by element.
Errormultiply_matblocks_elt_wise_d (Matblock_d **m_out, const Matblock_d *m_1, const Matblock_d *m_2)
 Multiples two double precision matrix blocks element by element.
Errormultiply_matblocks_elt_wise_cf (Matblock_cf **m_out, const Matblock_cf *m_1, const Matblock_cf *m_2)
 Multiples two single precision complex matrix blocks element by element.
Errormultiply_matblocks_elt_wise_cd (Matblock_cd **m_out, const Matblock_cd *m_1, const Matblock_cd *m_2)
 Multiples two double precision complex matrix blocks element by element.
add_matblocks

Adds two matrix blocks element-wise.

Erroradd_matblocks_f (Matblock_f **m_out, const Matblock_f *m_1, const Matblock_f *m_2)
 Adds two single precision matrix blocks element-wise.
Erroradd_matblocks_d (Matblock_d **m_out, const Matblock_d *m_1, const Matblock_d *m_2)
 Adds two double precision matrix blocks element-wise.
subtract_matblocks

Subtracts two matrix blocks element-wise.

Errorsubtract_matblocks_f (Matblock_f **m_out, const Matblock_f *m_1, const Matblock_f *m_2)
 Subtracts two single precision matrix blocks element-wise.
Errorsubtract_matblocks_d (Matblock_d **m_out, const Matblock_d *m_1, const Matblock_d *m_2)
 Subtracts two double precision matrix blocks element-wise.
calc_matblock_asum

Calculates the absolute sum of a real matrix block.

void calc_matblock_asum_f (float *sum_out, const Matblock_f *m)
 Calculates the absolute value sum of a single precision matrix block.
void calc_matblock_asum_d (double *sum_out, const Matblock_d *m)
 Calculates the absolute value sum of a double precision matrix block.
normalize_matblock_sum

Normalizes a real matrix block by its sum.

void normalize_matblock_sum_f (Matblock_f **m_out, const Matblock_f *m_in)
 Normalizes a single precision matrix block by its sum.
void normalize_matblock_sum_d (Matblock_d **m_out, const Matblock_d *m_in)
 Normalizes a double precision matrix block by its sum.
abs_matblock

Takes the absolute value of all elements of a matrix.

void abs_matblock_f (Matblock_f **m_out, const Matblock_f *m_in)
 Takes the absolute value of all elements of a single precision matrix.
void abs_matblock_d (Matblock_d **m_out, const Matblock_d *m_in)
 Takes the absolute value of all elements of a double precision matrix.
threshold_matblock

Thresholds a matblock by setting all values below the threshold to zero.

void threshold_matblock_f (Matblock_f **m_out, const Matblock_f *m_in, float threshold)
 Thresholds a single precision matrix block by setting all values below the threshold to zero.
void threshold_matblock_d (Matblock_d **m_out, const Matblock_d *m_in, double threshold)
 Thresholds a double precision matrix block by setting all values below the threshold to zero.

Detailed Description

Declarations for mathematical matrix block operations.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Many of the functions are accelerated if linked against an optimized BLAS library.

Definition in file matblock_math.h.


Function Documentation

void add_scalar_to_matblock_f ( Matblock_f **  m_out,
const Matblock_f m_in,
float  a 
)

Adds a scalar to a single precision matrix block.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to add a to.
aScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 79 of file matblock_math.c.

void add_scalar_to_matblock_d ( Matblock_d **  m_out,
const Matblock_d m_in,
double  a 
)

Adds a scalar to a double precision matrix block.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to add a to.
aScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 115 of file matblock_math.c.

void add_scalar_to_matblock_cf ( Matblock_cf **  m_out,
const Matblock_cf m_in,
Complex_f  z 
)

Adds a scalar to a single precision complex matrix block.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to add a to.
zScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 151 of file matblock_math.c.

void add_scalar_to_matblock_cd ( Matblock_cd **  m_out,
const Matblock_cd m_in,
Complex_d  z 
)

Adds a scalar to a double precision complex matrix block.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to add a to.
zScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 188 of file matblock_math.c.

void multiply_matblock_by_scalar_f ( Matblock_f **  m_out,
const Matblock_f m_in,
float  a 
)

Multiplies a single precision matrix block by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to multiply scalar with.
aScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 237 of file matblock_math.c.

void multiply_matblock_by_scalar_d ( Matblock_d **  m_out,
const Matblock_d m_in,
double  a 
)

Multiplies a double precision matrix block by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to multiply scalar with.
aScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 286 of file matblock_math.c.

void multiply_matblock_by_scalar_cf ( Matblock_cf **  m_out,
const Matblock_cf m_in,
Complex_f  z 
)

Multiplies a single precision complex matrix block by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to multiply scalar with.
zScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 335 of file matblock_math.c.

void multiply_matblock_by_scalar_cd ( Matblock_cd **  m_out,
const Matblock_cd m_in,
Complex_d  z 
)

Multiplies a double precision complex matrix block by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to multiply scalar with.
zScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 389 of file matblock_math.c.

Error* multiply_matblocks_elt_wise_f ( Matblock_f **  m_out,
const Matblock_f m_1,
const Matblock_f m_2 
)

Multiples two single precision matrix blocks element by element.

The matrix blocks must have the same dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_1First (left) matrix block in the multiply operation.
m_2Second (right) matrix block in the multiply operation.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix block).
  • ERROR_INV_ARG Matrix blocks m_1 and m_2 do not have the same dimensions.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 462 of file matblock_math.c.

Error* multiply_matblocks_elt_wise_d ( Matblock_d **  m_out,
const Matblock_d m_1,
const Matblock_d m_2 
)

Multiples two double precision matrix blocks element by element.

Definition at line 504 of file matblock_math.c.

Error* multiply_matblocks_elt_wise_cf ( Matblock_cf **  m_out,
const Matblock_cf m_1,
const Matblock_cf m_2 
)

Multiples two single precision complex matrix blocks element by element.

Definition at line 546 of file matblock_math.c.

Error* multiply_matblocks_elt_wise_cd ( Matblock_cd **  m_out,
const Matblock_cd m_1,
const Matblock_cd m_2 
)

Multiples two double precision complex matrix blocks element by element.

Definition at line 595 of file matblock_math.c.

Error* add_matblocks_f ( Matblock_f **  m_out,
const Matblock_f m_1,
const Matblock_f m_2 
)

Adds two single precision matrix blocks element-wise.

The matrix block must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_1Matrix block to add.
m_2Matrix block to add.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
  • ERROR_INV_ARG Matrix blocks m_1 and m_2 do not have equal dimensions.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 671 of file matblock_math.c.

Error* add_matblocks_d ( Matblock_d **  m_out,
const Matblock_d m_1,
const Matblock_d m_2 
)

Adds two double precision matrix blocks element-wise.

The matrix block must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_1Matrix block to add.
m_2Matrix block to add.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
  • ERROR_INV_ARG Matrix blocks m_1 and m_2 do not have equal dimensions.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 761 of file matblock_math.c.

Error* subtract_matblocks_f ( Matblock_f **  m_out,
const Matblock_f m_1,
const Matblock_f m_2 
)

Subtracts two single precision matrix blocks element-wise.

The matrix block must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_1Matrix block to subtract.
m_2Matrix block to subtract.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
  • ERROR_INV_ARG Matrix blocks m_1 and m_2 do not have equal dimensions.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 863 of file matblock_math.c.

Error* subtract_matblocks_d ( Matblock_d **  m_out,
const Matblock_d m_1,
const Matblock_d m_2 
)

Subtracts two double precision matrix blocks element-wise.

The matrix block must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_1Matrix block to subtract.
m_2Matrix block to subtract.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
  • ERROR_INV_ARG Matrix blocks m_1 and m_2 do not have equal dimensions.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 957 of file matblock_math.c.

void calc_matblock_asum_f ( float *  sum_out,
const Matblock_f m 
)

Calculates the absolute value sum of a single precision matrix block.

Parameters:
sum_outResult parameter. Sum of the absolute values of m.
mMatrix block to calculate the sum of.

Definition at line 1051 of file matblock_math.c.

void calc_matblock_asum_d ( double *  sum_out,
const Matblock_d m 
)

Calculates the absolute value sum of a double precision matrix block.

Parameters:
sum_outResult parameter. Sum of the absolute values of m.
mMatrix block to calculate the sum of.

Definition at line 1075 of file matblock_math.c.

void normalize_matblock_sum_f ( Matblock_f **  m_out,
const Matblock_f m_in 
)

Normalizes a single precision matrix block by its sum.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to normalize.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1114 of file matblock_math.c.

void normalize_matblock_sum_d ( Matblock_d **  m_out,
const Matblock_d m_in 
)

Normalizes a double precision matrix block by its sum.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to normalize.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1137 of file matblock_math.c.

void abs_matblock_f ( Matblock_f **  m_out,
const Matblock_f m_in 
)

Takes the absolute value of all elements of a single precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to take the absolute value of.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1170 of file matblock_math.c.

void abs_matblock_d ( Matblock_d **  m_out,
const Matblock_d m_in 
)

Takes the absolute value of all elements of a double precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to take the absolute value of.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1201 of file matblock_math.c.

void threshold_matblock_f ( Matblock_f **  m_out,
const Matblock_f m_in,
float  threshold 
)

Thresholds a single precision matrix block by setting all values below the threshold to zero.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to threshold.
thresholdElements below this value will be set to zero
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1243 of file matblock_math.c.

void threshold_matblock_d ( Matblock_d **  m_out,
const Matblock_d m_in,
double  threshold 
)

Thresholds a double precision matrix block by setting all values below the threshold to zero.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to threshold.
thresholdElements below this value will be set to zero
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1277 of file matblock_math.c.