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

solve unecessary use of inv function #12

Merged
merged 2 commits into from
Nov 1, 2021
Merged
Changes from 1 commit
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
18 changes: 12 additions & 6 deletions src/transforms/eigenanalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,21 @@ function pcaproj(λ, V)
end

function drsproj(λ, V)
Λ = Diagonal(sqrt.(λ))
S = V * inv(Λ)
S, inv(S)
λₛ = sqrt.(λ)
Λᵢ = Diagonal(1 ./ λₛ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent. In other parts of the code you use ^-1 to represent inverse matrices, and here you use i.

Λₛ = Diagonal(λₛ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use \Lambda = Diagonal(sqrt.(\lambda)) and the corresponding inverse?

S = V * Λᵢ
Sᵢ = Λₛ * transpose(V)
S, Sᵢ
end

function sdsproj(λ, V)
Λ = Diagonal(sqrt.(λ))
S = V * inv(Λ) * transpose(V)
S, inv(S)
λₛ = sqrt.(λ)
Λᵢ = Diagonal(1 ./ λₛ)
Λₛ = Diagonal(λₛ)
S = V * Λᵢ * transpose(V)
Sᵢ = V * Λₛ * transpose(V)
S, Sᵢ
end

function matrices(transform::EigenAnalysis, λ, V)
Expand Down