Supported Versions: Current (18) / 17 / 16 / 15 / 14
Development Versions: 19 / devel
Unsupported versions: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3

F.10. cube — a multi-dimensional cube data type #

This module implements a data type cube for representing multidimensional cubes.

This module is considered trusted, that is, it can be installed by non-superusers who have CREATE privilege on the current database.

F.10.1. Syntax #

Table F.1 shows the valid external representations for the cube type. x, y, etc. denote floating-point numbers.

Table F.1. Cube External Representations

External Syntax Meaning
x A one-dimensional point (or, zero-length one-dimensional interval)
(x) Same as above
x1,x2,...,xn A point in n-dimensional space, represented internally as a zero-volume cube
(x1,x2,...,xn) Same as above
(x),(y) A one-dimensional interval starting at x and ending at y or vice versa; the order does not matter
[(x),(y)] Same as above
(x1,...,xn),(y1,...,yn) An n-dimensional cube represented by a pair of its diagonally opposite corners
[(x1,...,xn),(y1,...,yn)] Same as above

It does not matter which order the opposite corners of a cube are entered in. The cube functions automatically swap values if needed to create a uniform lower left — upper right internal representation. When the corners coincide, cube stores only one corner along with an is point flag to avoid wasting space.

White space is ignored on input, so [(x),(y)] is the same as [ ( x ), ( y ) ].

F.10.2. Precision #

Values are stored internally as 64-bit floating point numbers. This means that numbers with more than about 16 significant digits will be truncated.

F.10.3. Usage #

Table F.2 shows the specialized operators provided for type cube.

Table F.2. Cube Operators

Operator

Description

cube && cubeboolean

Do the cubes overlap?

cube @> cubeboolean

Does the first cube contain the second?

cube <@ cubeboolean

Is the first cube contained in the second?

cube -> integerfloat8

Extracts the n-th coordinate of the cube (counting from 1).

cube ~> integerfloat8

Extracts the n-th coordinate of the cube, counting in the following way: n = 2 * k - 1 means lower bound of k-th dimension, n = 2 * k means upper bound of k-th dimension. Negative n denotes the inverse value of the corresponding positive coordinate. This operator is designed for KNN-GiST support.

cube <-> cubefloat8

Computes the Euclidean distance between the two cubes.

cube <#> cubefloat8

Computes the taxicab (L-1 metric) distance between the two cubes.

cube <=> cube