We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c547f0d commit 8c2869cCopy full SHA for 8c2869c
lib/pgvector/sparse_vector.ex
@@ -9,13 +9,12 @@ defmodule Pgvector.SparseVector do
9
Creates a new sparse vector from a list, tensor or sparse vector
10
"""
11
def new(list) when is_list(list) do
12
- indices =
+ {values, indices} =
13
list
14
|> Enum.with_index()
15
|> Enum.filter(fn {v, _} -> v != 0 end)
16
- |> Enum.map(fn {_, i} -> i end)
+ |> Enum.unzip()
17
18
- values = list |> Enum.filter(fn v -> v != 0 end)
19
dim = list |> length()
20
nnz = indices |> length()
21
indices = for v <- indices, into: "", do: <<v::signed-32>>
0 commit comments