Re: arrays of floating point numbers / linear algebra operations into the DB

From: Colin Wetherbee <cww(at)denterprises(dot)org>
To: Enrico Sirola <enrico(dot)sirola(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: arrays of floating point numbers / linear algebra operations into the DB
Date: 2008-02-01 14:22:26
Message-ID: 47A32B22.7060409@denterprises.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Enrico Sirola wrote:
> Hello,
> I'd like to perform linear algebra operations on float4/8 arrays. These
> tasks are tipically carried on using ad hoc optimized libraries (e.g.
> BLAS). In order to do this, I studied a bit how arrays are stored
> internally by the DB: from what I understood, arrays are basically a
> vector of Datum, and floating point numbers are stored by reference into
> Datums. At a first glance, this seem to close the discussion because in
> order to perform fast linear algebra operations, you need to store array
> items in consecutive memory cells.
> What are the alternatives? Create a new specialized data type for
> floating point vectors?
> Basically, the use-case is to be able to rescale, add and multiply
> (element-by-element)
> vectors.

I'm not sure about the internals of PostgreSQL (eg. the Datum object(?)
you mention), but if you're just scaling vectors, consecutive memory
addresses shouldn't be absolutely necessary. Add and multiply
operations within a linked list (which is how I'm naively assuming Datum
storage for arrays in memory is implemented) will be "roughly" just as fast.

How many scaling operations are you planning to execute per second, and
how many elements do you scale per operation?

Colin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yuriy Rusinov 2008-02-01 14:36:23 Complex query optimization
Previous Message Stefan Schwarzer 2008-02-01 14:10:03 Re: Forgot to dump old data before re-installing machine [solved]