Skip to contents

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

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.

Usage

FastTransform$fwd_eval(x)

Arguments

x

Input matrix of the correct dimensionality

Returns

A matrix with the same number of columns as x.


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.

Usage

FastTransform$rev_eval(x)

Arguments

x

Input matrix of the correct dimensionality

Returns

A matrix with the same number of columns as x.


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.

Usage

FastTransform$calculate_rev_par()


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)

Arguments

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 (must be a power of 2).

Returns

A matrix with the same number of columns as x.


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).

Usage

FastTransform$evaluate(x)

Arguments

x

Input matrix with correct dimensionality.

Returns

A matrix with the same number of columns as x.

Examples

x <- fort(4) # random transform
y <- diag(4) # data to transform
x %*% y # y transformed by x
y |> x$evaluate() # same as previous line


Method get_ncol()

Returns the number of columns of the linear transform represented by this object.

Usage

FastTransform$get_ncol()

Returns

A numeric value.


Method get_nrow()

Returns the number of rows of the linear transform represented by this object.

Usage

FastTransform$get_nrow()

Returns

A numeric value.


Method get_dim()

Returns the dimensions of the linear transform represented by this object.

Usage

FastTransform$get_dim()

Returns

A numeric vector with length 2.


Method get_n_par()

Returns the number of parameters required to represent the linear transform represented by this object.

Usage

FastTransform$get_n_par()

Returns

A numeric value.


Method get_inverse()

Returns a new FastTransform object that represents the inverse transform of the transform represented by this object.

Usage

FastTransform$get_inverse()

Returns

A new object of type FastTransform.


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.

Usage

FastTransform$get_transpose()

Returns

Either an new object of type FastTransform or a 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.

Usage

FastTransform$get_logdet()

Returns

The same type of object returned by determinant.matrix.


Method get_norm()

Returns norm of the matrix equivalent to the linear transform represented by this object.

Usage

FastTransform$get_norm(type = "o")

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).

Returns

A numeric value.


Method get_norm_margin()

Returns norms of the rows (or columns) or the matrix equivalent to the linear transform represented by this object.

Usage

FastTransform$get_norm_margin(type = "2", by = 1)

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, use by = 2.

Returns

A vector of numeric values.


Method as_matrix()

Returns the matrix equivalent to the transform represented by this object.

Usage

FastTransform$as_matrix()

Returns

A matrix.


Method print()

Prints terse information about the object.

Usage

FastTransform$print()

Returns

The object itself (invisibly).


Method summary()

Prints verbose information about the object.

Usage

FastTransform$summary()

Returns

The object itself (invisibly).


Method clone()

The objects of this class are cloneable with this method.

Usage

FastTransform$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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