floatvec

Math for vectors (arrays) of numbers

Overview

PackageVersionCategoryLicenseLanguage
floatvec1.1.1FUNCMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
4730floatvecNoYesNoYesNoYes-
Relatedpg_rational uint uint128 numeral aggs_for_vecs aggs_for_arrays arraymath financial

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.1.11817161514floatvec-
RPMPIGSTY1.1.11817161514floatvec_$v-
DEBPIGSTY1.1.11817161514postgresql-$v-floatvec-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
u22.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
u22.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
u24.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
u24.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1

Build

You can build the RPM / DEB packages for floatvec using pig build:

pig build pkg floatvec         # build RPM / DEB packages

Install

You can install floatvec directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install floatvec;          # Install for current active PG version
pig ext install -y floatvec -v 18  # PG 18
pig ext install -y floatvec -v 17  # PG 17
pig ext install -y floatvec -v 16  # PG 16
pig ext install -y floatvec -v 15  # PG 15
pig ext install -y floatvec -v 14  # PG 14
dnf install -y floatvec_18       # PG 18
dnf install -y floatvec_17       # PG 17
dnf install -y floatvec_16       # PG 16
dnf install -y floatvec_15       # PG 15
dnf install -y floatvec_14       # PG 14
apt install -y postgresql-18-floatvec   # PG 18
apt install -y postgresql-17-floatvec   # PG 17
apt install -y postgresql-16-floatvec   # PG 16
apt install -y postgresql-15-floatvec   # PG 15
apt install -y postgresql-14-floatvec   # PG 14

Create Extension:

CREATE EXTENSION floatvec;

Usage

floatvec: element-by-element arithmetic on PostgreSQL arrays

Provides basic arithmetic functions for operating on arrays treated as vectors. Supports SMALLINT, INTEGER, BIGINT, REAL, and DOUBLE PRECISION.

CREATE EXTENSION floatvec;

Functions

Each function accepts two arrays of the same length, or an array and a scalar, or a scalar and an array. Both arguments must be of the same type.

FunctionDescription
vec_add(a, b)Element-by-element addition
vec_sub(a, b)Element-by-element subtraction
vec_mul(a, b)Element-by-element multiplication
vec_div(a, b)Element-by-element division
vec_pow(a, b)Element-by-element exponentiation

Examples

-- Array + Array
SELECT vec_add(ARRAY[1,2,3], ARRAY[10,20,30]);  -- {11,22,33}

-- Array * Scalar
SELECT vec_mul(ARRAY[1.0, 2.0, 3.0], 2.0);     -- {2.0, 4.0, 6.0}

-- Scalar - Array
SELECT vec_sub(10, ARRAY[1,2,3]);               -- {9,8,7}

Last Modified 2026-03-12: add pg extension catalog (95749bf)