Table Of Contents

Previous topic

Vector Broadcasting

Next topic

Reduction

This Page

Transformations

This package provides generic functions transform and transform! that allow writing generic codes using linear / affine transformations.

transform(t, x)          # apply transform t to x
transform!(y, t, x)      # apply transform t to x and write results to y
transform!(t, x)         # apply transform t to x inplace (t need to be a simple transform)

Here, t can be an instance of type LinearTransform or AffineTransform.

LinearTransform

The type LinearTransform is a union of several ordinary Julia types, as

typealias LinearTransform{T<:Real} Union(T,
                                         StridedVector{T},
                                         StridedMatrix{T},
                                         Transpose{T})

Here, Transpose is a swallow wrapper of a dense matrix to indicate the use of its transposed version.

The semantics of these types being used as a linear transform type are defined below:

transform(a::Real,   x)       # --> a * x
transform(a::Vector, x)       # --> a .* x
transform(a::Matrix, x)       # --> a * x
transform(a::Transpose, x)    # --> a'x

AffineTransform

The type AffineTransform is defined as

immutable AffineTransform{T,A<:LinearTransform}
    a::A
    b::Vector{T}
end

Applying an affine transform aff as above to x is equivalent to transform(aff.a, x) .+ aff.b. The field b is allowed to be empty, in which case, aff.b is not added to the transformed result.

An affine transform can be constructed as follows:

AffineTransform(a, b)
AffineTransform(a)      # b is set to empty