Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split the whiten and unwhiten docs. #203

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/generics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AbstractPDMat(A::AbstractPDMat) = A
AbstractPDMat(A::AbstractMatrix) = PDMat(A)

## convert
Base.convert(::Type{AbstractMatrix{T}}, a::AbstractPDMat) where {T<:Real} = convert(AbstractPDMat{T}, a)
Base.convert(::Type{AbstractMatrix{T}}, a::AbstractPDMat) where {T<:Real} = convert(AbstractPDMat{T}, a)
Base.convert(::Type{AbstractArray{T}}, a::AbstractPDMat) where {T<:Real} = convert(AbstractMatrix{T}, a)

## arithmetics
Expand Down Expand Up @@ -35,11 +35,10 @@ LinearAlgebra.checksquare(a::AbstractPDMat) = size(a, 1)

"""
whiten(a::AbstractMatrix, x::AbstractVecOrMat)
unwhiten(a::AbstractMatrix, x::AbstractVecOrMat)
unwhiten!(a::AbstractMatrix, x::AbstractVecOrMat)
unwhiten!(r::AbstractVecOrMat, a::AbstractPDMat, x::AbstractVecOrMat)
whiten!(a::AbstractMatrix, x::AbstractVecOrMat)
whiten!(r::AbstractVecOrMat, a::AbstractPDMat, x::AbstractVecOrMat)

Allocating and in-place versions of the `whiten`ing transform (or its inverse) defined by `a` applied to `x`
Allocating and in-place versions of the `whiten`ing transform defined by `a` applied to `x`

If the covariance of `x` is `a` then the covariance of the result will be `I`.
The name `whiten` indicates that this function transforms a correlated multivariate random
Expand All @@ -66,8 +65,24 @@ julia> W * W'
1.0 0.0
0.0 1.0
```

See also [`unwhiten`](@ref).
"""
whiten(a::AbstractMatrix{<:Real}, x::AbstractVecOrMat) = whiten(AbstractPDMat(a), x)

"""
unwhiten(a::AbstractMatrix, x::AbstractVecOrMat)
unwhiten!(a::AbstractMatrix, x::AbstractVecOrMat)
unwhiten!(r::AbstractVecOrMat, a::AbstractPDMat, x::AbstractVecOrMat)

Allocating and in-place versions of the `unwhiten`ing transform defined by `a` applied to `x`

If the covariance of `x` is `I` then the covariance of the result will be `a`.
The name `unwhiten` indicates that this function transforms an uncorrelated "white noise" signal
into a signal with the given covariance.

`unwhiten` is the inverse transformation of [`whiten`](@ref).
"""
unwhiten(a::AbstractMatrix{<:Real}, x::AbstractVecOrMat) = unwhiten(AbstractPDMat(a), x)

whiten!(a::AbstractMatrix{<:Real}, x::AbstractVecOrMat) = whiten!(x, a, x)
Expand Down
Loading