From: Paul Jungwirth <pj@illuminatedcomputing.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Treating float arrays as vectors?
Date: Thu, 17 Jun 2021 09:08:18 -0700
Message-ID: <c6cdac6a-a3cd-88a1-2400-caa4fbb5d832@illuminatedcomputing.com> (raw)
In-Reply-To: <CAGD6t7JaCQfCyDidSZSEh1MJgRhhSrcxwNE0WVoMgKAwjtR6Mw@mail.gmail.com>
References: <CAGD6t7JaCQfCyDidSZSEh1MJgRhhSrcxwNE0WVoMgKAwjtR6Mw@mail.gmail.com>
On 6/17/21 7:13 AM, Celia McInnis wrote:
> I would love it if there was a vector data type in postgresql along with
> such vector operations as addition, subtraction, scalar multiplication,
> cross product, dot product, normalization, length and various sorts of
> vector distances.
I wrote an extension to define vector-based functions that take & return
numeric arrays:
https://github.com/pjungwir/floatvec
It only has basic arithmetic, but matrix math functions could be added.
If you want aggregate functions instead I wrote another extension for that:
https://github.com/pjungwir/aggs_for_vecs
I haven't touched either in a while, but if you find they have problems
on modern versions of Postgres, let me know and I should be able to get
them updated quickly.
I experimented a bit with an AVX implementation, and it showed a
worthwhile performance improvement, but I never got around to adding it
to all functions, so it was just a proof-of-concept. I could dust that
off if you're interested. But since the extension is C things are
already pretty fast.
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pj@illuminatedcomputing.com
Subject: Re: Treating float arrays as vectors?
In-Reply-To: <c6cdac6a-a3cd-88a1-2400-caa4fbb5d832@illuminatedcomputing.com>
References: <CAGD6t7JaCQfCyDidSZSEh1MJgRhhSrcxwNE0WVoMgKAwjtR6Mw@mail.gmail.com> <c6cdac6a-a3cd-88a1-2400-caa4fbb5d832@illuminatedcomputing.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox