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

Format matrix in pairwise docs #1148

Merged
merged 1 commit into from
Nov 28, 2023
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
20 changes: 12 additions & 8 deletions sgkit/distance/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ def pairwise_distance(

To illustrate the algorithm consider the following (4, 5) two dimensional array:

[e.00, e.01, e.02, e.03, e.04]
[e.10, e.11, e.12, e.13, e.14]
[e.20, e.21, e.22, e.23, e.24]
[e.30, e.31, e.32, e.33, e.34]
.. code-block:: none

[e.00, e.01, e.02, e.03, e.04]
[e.10, e.11, e.12, e.13, e.14]
[e.20, e.21, e.22, e.23, e.24]
[e.30, e.31, e.32, e.33, e.34]

The rows of the above matrix are the set of vectors. Now let's label all
the vectors as v0, v1, v2, v3.
Expand All @@ -34,10 +36,12 @@ def pairwise_distance(
distance between each vector and every other vector, will result in 16
distances and the resultant array will be of size (4, 4) as follows:

[v0.v0, v0.v1, v0.v2, v0.v3]
[v1.v0, v1.v1, v1.v2, v1.v3]
[v2.v0, v2.v1, v2.v2, v2.v3]
[v3.v0, v3.v1, v3.v2, v3.v3]
.. code-block:: none

[v0.v0, v0.v1, v0.v2, v0.v3]
[v1.v0, v1.v1, v1.v2, v1.v3]
[v2.v0, v2.v1, v2.v2, v2.v3]
[v3.v0, v3.v1, v3.v2, v3.v3]

The (i, j) position in the resulting array (matrix) denotes the distance
between vi and vj vectors.
Expand Down
Loading