floatvec

floatvec

floatvec : Math for vectors (arrays) of numbers

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4730
floatvec
floatvec
1.1.1
FUNC
MIT
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
pg_rational
uint
uint128
numeral
aggs_for_vecs
aggs_for_arrays
arraymath
financial

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.1.1
18
17
16
15
14
floatvec-
RPM
PIGSTY
1.1.1
18
17
16
15
14
floatvec_$v-
DEB
PIGSTY
1.1.1
18
17
16
15
14
postgresql-$v-floatvec-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
el8.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
el9.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
el9.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
el10.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
el10.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
d12.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
d12.aarch64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
d13.x86_64
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
PIGSTY 1.1.1
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

Source

pig build pkg floatvec;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

pig install floatvec;		# install via package name, for the active PG version

pig install floatvec -v 18;   # install for PG 18
pig install floatvec -v 17;   # install for PG 17
pig install floatvec -v 16;   # install for PG 16
pig install floatvec -v 15;   # install for PG 15
pig install floatvec -v 14;   # install for PG 14

Create this extension with:

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 updated on