Skip to content

Commit 7f3a28c

Browse files
johnnychen94KristofferC
authored andcommitted
comment the reason of performance regression in #144 (#146)
1 parent 5dbf9b8 commit 7f3a28c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/metrics.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,10 @@ function _pairwise!(r::AbstractMatrix, dist::CosineDist, a::AbstractMatrix)
713713
end
714714

715715
# CorrDist
716+
# This part of codes is accelerated because:
717+
# 1. It calls the accelerated `_pairwise` specilization for CosineDist
718+
# 2. pre-calculated `_centralize_colwise` avoids four times of redundant computations
719+
# of `_centralize` -- ~4x speed up
716720
_centralize_colwise(x::AbstractVector) = x .- mean(x)
717721
_centralize_colwise(x::AbstractMatrix) = x .- mean(x, dims=1)
718722
function colwise!(r::AbstractVector, dist::CorrDist, a::AbstractMatrix, b::AbstractMatrix)
@@ -727,4 +731,4 @@ function _pairwise!(r::AbstractMatrix, dist::CorrDist,
727731
end
728732
function _pairwise!(r::AbstractMatrix, dist::CorrDist, a::AbstractMatrix)
729733
_pairwise!(r, CosineDist(), _centralize_colwise(a))
730-
end
734+
end

0 commit comments

Comments
 (0)