Skip to contents

Solves an equation of the form a %*% x = b for x, where a is a linear operation represented by a FastTransform object, while b can be either a vector or a matrix. If b is missing, it returns a FastTransform object corresponding to the inverse (or a generalized inverse) of a.

Usage

# S3 method for FastTransform
solve(a, b, ...)

Arguments

a

An object of class FastTransform, created using fort().

b

A numeric vector or matrix (to solve the equation), or nothing (to obtain a generalized inverse of a).

...

Extra parameters (ignored).

Value

Either a matrix (representing x), or a FastTransform object (representing a generalized inverse of a; if parameter b is missing).

Details

Note that the inverse transform will only be fast (i.e., avoid matrix multiplication) if \(dim\_in = dim\_out = blocksize\).

See also

Examples

a <- fort(4)
inv_a <- solve(a) # inverse of a
inv_a %*% diag(4) # applying the inverse of a
#>             [,1]       [,2]        [,3]       [,4]
#> [1,] -0.54408231 -0.6608470 -0.46028742  0.2353532
#> [2,] -0.46028742 -0.2353532  0.54408231 -0.6608470
#> [3,] -0.69996384  0.6488714  0.04648175  0.2947134
#> [4,]  0.04648175 -0.2947134  0.69996384  0.6488714
solve(a, diag(4)) # should give the same output
#>             [,1]       [,2]        [,3]       [,4]
#> [1,] -0.54408231 -0.6608470 -0.46028742  0.2353532
#> [2,] -0.46028742 -0.2353532  0.54408231 -0.6608470
#> [3,] -0.69996384  0.6488714  0.04648175  0.2947134
#> [4,]  0.04648175 -0.2947134  0.69996384  0.6488714