General specification of the type of objects generated by
fort()
, which correspond to structured linear transforms. Useful objects
of this class must be also part of a subclass which extends this one with
a specific implementation of a structured linear transform (e.g.,
FastTransformFFT1 or FastTransformFFT2).
Details
It is generally not recommended that the fields and methods
described here are used directly, unless you have some specific reason
(e.g., require low-level access to objects or want to use pipe operators).
Instead, you should use fort()
and the typical S3 methods for matrices,
such as %*%.FastTransform
and solve.FastTransform
.
See also
fort()
and fort-package, for more detailed informationFastTransformFFT1 and FastTransformFFT2, for specific
FastTransform
subclasses
Public fields
inverse
Logical. Indicates whether the object currently represents a forward or inverse transform.
invertible
Logical. Indicates whether the inverse transform can also be expressed as a
FastTransform
object.dim_in
Dimensionality of the input for the forward transform.
dim_out
Dimensionality of the output for the forward transform.
blocksize
Dimensionality of the internal transformation (always a power of 2).
fwd_par
List of parameters used in the forward transform.
fwd_mtrx
Cached matrix representation of the forward transform.
rev_par
List of parameters used in the inverse transform.
rev_mtrx
Cached matrix representation of the inverse transform.
fort_type
String indicating the type of structured transform being used.
cache_matrix
Logical. Indicates whether to cache calculated matrices or not (default is
TRUE
).logdet
List with cached determinants of the forward and inverse transforms
Methods
Method fwd_eval()
Function that performs the forward transform.
Do not call this directly unless you know what you are doing:
use the FastTransform$evaluate()
method instead.
Method rev_eval()
Function that performs the inverse transform.
Do not call this directly unless you know what you are doing:
use the FastTransform$evaluate()
method instead.
Method calculate_rev_par()
Function that calculates and caches the parameters
for the inverse transform. Do not call this directly unless you
know what you are doing. If you need the inverse transform, use
the FastTransform$get_inverse()
method instead.
Method new()
Raw object creation function. Note that calling this
function does not result in a useful object. Instead, you
should call the fort()
function.
Usage
FastTransform$new(dim_in, dim_out, blocksize)
Method evaluate()
Evaluates the result of applying the transform represented
by this object on an input matrix x
. It is important that the
provided matrix has compatible dimensionality since no input
validation is performed. This method is compatible with the use of
pipe operators (e.g., |>
or magrittr's %>%
and %<>%
pipe operators).
Method get_n_par()
Returns the number of parameters required to represent the linear transform represented by this object.
Method get_inverse()
Returns a new FastTransform
object that represents
the inverse transform of the transform represented by this
object.
Method get_transpose()
Returns either a FastTransform
object that represents
the transpose of the transform represented by this object (if
the value of the invertible
field is TRUE
), or an equivalent
matrix.
Method get_logdet()
Returns information on the determinant of the
transform represented by this object. Fails if dim_in != dim_out
.
The modulus of the determinant is provided in log scale.
Method get_norm()
Returns norm of the matrix equivalent to the linear transform represented by this object.
Arguments
type
String indicating the type of matrix norm to calculate, using the same convention as
base::norm
(default is "o", which corresponds to the maximum absolute column sum).
Method get_norm_margin()
Returns norms of the rows (or columns) or the matrix equivalent to the linear transform represented by this object.
Arguments
type
String indicating the type of matrix norm to calculate, using a convention compatible with
base::norm
(default is "2", which corresponds to the Euclidian norm; use "o" for L1 norm, "m" for Inf norm).by
The norms of the rows are calculated by default (
by = 1
). To calculate the norms of columns instead, useby = 2
.
Method print()
Prints terse information about the object.
Method summary()
Prints verbose information about the object.
Examples
## ------------------------------------------------
## Method `FastTransform$evaluate`
## ------------------------------------------------
x <- fort(4) # random transform
y <- diag(4) # data to transform
x %*% y # y transformed by x
#> [,1] [,2] [,3] [,4]
#> [1,] -0.01606704 -0.74181168 -0.05571482 -0.66809665
#> [2,] -0.52790248 0.03086087 -0.84732325 0.04909070
#> [3,] 0.05571482 -0.66809665 -0.01606704 0.74181168
#> [4,] -0.84732325 -0.04909070 0.52790248 0.03086087
y |> x$evaluate() # same as previous line
#> [,1] [,2] [,3] [,4]
#> [1,] -0.01606704 -0.74181168 -0.05571482 -0.66809665
#> [2,] -0.52790248 0.03086087 -0.84732325 0.04909070
#> [3,] 0.05571482 -0.66809665 -0.01606704 0.74181168
#> [4,] -0.84732325 -0.04909070 0.52790248 0.03086087