Spectral Transforms
JAX-compatible DCT and DST transforms (types I–IV), re-exported from spectraldiffx.
Discrete Cosine Transform
finitevolx.dct(x, type=2, norm=None)
Discrete Cosine Transform of a 1-D vector.
Computes the DCT of x using an FFT-based O(N log N) algorithm. The default type is DCT-II:
Y[k] = 2 Sigma_{n=0}^{N-1} x[n] cos(pi k(2n+1) / (2N)), k = 0, ..., N-1
All four types (I-IV) follow the scipy convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, ' N']
|
Input 1-D array of length N. |
required |
type
|
(1, 2, 3, 4)
|
DCT variant. Default: 2. |
1
|
norm
|
(None, 'ortho')
|
Normalization mode. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, ' N']
|
DCT of x, same shape as input. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If x is not 1-D, type is invalid, or norm is unrecognised. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
finitevolx.dctn(x, type=2, axes=None, norm=None)
N-dimensional DCT: apply DCT sequentially along each axis.
For a 2-D array with axes=[0, 1], this computes the separable
transform DCT_y(DCT_x(x)). The result is identical to applying the
1-D DCT independently along each axis in sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, '...']
|
Input array of any dimensionality. |
required |
type
|
(1, 2, 3, 4)
|
DCT variant. Default: 2. |
1
|
axes
|
sequence of int or None
|
Axes to transform. |
None
|
norm
|
(None, 'ortho')
|
Normalization mode. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, '...']
|
N-D DCT of x, same shape as input. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
finitevolx.idct(x, type=2, norm=None)
Inverse Discrete Cosine Transform of a 1-D vector.
Satisfies idct(dct(x, t, norm=m), t, norm=m) == x for all types
t in {1, 2, 3, 4} and normalization modes m in {None, "ortho"}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, ' N']
|
DCT-transformed 1-D array of length N. |
required |
type
|
(1, 2, 3, 4)
|
DCT variant of the forward transform to invert. |
1
|
norm
|
(None, 'ortho')
|
Normalization mode — must match the mode used in the forward transform. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, ' N']
|
Reconstructed signal, same shape as x. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If x is not 1-D, type is invalid, or norm is unrecognised. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
finitevolx.idctn(x, type=2, axes=None, norm=None)
N-dimensional inverse DCT: apply IDCT sequentially along each axis.
Satisfies idctn(dctn(x, t, axes, norm=m), t, axes, norm=m) == x.
The inverse is separable — each axis is inverted independently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, '...']
|
DCT-transformed array. |
required |
type
|
(1, 2, 3, 4)
|
DCT variant of the forward transform to invert. |
1
|
axes
|
sequence of int or None
|
Axes to inverse-transform. |
None
|
norm
|
(None, 'ortho')
|
Normalization mode — must match the forward transform. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, '...']
|
Reconstructed N-D array, same shape as input. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
Discrete Sine Transform
finitevolx.dst(x, type=1, norm=None)
Discrete Sine Transform of a 1-D vector.
Computes the DST of x using an FFT-based O(N log N) algorithm. The default type is DST-I:
Y[k] = 2 Sigma_{n=0}^{N-1} x[n] sin(pi(n+1)(k+1) / (N+1)), k = 0, ..., N-1
All four types (I-IV) follow the scipy convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, ' N']
|
Input 1-D array of length N. |
required |
type
|
(1, 2, 3, 4)
|
DST variant. Default: 1. |
1
|
norm
|
(None, 'ortho')
|
Normalization mode. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, ' N']
|
DST of x, same shape as input. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If x is not 1-D, type is invalid, or norm is unrecognised. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
finitevolx.dstn(x, type=1, axes=None, norm=None)
N-dimensional DST: apply DST sequentially along each axis.
For a 2-D array with axes=[0, 1], this computes the separable
transform DST_y(DST_x(x)). The result is identical to applying the
1-D DST independently along each axis in sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, '...']
|
Input array of any dimensionality. |
required |
type
|
(1, 2, 3, 4)
|
DST variant. Default: 1. |
1
|
axes
|
sequence of int or None
|
Axes to transform. |
None
|
norm
|
(None, 'ortho')
|
Normalization mode. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, '...']
|
N-D DST of x, same shape as input. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
finitevolx.idst(x, type=1, norm=None)
Inverse Discrete Sine Transform of a 1-D vector.
Satisfies idst(dst(x, t, norm=m), t, norm=m) == x for all types
t in {1, 2, 3, 4} and normalization modes m in {None, "ortho"}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, ' N']
|
DST-transformed 1-D array of length N. |
required |
type
|
(1, 2, 3, 4)
|
DST variant of the forward transform to invert. |
1
|
norm
|
(None, 'ortho')
|
Normalization mode — must match the mode used in the forward transform. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, ' N']
|
Reconstructed signal, same shape as x. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If x is not 1-D, type is invalid, or norm is unrecognised. |
Source code in .venv/lib/python3.12/site-packages/spectraldiffx/_src/fourier/transforms.py
finitevolx.idstn(x, type=1, axes=None, norm=None)
N-dimensional inverse DST: apply IDST sequentially along each axis.
Satisfies idstn(dstn(x, t, axes, norm=m), t, axes, norm=m) == x.
The inverse is separable — each axis is inverted independently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, '...']
|
DST-transformed array. |
required |
type
|
(1, 2, 3, 4)
|
DST variant of the forward transform to invert. |
1
|
axes
|
sequence of int or None
|
Axes to inverse-transform. |
None
|
norm
|
(None, 'ortho')
|
Normalization mode — must match the forward transform. |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, '...']
|
Reconstructed N-D array, same shape as input. |