2525 <table id="cube-repr-table">
2626 <title>Cube External Representations</title>
2727 <tgroup cols="2">
28+ <thead>
29+ <row>
30+ <entry>External Syntax</entry>
31+ <entry>Meaning</entry>
32+ </row>
33+ </thead>
34+
2835 <tbody>
2936 <row>
3037 <entry><literal><replaceable>x</></literal></entry>
8087 </para>
8188
8289 <para>
83- White space is ignored, so <literal>[(<replaceable>x</>),(<replaceable>y</>)]</literal> is the same as
90+ White space is ignored on input, so
91+ <literal>[(<replaceable>x</>),(<replaceable>y</>)]</literal> is the same as
8492 <literal>[ ( <replaceable>x</> ), ( <replaceable>y</> ) ]</literal>.
8593 </para>
8694 </sect2>
98106 <title>Usage</title>
99107
100108 <para>
101- <xref linkend="cube-operators"> shows the operators provided for type
102- <type>cube</>.
109+ <xref linkend="cube-operators-table "> shows the operators provided for
110+ type <type>cube</>.
103111 </para>
104112
105- <table id="cube-operators">
113+ <table id="cube-operators-table ">
106114 <title>Cube Operators</title>
107115 <tgroup cols="3">
108116 <thead>
240248 For example, the nearest neighbor of the 3-D point (0.5, 0.5, 0.5)
241249 could be found efficiently with:
242250<programlisting>
243- SELECT c FROM test
244- ORDER BY cube(array[0.5,0.5,0.5]) <-> c
245- LIMIT 1;
251+ SELECT c FROM test ORDER BY c <-> cube(array[0.5,0.5,0.5]) LIMIT 1;
246252</programlisting>
247253 </para>
248254
@@ -252,12 +258,12 @@ LIMIT 1;
252258 For example, to get the first few cubes ordered by the first coordinate
253259 (lower left corner) ascending one could use the following query:
254260<programlisting>
255- SELECT c FROM test ORDER BY c ~> 1 LIMIT 5;
261+ SELECT c FROM test ORDER BY c ~> 1 LIMIT 5;
256262</programlisting>
257263 And to get 2-D cubes ordered by the first coordinate of the upper right
258264 corner descending:
259265<programlisting>
260- SELECT c FROM test ORDER BY c ~> 3 DESC LIMIT 5;
266+ SELECT c FROM test ORDER BY c ~> 3 DESC LIMIT 5;
261267</programlisting>
262268 </para>
263269
@@ -267,128 +273,191 @@ SELECT c FROM test ORDER BY c ~> 3 DESC LIMIT 5;
267273
268274 <table id="cube-functions-table">
269275 <title>Cube Functions</title>
270- <tgroup cols="2">
276+ <tgroup cols="4">
277+ <thead>
278+ <row>
279+ <entry>Function</entry>
280+ <entry>Result</entry>
281+ <entry>Description</entry>
282+ <entry>Example</entry>
283+ </row>
284+ </thead>
285+
271286 <tbody>
272287 <row>
273- <entry><literal>cube(float8) returns cube</literal></entry>
288+ <entry><literal>cube(float8)</literal></entry>
289+ <entry><type>cube</type></entry>
274290 <entry>Makes a one dimensional cube with both coordinates the same.
291+ </entry>
292+ <entry>
275293 <literal>cube(1) == '(1)'</literal>
276294 </entry>
277295 </row>
278296
279297 <row>
280- <entry><literal>cube(float8, float8) returns cube</literal></entry>
298+ <entry><literal>cube(float8, float8)</literal></entry>
299+ <entry><type>cube</type></entry>
281300 <entry>Makes a one dimensional cube.
301+ </entry>
302+ <entry>
282303 <literal>cube(1,2) == '(1),(2)'</literal>
283304 </entry>
284305 </row>
285306
286307 <row>
287- <entry><literal>cube(float8[]) returns cube</literal></entry>
308+ <entry><literal>cube(float8[])</literal></entry>
309+ <entry><type>cube</type></entry>
288310 <entry>Makes a zero-volume cube using the coordinates
289311 defined by the array.
312+ </entry>
313+ <entry>
290314 <literal>cube(ARRAY[1,2]) == '(1,2)'</literal>
291315 </entry>
292316 </row>
293317
294318 <row>
295- <entry><literal>cube(float8[], float8[]) returns cube</literal></entry>
319+ <entry><literal>cube(float8[], float8[])</literal></entry>
320+ <entry><type>cube</type></entry>
296321 <entry>Makes a cube with upper right and lower left
297322 coordinates as defined by the two arrays, which must be of the
298323 same length.
299- <literal>cube('{1,2}'::float[], '{3,4}'::float[]) == '(1,2),(3,4)'
324+ </entry>
325+ <entry>
326+ <literal>cube(ARRAY[1,2], ARRAY[3,4]) == '(1,2),(3,4)'
300327 </literal>
301328 </entry>
302329 </row>
303330
304331 <row>
305- <entry><literal>cube(cube, float8) returns cube</literal></entry>
306- <entry>Makes a new cube by adding a dimension on to an
307- existing cube with the same values for both parts of the new coordinate.
308- This is useful for building cubes piece by piece from calculated values.
309- <literal>cube('(1)',2) == '(1,2),(1,2)'</literal>
332+ <entry><literal>cube(cube, float8)</literal></entry>
333+ <entry><type>cube</type></entry>
334+ <entry>Makes a new cube by adding a dimension on to an existing cube,
335+ with the same values for both endpoints of the new coordinate. This
336+ is useful for building cubes piece by piece from calculated values.
337+ </entry>
338+ <entry>
339+ <literal>cube('(1,2),(3,4)'::cube, 5) == '(1,2,5),(3,4,5)'</literal>
310340 </entry>
311341 </row>
312342
313343 <row>
314- <entry><literal>cube(cube, float8, float8) returns cube</literal></entry>
315- <entry>Makes a new cube by adding a dimension on to an
316- existing cube. This is useful for building cubes piece by piece from
317- calculated values. <literal>cube('(1,2)',3,4) == '(1,3),(2,4)'</literal>
344+ <entry><literal>cube(cube, float8, float8)</literal></entry>
345+ <entry><type>cube</type></entry>
346+ <entry>Makes a new cube by adding a dimension on to an existing
347+ cube. This is useful for building cubes piece by piece from calculated
348+ values.
349+ </entry>
350+ <entry>
351+ <literal>cube('(1,2),(3,4)'::cube, 5, 6) == '(1,2,5),(3,4,6)'</literal>
318352 </entry>
319353 </row>
320354
321355 <row>
322- <entry><literal>cube_dim(cube) returns int</literal></entry>
323- <entry>Returns the number of dimensions of the cube
356+ <entry><literal>cube_dim(cube)</literal></entry>
357+ <entry><type>integer</type></entry>
358+ <entry>Returns the number of dimensions of the cube.
359+ </entry>
360+ <entry>
361+ <literal>cube_dim('(1,2),(3,4)') == '2'</literal>
324362 </entry>
325363 </row>
326364
327365 <row>
328- <entry><literal>cube_ll_coord(cube, int) returns double </literal></entry>
329- <entry>Returns the n'th coordinate value for the lower left
330- corner of a cube
366+ <entry><literal>cube_ll_coord(cube, integer)</literal></entry>
367+ <entry><type>float8</type></entry>
368+ <entry>Returns the <replaceable>n</>-th coordinate value for the lower
369+ left corner of the cube.
370+ </entry>
371+ <entry>
372+ <literal>cube_ll_coord('(1,2),(3,4)', 2) == '2'</literal>
331373 </entry>
332374 </row>
333375
334376 <row>
335- <entry><literal>cube_ur_coord(cube, int) returns double
336- </literal></entry>
337- <entry>Returns the n'th coordinate value for the
338- upper right corner of a cube
377+ <entry><literal>cube_ur_coord(cube, integer)</literal></entry>
378+ <entry><type>float8</type></entry>
379+ <entry>Returns the <replaceable>n</>-th coordinate value for the
380+ upper right corner of the cube.
381+ </entry>
382+ <entry>
383+ <literal>cube_ur_coord('(1,2),(3,4)', 2) == '4'</literal>
339384 </entry>
340385 </row>
341386
342387 <row>
343- <entry><literal>cube_is_point(cube) returns bool</literal></entry>
344- <entry>Returns true if a cube is a point, that is,
388+ <entry><literal>cube_is_point(cube)</literal></entry>
389+ <entry><type>boolean</type></entry>
390+ <entry>Returns true if the cube is a point, that is,
345391 the two defining corners are the same.</entry>
392+ <entry>
393+ </entry>
346394 </row>
347395
348396 <row>
349- <entry><literal>cube_distance(cube, cube) returns double</literal></entry>
397+ <entry><literal>cube_distance(cube, cube)</literal></entry>
398+ <entry><type>float8</type></entry>
350399 <entry>Returns the distance between two cubes. If both
351400 cubes are points, this is the normal distance function.
352401 </entry>
402+ <entry>
403+ </entry>
353404 </row>
354405
355406 <row>
356- <entry><literal>cube_subset(cube, int []) returns cube
357- </literal ></entry>
407+ <entry><literal>cube_subset(cube, integer [])</literal></entry>
408+ <entry><type>cube</type ></entry>
358409 <entry>Makes a new cube from an existing cube, using a list of
359- dimension indexes from an array. Can be used to find both the LL and UR
360- coordinates of a single dimension, e.g.
361- <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[2]) = '(3),(7)'</>.
362- Or can be used to drop dimensions, or reorder them as desired, e.g.
363- <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1]) = '(5, 3,
364- 1, 1),(8, 7, 6, 6)'</>.
410+ dimension indexes from an array. Can be used to extract the endpoints
411+ of a single dimension, or to drop dimensions, or to reorder them as
412+ desired.
413+ </entry>
414+ <entry>
415+ <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[2]) == '(3),(7)'</>
416+ <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1]) ==
417+ '(5,3,1,1),(8,7,6,6)'</>
365418 </entry>
366419 </row>
367420
368421 <row>
369- <entry><literal>cube_union(cube, cube) returns cube</literal></entry>
370- <entry>Produces the union of two cubes
422+ <entry><literal>cube_union(cube, cube)</literal></entry>
423+ <entry><type>cube</type></entry>
424+ <entry>Produces the union of two cubes.
425+ </entry>
426+ <entry>
371427 </entry>
372428 </row>
373429
374430 <row>
375- <entry><literal>cube_inter(cube, cube) returns cube</literal></entry>
376- <entry>Produces the intersection of two cubes
431+ <entry><literal>cube_inter(cube, cube)</literal></entry>
432+ <entry><type>cube</type></entry>
433+ <entry>Produces the intersection of two cubes.
434+ </entry>
435+ <entry>
377436 </entry>
378437 </row>
379438
380439 <row>
381- <entry><literal>cube_enlarge(cube c, double r, int n) returns cube</literal></entry>
382- <entry>Increases the size of a cube by a specified radius in at least
383- n dimensions. If the radius is negative the cube is shrunk instead. This
384- is useful for creating bounding boxes around a point for searching for
385- nearby points. All defined dimensions are changed by the radius r.
386- LL coordinates are decreased by r and UR coordinates are increased by r.
387- If a LL coordinate is increased to larger than the corresponding UR
388- coordinate (this can only happen when r < 0) than both coordinates
389- are set to their average. If n is greater than the number of defined
390- dimensions and the cube is being increased (r >= 0) then 0 is used
391- as the base for the extra coordinates.
440+ <entry><literal>cube_enlarge(c cube, r double, n integer)</literal></entry>
441+ <entry><type>cube</type></entry>
442+ <entry>Increases the size of the cube by the specified
443+ radius <replaceable>r</> in at least <replaceable>n</> dimensions.
444+ If the radius is negative the cube is shrunk instead.
445+ All defined dimensions are changed by the radius <replaceable>r</>.
446+ Lower-left coordinates are decreased by <replaceable>r</> and
447+ upper-right coordinates are increased by <replaceable>r</>. If a
448+ lower-left coordinate is increased to more than the corresponding
449+ upper-right coordinate (this can only happen when <replaceable>r</>
450+ < 0) than both coordinates are set to their average.
451+ If <replaceable>n</> is greater than the number of defined dimensions
452+ and the cube is being enlarged (<replaceable>r</> > 0), then extra
453+ dimensions are added to make <replaceable>n</> altogether;
454+ 0 is used as the initial value for the extra coordinates.
455+ This function is useful for creating bounding boxes around a point for
456+ searching for nearby points.
457+ </entry>
458+ <entry>
459+ <literal>cube_enlarge('(1,2),(3,4)', 0.5, 3) ==
460+ '(0.5,1.5,-0.5),(3.5,4.5,0.5)'</>
392461 </entry>
393462 </row>
394463 </tbody>
0 commit comments