floatvec
Math for vectors (arrays) of numbers
Repository
pjungwir/floatvec
https://github.com/pjungwir/floatvec
Source
floatvec-1.1.1.tar.gz
floatvec-1.1.1.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
floatvec | 1.1.1 | FUNC | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4730 | floatvec | No | Yes | No | Yes | No | Yes | - |
| Related | pg_rational uint uint128 numeral aggs_for_vecs aggs_for_arrays arraymath financial |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.1 | 1817161514 | floatvec | - |
| RPM | PIGSTY | 1.1.1 | 1817161514 | floatvec_$v | - |
| DEB | PIGSTY | 1.1.1 | 1817161514 | postgresql-$v-floatvec | - |
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.
| Function | Description |
|---|---|
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}
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.