@@ -46,15 +46,15 @@ __eltype(::Base.EltypeUnknown, a) = _eltype(typeof(first(a)))
4646# Generic column-wise evaluation
4747
4848"""
49- colwise!(r::AbstractArray, metric::PreMetric , a, b)
49+ colwise!(metric::PreMetric, r::AbstractArray , a, b)
5050
5151Compute distances between corresponding elements of the iterable collections
5252`a` and `b` according to distance `metric`, and store the result in `r`.
5353
5454`a` and `b` must have the same number of elements, `r` must be an array of length
5555`length(a) == length(b)`.
5656"""
57- function colwise! (r :: AbstractArray , metric :: PreMetric , a, b)
57+ function colwise! (metric :: PreMetric , r :: AbstractArray , a, b)
5858 require_one_based_indexing (r)
5959 n = length (a)
6060 length (b) == n || throw (DimensionMismatch (" iterators have different lengths" ))
@@ -65,7 +65,7 @@ function colwise!(r::AbstractArray, metric::PreMetric, a, b)
6565 r
6666end
6767
68- function colwise! (r :: AbstractArray , metric :: PreMetric , a:: AbstractVector , b:: AbstractMatrix )
68+ function colwise! (metric :: PreMetric , r :: AbstractArray , a:: AbstractVector , b:: AbstractMatrix )
6969 require_one_based_indexing (r)
7070 n = size (b, 2 )
7171 length (r) == n || throw (DimensionMismatch (" Incorrect size of r." ))
@@ -75,7 +75,7 @@ function colwise!(r::AbstractArray, metric::PreMetric, a::AbstractVector, b::Abs
7575 r
7676end
7777
78- function colwise! (r :: AbstractArray , metric :: PreMetric , a:: AbstractMatrix , b:: AbstractVector )
78+ function colwise! (metric :: PreMetric , r :: AbstractArray , a:: AbstractMatrix , b:: AbstractVector )
7979 require_one_based_indexing (r)
8080 n = size (a, 2 )
8181 length (r) == n || throw (DimensionMismatch (" Incorrect size of r." ))
@@ -86,11 +86,11 @@ function colwise!(r::AbstractArray, metric::PreMetric, a::AbstractMatrix, b::Abs
8686end
8787
8888"""
89- colwise!(r::AbstractArray, metric::PreMetric ,
89+ colwise!(metric::PreMetric, r::AbstractArray ,
9090 a::AbstractMatrix, b::AbstractMatrix)
91- colwise!(r::AbstractArray, metric::PreMetric ,
91+ colwise!(metric::PreMetric, r::AbstractArray ,
9292 a::AbstractVector, b::AbstractMatrix)
93- colwise!(r::AbstractArray, metric::PreMetric ,
93+ colwise!(metric::PreMetric, r::AbstractArray ,
9494 a::AbstractMatrix, b::AbstractVector)
9595
9696Compute distances between each corresponding columns of `a` and `b` according
@@ -105,7 +105,7 @@ vector. `r` must be an array of length `maximum(size(a, 2), size(b, 2))`.
105105 If both `a` and `b` are vectors, the generic, iterator-based method of
106106 `colwise` applies.
107107"""
108- function colwise! (r :: AbstractArray , metric :: PreMetric , a:: AbstractMatrix , b:: AbstractMatrix )
108+ function colwise! (metric :: PreMetric , r :: AbstractArray , a:: AbstractMatrix , b:: AbstractMatrix )
109109 require_one_based_indexing (r, a, b)
110110 n = get_common_ncols (a, b)
111111 length (r) == n || throw (DimensionMismatch (" Incorrect size of r." ))
@@ -126,7 +126,7 @@ Compute distances between corresponding elements of the iterable collections
126126function colwise (metric:: PreMetric , a, b)
127127 n = get_common_length (a, b)
128128 r = Vector {result_type(metric, a, b)} (undef, n)
129- colwise! (r, metric , a, b)
129+ colwise! (metric, r , a, b)
130130end
131131
132132"""
@@ -148,25 +148,25 @@ vector.
148148function colwise (metric:: PreMetric , a:: AbstractMatrix , b:: AbstractMatrix )
149149 n = get_common_ncols (a, b)
150150 r = Vector {result_type(metric, a, b)} (undef, n)
151- colwise! (r, metric , a, b)
151+ colwise! (metric, r , a, b)
152152end
153153
154154function colwise (metric:: PreMetric , a:: AbstractVector , b:: AbstractMatrix )
155155 n = size (b, 2 )
156156 r = Vector {result_type(metric, a, b)} (undef, n)
157- colwise! (r, metric , a, b)
157+ colwise! (metric, r , a, b)
158158end
159159
160160function colwise (metric:: PreMetric , a:: AbstractMatrix , b:: AbstractVector )
161161 n = size (a, 2 )
162162 r = Vector {result_type(metric, a, b)} (undef, n)
163- colwise! (r, metric , a, b)
163+ colwise! (metric, r , a, b)
164164end
165165
166166
167167# Generic pairwise evaluation
168168
169- function _pairwise! (r :: AbstractMatrix , metric :: PreMetric , a, b= a)
169+ function _pairwise! (metric :: PreMetric , r :: AbstractMatrix , a, b= a)
170170 require_one_based_indexing (r)
171171 na = length (a)
172172 nb = length (b)
@@ -177,7 +177,7 @@ function _pairwise!(r::AbstractMatrix, metric::PreMetric, a, b=a)
177177 r
178178end
179179
180- function _pairwise! (r :: AbstractMatrix , metric :: PreMetric ,
180+ function _pairwise! (metric :: PreMetric , r :: AbstractMatrix ,
181181 a:: AbstractMatrix , b:: AbstractMatrix = a)
182182 require_one_based_indexing (r, a, b)
183183 na = size (a, 2 )
@@ -192,7 +192,7 @@ function _pairwise!(r::AbstractMatrix, metric::PreMetric,
192192 r
193193end
194194
195- function _pairwise! (r :: AbstractMatrix , metric :: SemiMetric , a)
195+ function _pairwise! (metric :: SemiMetric , r :: AbstractMatrix , a)
196196 require_one_based_indexing (r)
197197 n = length (a)
198198 size (r) == (n, n) || throw (DimensionMismatch (" Incorrect size of r." ))
@@ -208,7 +208,7 @@ function _pairwise!(r::AbstractMatrix, metric::SemiMetric, a)
208208 r
209209end
210210
211- function _pairwise! (r :: AbstractMatrix , metric :: SemiMetric , a:: AbstractMatrix )
211+ function _pairwise! (metric :: SemiMetric , r :: AbstractMatrix , a:: AbstractMatrix )
212212 require_one_based_indexing (r)
213213 n = size (a, 2 )
214214 size (r) == (n, n) || throw (DimensionMismatch (" Incorrect size of r." ))
@@ -237,7 +237,7 @@ function deprecated_dims(dims::Union{Nothing,Integer})
237237end
238238
239239"""
240- pairwise!(r::AbstractMatrix, metric::PreMetric ,
240+ pairwise!(metric::PreMetric, r::AbstractMatrix ,
241241 a::AbstractMatrix, b::AbstractMatrix=a; dims)
242242
243243Compute distances between each pair of rows (if `dims=1`) or columns (if `dims=2`)
@@ -247,7 +247,7 @@ If a single matrix `a` is provided, compute distances between its rows or column
247247`a` and `b` must have the same numbers of columns if `dims=1`, or of rows if `dims=2`.
248248`r` must be a matrix with size `size(a, dims) × size(b, dims)`.
249249"""
250- function pairwise! (r :: AbstractMatrix , metric :: PreMetric ,
250+ function pairwise! (metric :: PreMetric , r :: AbstractMatrix ,
251251 a:: AbstractMatrix , b:: AbstractMatrix ;
252252 dims:: Union{Nothing,Integer} = nothing )
253253 dims = deprecated_dims (dims)
@@ -266,13 +266,13 @@ function pairwise!(r::AbstractMatrix, metric::PreMetric,
266266 size (r) == (na, nb) ||
267267 throw (DimensionMismatch (" Incorrect size of r (got $(size (r)) , expected $((na, nb)) )." ))
268268 if dims == 1
269- _pairwise! (r, metric , permutedims (a), permutedims (b))
269+ _pairwise! (metric, r , permutedims (a), permutedims (b))
270270 else
271- _pairwise! (r, metric , a, b)
271+ _pairwise! (metric, r , a, b)
272272 end
273273end
274274
275- function pairwise! (r :: AbstractMatrix , metric :: PreMetric , a:: AbstractMatrix ;
275+ function pairwise! (metric :: PreMetric , r :: AbstractMatrix , a:: AbstractMatrix ;
276276 dims:: Union{Nothing,Integer} = nothing )
277277 dims = deprecated_dims (dims)
278278 dims in (1 , 2 ) || throw (ArgumentError (" dims should be 1 or 2 (got $dims )" ))
@@ -284,23 +284,23 @@ function pairwise!(r::AbstractMatrix, metric::PreMetric, a::AbstractMatrix;
284284 size (r) == (n, n) ||
285285 throw (DimensionMismatch (" Incorrect size of r (got $(size (r)) , expected $((n, n)) )." ))
286286 if dims == 1
287- _pairwise! (r, metric , permutedims (a))
287+ _pairwise! (metric, r , permutedims (a))
288288 else
289- _pairwise! (r, metric , a)
289+ _pairwise! (metric, r , a)
290290 end
291291end
292292
293293"""
294- pairwise!(r::AbstractMatrix, metric::PreMetric , a, b=a)
294+ pairwise!(metric::PreMetric, r::AbstractMatrix , a, b=a)
295295
296296Compute distances between each element of collection `a` and each element of
297297collection `b` according to distance `metric`, and store the result in `r`.
298298If a single iterable `a` is provided, compute distances between its elements.
299299
300300`r` must be a matrix with size `length(a) × length(b)`.
301301"""
302- pairwise! (r :: AbstractMatrix , metric :: PreMetric , a, b) = _pairwise! (r, metric , a, b)
303- pairwise! (r :: AbstractMatrix , metric :: PreMetric , a) = _pairwise! (r, metric , a)
302+ pairwise! (metric :: PreMetric , r :: AbstractMatrix , a, b) = _pairwise! (metric, r , a, b)
303+ pairwise! (metric :: PreMetric , r :: AbstractMatrix , a) = _pairwise! (metric, r , a)
304304
305305"""
306306 pairwise(metric::PreMetric, a::AbstractMatrix, b::AbstractMatrix=a; dims)
@@ -318,7 +318,7 @@ function pairwise(metric::PreMetric, a::AbstractMatrix, b::AbstractMatrix;
318318 m = size (a, dims)
319319 n = size (b, dims)
320320 r = Matrix {result_type(metric, a, b)} (undef, m, n)
321- pairwise! (r, metric , a, b, dims= dims)
321+ pairwise! (metric, r , a, b, dims= dims)
322322end
323323
324324function pairwise (metric:: PreMetric , a:: AbstractMatrix ;
@@ -327,7 +327,7 @@ function pairwise(metric::PreMetric, a::AbstractMatrix;
327327 dims in (1 , 2 ) || throw (ArgumentError (" dims should be 1 or 2 (got $dims )" ))
328328 n = size (a, dims)
329329 r = Matrix {result_type(metric, a, a)} (undef, n, n)
330- pairwise! (r, metric , a, dims= dims)
330+ pairwise! (metric, r , a, dims= dims)
331331end
332332
333333"""
@@ -341,11 +341,11 @@ function pairwise(metric::PreMetric, a, b)
341341 m = length (a)
342342 n = length (b)
343343 r = Matrix {result_type(metric, a, b)} (undef, m, n)
344- _pairwise! (r, metric , a, b)
344+ _pairwise! (metric, r , a, b)
345345end
346346
347347function pairwise (metric:: PreMetric , a)
348348 n = length (a)
349349 r = Matrix {result_type(metric, a, a)} (undef, n, n)
350- _pairwise! (r, metric , a)
350+ _pairwise! (metric, r , a)
351351end
0 commit comments