Skip to content

Commit 19fdbfc

Browse files
nalimilanKristofferC
authored andcommitted
Add docstrings for pairwise and pairwise! (#124)
1 parent abfc204 commit 19fdbfc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/generic.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ function deprecated_dims(dims::Union{Nothing,Integer})
122122
end
123123
end
124124

125+
"""
126+
pairwise!(r::AbstractMatrix, metric::PreMetric,
127+
a::AbstractMatrix, b::AbstractMatrix=a; dims)
128+
129+
Compute distances between each pair of rows (if `dims=1`) or columns (if `dims=2`)
130+
in `a` and `b` according to distance `metric`, and store the result in `r`.
131+
If a single matrix `a` is provided, compute distances between its rows or columns.
132+
133+
`a` and `b` must have the same numbers of columns if `dims=1`, or of rows if `dims=2`.
134+
`r` must be a square matrix with size `size(a, dims) == size(b, dims)`.
135+
"""
125136
function pairwise!(r::AbstractMatrix, metric::PreMetric,
126137
a::AbstractMatrix, b::AbstractMatrix;
127138
dims::Union{Nothing,Integer}=nothing)
@@ -165,6 +176,15 @@ function pairwise!(r::AbstractMatrix, metric::PreMetric, a::AbstractMatrix;
165176
end
166177
end
167178

179+
"""
180+
pairwise(metric::PreMetric, a::AbstractMatrix, b::AbstractMatrix=a; dims)
181+
182+
Compute distances between each pair of rows (if `dims=1`) or columns (if `dims=2`)
183+
in `a` and `b` according to distance `metric`. If a single matrix `a` is provided,
184+
compute distances between its rows or columns.
185+
186+
`a` and `b` must have the same numbers of columns if `dims=1`, or of rows if `dims=2`.
187+
"""
168188
function pairwise(metric::PreMetric, a::AbstractMatrix, b::AbstractMatrix;
169189
dims::Union{Nothing,Integer}=nothing)
170190
dims = deprecated_dims(dims)

0 commit comments

Comments
 (0)