fiery.bounds.realtransforms
This module implements discrete transforms for real signals:
The implementation relies on the FFT under the hood, with memory-saving
tricks (borrowed from cupy).
The table below lists all functions implemented in the module.
In addition to these, wrappers of the form
FUNCTYPE = partial(FUNC, type=TYPE) are defined. For example:
Functions:
| Name | Description |
|---|---|
dct |
One-dimensional Discrete Cosine Transform (DCT) |
dst |
One-dimensional Discrete Sine Transform (DST) |
idct |
One-dimensional Inverse Discrete Cosine Transform (DCT) |
idst |
One-dimensional Inverse Discrete Sine Transform (DST) |
dctn |
N-dimensional Discrete Cosine Transform (DCT) |
dstn |
N-dimensional Discrete Sine Transform (DST) |
idctn |
N-dimensional Inverse Discrete Cosine Transform (IDCT) |
idstn |
N-dimensional Inverse Discrete Sine Transform (IDST) |
Functions:
dct
Return the Discrete Cosine Transform
Type IV not implemented
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
int
|
Dimension along which the DCT is computed. Default is the last one. |
-1
|
norm
|
(backward, ortho, forward)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DCT. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
idct
Return the Inverse Discrete Cosine Transform
Warning
Type IV not implemented
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
int
|
Dimension along which the DCT is computed. Default is the last one. |
-1
|
norm
|
(backward, ortho, forward)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DCT. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
dst
Return the Discrete Sine Transform
Type IV not implemented
Warning
dst(..., norm="ortho") yields a different result than scipy
and cupy for types 2 and 3. This is because their DST is not
properly orthogonalized. Use norm="ortho_scipy" to get results
matching their implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
int
|
Dimension along which the DST is computed. Default is the last one. |
-1
|
norm
|
(backward, ortho, forward, ortho_scipy)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DST. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
idst
Return the Inverse Discrete Sine Transform
Type IV not implemented
Warning
idst(..., norm="ortho") yields a different result than scipy
and cupy for types 2 and 3. This is because their DST is not
properly orthogonalized. Use norm="ortho_scipy" to get results
matching their implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
int
|
Dimension along which the DST is computed. Default is the last one. |
-1
|
norm
|
(backward, ortho, forward, ortho_scipy)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DST. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
dctn
dctn(x: Tensor, dim: SequenceOrScalar[int] | None = None, norm: str = 'backward', type: int = 2) -> Tensor
Return multidimensional Discrete Cosine Transform along the specified axes.
Type IV not implemented
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
[sequence of] int
|
Dimensions over which the DCT is computed. If not given, all dimensions are used. |
None
|
norm
|
(backward, ortho, forward)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DCT. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
idctn
idctn(x: Tensor, dim: SequenceOrScalar[int] | None = None, norm: str = 'backward', type: int = 2) -> Tensor
Return multidimensional Inverse Discrete Cosine Transform along the specified axes.
Type IV not implemented
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
[sequence of] int
|
Dimensions over which the DCT is computed. If not given, all dimensions are used. |
None
|
norm
|
(backward, ortho, forward)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DCT. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
dstn
dstn(x: Tensor, dim: SequenceOrScalar[int] | None = None, norm: str = 'backward', type: int = 2) -> Tensor
Return multidimensional Discrete Sine Transform along the specified axes.
Type IV not implemented
Warning
dstn(..., norm="ortho") yields a different result than scipy
and cupy for types 2 and 3. This is because their DST is not
properly orthogonalized. Use norm="ortho_scipy" to get results
matching their implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
[sequence of] int
|
Dimensions over which the DST is computed. If not given, all dimensions are used. |
None
|
norm
|
(backward, ortho, forward, ortho_scipy)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DST. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |
idstn
idstn(x: Tensor, dim: SequenceOrScalar[int] | None = None, norm: str = 'backward', type: int = 2) -> Tensor
Return multidimensional Inverse Discrete Sine Transform along the specified axes.
Type IV not implemented
Warning
idstn(..., norm="ortho") yields a different result than scipy
and cupy for types 2 and 3. This is because their DST is not
properly orthogonalized. Use norm="ortho_scipy" to get results
matching their implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
tensor
|
The input tensor |
required |
dim
|
[sequence of] int
|
Dimensions over which the DST is computed. If not given, all dimensions are used. |
None
|
norm
|
(backward, ortho, forward, ortho_scipy)
|
Normalization mode. Default is "backward". |
"backward"
|
type
|
int
|
Type of the DST. Default type is 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
y |
tensor
|
The transformed tensor. |