1******************************************************************************** 2Changes that were made in July 2006 by Joshua Reich I. 3******************************************************************************** 4 5Code Cleanup: 6 7Update the calling convention for all external facing functions. By external 8facing, I mean all functions that are directly referenced in cube.sql. Prior 9to my update, all functions used the older V0 calling convention. They now 10use V1. 11 12New Functions: 13 14cube(float[]), which makes a zero volume cube from a float array 15 16cube(float[], float[]), which allows the user to create a cube from 17two float arrays; one for the upper right and one for the lower left 18coordinate. 19 20cube_subset(cube, int4[]), to allow you to reorder or choose a subset of 21dimensions from a cube, using index values specified in the array. 22 23******************************************************************************** 24Changes that were made in August/September 2002 by Bruno Wolff III. 25******************************************************************************** 26 27Note that this was based on a 7.3 development version and changes may not 28directly work with earlier versions. 29 30I fixed a bug in cubescan.pl that prevented signed numbers with no digits 31before a decimal point from being accepted. This was submitted as a separate 32patch and may already be applied. 33 34cube_inter should really return NULL if the two cubes don't overlap. However 35this requires changing to the new calling sequence and I don't know enough 36about how to do it to make the change. 37 38I changed all floats to doubles except for g_cube_penalty which I don't 39think can be changed to return double. This might cause the penalty to 40overflow sooner than one might expect, but overflow could have happened 41even with floats. 42 43I changed the output format (in cube_out) to use %.16g instead of %g, since the 44default is only 6 digits of precision. 45 46I changed all of the functions declared with (isstrict) to use the current 47method of declaring this. 48 49I changed all of the externally visible functions to be immutable which 50they are. I don't think this matters for the gist functions and didn't 51try to declare them immutable in case there was something tricky about them 52that I don't understand. 53 54I changed the regression tests to use some larger exponents to test output 55in exponential form. 1e7 was too small for this. 56 57I added some regression tests to check for 16 digits of precision. This 58may or may not be a good idea. 59 60I got rid of the swap_corners function. It created scratch boxes that 61were iterated through and deleted. This is slower than just getting the 62larger or smaller coordinate as needed, since swap_corners was doing the 63same thing with the overhead of a function call and memory allocation. 64 65I added memset calls to zero out newly allocated NDBOXes as the documentation 66on functions indicates should be done. This still doesn't allow a hash 67index for equality since there are multiple representations of the 68same cube. 69 70I got rid of a call to cube_same in cube_lt and cube_gt since the test 71was redundant with other checks being made. The call to cube_same would 72only be faster if most of the time you were comparing equivalent cubes. 73 74In cube_lt and cube_gt, the second (UR) for loop for comparing 75extra coordinates to 0 had the wrong range. 76 77Note that the cube_distance function wasn't mentioned in the README.cube file. 78 79I added regression tests for the cube_distance function. 80 81I added the following new functions: 82cube 83cube_dim 84cube_ll_coord 85cube_ur_coord 86cube_is_point 87cube_enlarge 88 89cube takes text input and returns a cube. This is useful for making cubes 90from computed strings. 91 92cube_dim returns the number of dimensions stored in the data structure 93for a cube. This is useful for constraints on the dimensions of a cube. 94 95cube_ll_coord returns the nth coordinate value for the lower left corner 96of a cube. This is useful for doing coordinate transformations. 97 98cube_ur_coord returns the nth coordinate value for the upper right corner 99of a cube. This is useful for doing coordinate transformations. 100 101cube_is_point returns true if a cube is also a point. This is true when the 102two defining corners are the same. 103 104cube_enlarge increases the size of a cube by a specified radius in at least 105n dimensions. If the radius is negative the box is shrunk instead. This 106is useful for creating bounding boxes around a point for searching for 107nearby points. All defined dimensions are changed by the radius. If n 108is greater than the number of defined dimensions and the cube is being 109increased (r >= 0) then 0 is used as the base for the extra coordinates. 110LL coordinates are decreased by r and UR coordinates are increased by r. If a 111LL coordinate is increased to larger than the corresponding UR coordinate 112(this can only happen when r < 0) than both coordinates are set to their 113average. 114 115I added regression tests for the new functions. 116 117I added documentation for cube_distance and the new functions to README.cube 118as well as making a few other minor changes. 119 120I changed create function to create or replace function in the install 121script. 122 123I limited the number of dimensions allowed in cube_enlarge and cube_in 124to 100 to make it harder for people to mess up the database. The constant 125is defined in cubedata.h and can be increased if you need something larger. 126 127I added grant statements to the install script to make the functions 128executable to everyone. 129 130Bruno Wolff III <bruno@wolff.to> 131