25
25
<table id="cube-repr-table">
26
26
<title>Cube External Representations</title>
27
27
<tgroup cols="2">
28
+ <thead>
29
+ <row>
30
+ <entry>External Syntax</entry>
31
+ <entry>Meaning</entry>
32
+ </row>
33
+ </thead>
34
+
28
35
<tbody>
29
36
<row>
30
37
<entry><literal><replaceable>x</></literal></entry>
80
87
</para>
81
88
82
89
<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
84
92
<literal>[ ( <replaceable>x</> ), ( <replaceable>y</> ) ]</literal>.
85
93
</para>
86
94
</sect2>
98
106
<title>Usage</title>
99
107
100
108
<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</>.
103
111
</para>
104
112
105
- <table id="cube-operators">
113
+ <table id="cube-operators-table ">
106
114
<title>Cube Operators</title>
107
115
<tgroup cols="3">
108
116
<thead>
240
248
For example, the nearest neighbor of the 3-D point (0.5, 0.5, 0.5)
241
249
could be found efficiently with:
242
250
<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;
246
252
</programlisting>
247
253
</para>
248
254
@@ -252,12 +258,12 @@ LIMIT 1;
252
258
For example, to get the first few cubes ordered by the first coordinate
253
259
(lower left corner) ascending one could use the following query:
254
260
<programlisting>
255
- SELECT c FROM test ORDER BY c ~> 1 LIMIT 5;
261
+ SELECT c FROM test ORDER BY c ~> 1 LIMIT 5;
256
262
</programlisting>
257
263
And to get 2-D cubes ordered by the first coordinate of the upper right
258
264
corner descending:
259
265
<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;
261
267
</programlisting>
262
268
</para>
263
269
@@ -267,128 +273,191 @@ SELECT c FROM test ORDER BY c ~> 3 DESC LIMIT 5;
267
273
268
274
<table id="cube-functions-table">
269
275
<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
+
271
286
<tbody>
272
287
<row>
273
- <entry><literal>cube(float8) returns cube</literal></entry>
288
+ <entry><literal>cube(float8)</literal></entry>
289
+ <entry><type>cube</type></entry>
274
290
<entry>Makes a one dimensional cube with both coordinates the same.
291
+ </entry>
292
+ <entry>
275
293
<literal>cube(1) == '(1)'</literal>
276
294
</entry>
277
295
</row>
278
296
279
297
<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>
281
300
<entry>Makes a one dimensional cube.
301
+ </entry>
302
+ <entry>
282
303
<literal>cube(1,2) == '(1),(2)'</literal>
283
304
</entry>
284
305
</row>
285
306
286
307
<row>
287
- <entry><literal>cube(float8[]) returns cube</literal></entry>
308
+ <entry><literal>cube(float8[])</literal></entry>
309
+ <entry><type>cube</type></entry>
288
310
<entry>Makes a zero-volume cube using the coordinates
289
311
defined by the array.
312
+ </entry>
313
+ <entry>
290
314
<literal>cube(ARRAY[1,2]) == '(1,2)'</literal>
291
315
</entry>
292
316
</row>
293
317
294
318
<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>
296
321
<entry>Makes a cube with upper right and lower left
297
322
coordinates as defined by the two arrays, which must be of the
298
323
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)'
300
327
</literal>
301
328
</entry>
302
329
</row>
303
330
304
331
<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>
310
340
</entry>
311
341
</row>
312
342
313
343
<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>
318
352
</entry>
319
353
</row>
320
354
321
355
<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>
324
362
</entry>
325
363
</row>
326
364
327
365
<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>
331
373
</entry>
332
374
</row>
333
375
334
376
<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>
339
384
</entry>
340
385
</row>
341
386
342
387
<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,
345
391
the two defining corners are the same.</entry>
392
+ <entry>
393
+ </entry>
346
394
</row>
347
395
348
396
<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>
350
399
<entry>Returns the distance between two cubes. If both
351
400
cubes are points, this is the normal distance function.
352
401
</entry>
402
+ <entry>
403
+ </entry>
353
404
</row>
354
405
355
406
<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>
358
409
<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)'</>
365
418
</entry>
366
419
</row>
367
420
368
421
<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>
371
427
</entry>
372
428
</row>
373
429
374
430
<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>
377
436
</entry>
378
437
</row>
379
438
380
439
<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)'</>
392
461
</entry>
393
462
</row>
394
463
</tbody>
0 commit comments