JWS C Library
C language utility library
matrix_conv.c File Reference

Definitions for matrix convolution operations and filters. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
#include <assert.h>
#include "jwsc/base/error.h"
#include "jwsc/matrix/matrix.h"
#include "jwsc/matrix/matrix_math.h"
#include "jwsc/matrix/matrix_fft.h"
#include "jwsc/matrix/matrix_conv.h"
Include dependency graph for matrix_conv.c:

Go to the source code of this file.

Defines

#define PI   3.14159265358979323846
 Estimate of pi.

Functions

convolve_matrix

Convolves a matrix with a filter.

Errorconvolve_matrix_f (Matrix_f **m_out, const Matrix_f *m_in, const Matrix_f *h)
 Convolves a single precision matrix with a filter.
Errorconvolve_matrix_d (Matrix_d **m_out, const Matrix_d *m_in, const Matrix_d *h)
 Convolves a double precision matrix with a filter.

Detailed Description

Definitions for matrix convolution operations and filters.

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

Definition in file matrix_conv.c.


Define Documentation

#define PI   3.14159265358979323846

Estimate of pi.

Definition at line 61 of file matrix_conv.c.


Function Documentation

Error* convolve_matrix_f ( Matrix_f **  m_out,
const Matrix_f m_in,
const Matrix_f h 
)

Convolves a single precision matrix with a filter.

Uses reflection to handle boundary cases. The convolution filter must be no larger than the size of m_in.

If the dimension(s) of h are even, the center of the filter is the in upper-left of the central quadrant/pair. For example,

 1 0
 0 0

Does not use FFT.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to convolve.
hFilter to use in convolution.
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_in).
  • ERROR_INV_ARG h is not a usable filter in convolution, i.e., it is too large.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 98 of file matrix_conv.c.

Error* convolve_matrix_d ( Matrix_d **  m_out,
const Matrix_d m_in,
const Matrix_d h 
)

Convolves a double precision matrix with a filter.

Uses reflection to handle boundary cases. The convolution filter must be no larger than the size of m_in.

If the dimension(s) of h are even, the center of the filter is the in upper-left of the central quadrant/pair. For example,

 1 0
 0 0

Does not use FFT.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to convolve.
hFilter to use in convolution.
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_in).
  • ERROR_INV_ARG h is not a usable filter in convolution, i.e., it is too large.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 213 of file matrix_conv.c.