00001 //---------------------------------------------------------------------- 00002 // File: rand.h 00003 // Programmer: Sunil Arya and David Mount 00004 // Description: Basic include file for random point generators 00005 // Last modified: 08/04/06 (Version 1.1.1) 00006 //---------------------------------------------------------------------- 00007 // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 00008 // David Mount. All Rights Reserved. 00009 // 00010 // This software and related documentation is part of the Approximate 00011 // Nearest Neighbor Library (ANN). This software is provided under 00012 // the provisions of the Lesser GNU Public License (LGPL). See the 00013 // file ../ReadMe.txt for further information. 00014 // 00015 // The University of Maryland (U.M.) and the authors make no 00016 // representations about the suitability or fitness of this software for 00017 // any purpose. It is provided "as is" without express or implied 00018 // warranty. 00019 //---------------------------------------------------------------------- 00020 // History: 00021 // Revision 0.1 03/04/98 00022 // Initial release 00023 // Revision 1.0 04/01/05 00024 // Added annClusOrthFlats distribution 00025 // Changed procedure names to avoid namespace conflicts 00026 // Added annClusFlats distribution 00027 // Revision 1.1.1 08/04/06 00028 // Added planted distribution 00029 //---------------------------------------------------------------------- 00030 00031 #ifndef rand_H 00032 #define rand_H 00033 00034 //---------------------------------------------------------------------- 00035 // Basic includes 00036 //---------------------------------------------------------------------- 00037 #include <cstdlib> // standard includes (rand/random) 00038 #include <cmath> // math routines 00039 #include <ANN/ANN.h> // basic ANN includes 00040 00041 //---------------------------------------------------------------------- 00042 // Although random/srandom is a more reliable random number generator, 00043 // many systems do not have it. If it is not available, set the 00044 // preprocessor symbol ANN_NO_RANDOM, and this will substitute the use 00045 // of rand/srand for them. 00046 //---------------------------------------------------------------------- 00047 #ifdef ANN_NO_RANDOM // for systems not having random() 00048 #define ANN_RAND rand 00049 #define ANN_SRAND srand 00050 #define ANN_RAND_MAX RAND_MAX 00051 #else // otherwise use rand() 00052 #define ANN_RAND random 00053 #define ANN_SRAND srandom 00054 #define ANN_RAND_MAX 2147483647UL // 2**{31} - 1 00055 // #define ANN_RAND_MAX 1073741824UL // 2**{30} 00056 #endif 00057 00058 //---------------------------------------------------------------------- 00059 // Globals 00060 //---------------------------------------------------------------------- 00061 extern int annIdum; // random number seed 00062 00063 //---------------------------------------------------------------------- 00064 // External entry points 00065 //---------------------------------------------------------------------- 00066 00067 void annUniformPts( // uniform distribution 00068 ANNpointArray pa, // point array (modified) 00069 int n, // number of points 00070 int dim); // dimension 00071 00072 void annGaussPts( // Gaussian distribution 00073 ANNpointArray pa, // point array (modified) 00074 int n, // number of points 00075 int dim, // dimension 00076 double std_dev); // standard deviation 00077 00078 void annCoGaussPts( // correlated-Gaussian distribution 00079 ANNpointArray pa, // point array (modified) 00080 int n, // number of points 00081 int dim, // dimension 00082 double correlation); // correlation 00083 00084 void annLaplacePts( // Laplacian distribution 00085 ANNpointArray pa, // point array (modified) 00086 int n, // number of points 00087 int dim); // dimension 00088 00089 void annCoLaplacePts( // correlated-Laplacian distribution 00090 ANNpointArray pa, // point array (modified) 00091 int n, // number of points 00092 int dim, // dimension 00093 double correlation); // correlation 00094 00095 void annClusGaussPts( // clustered-Gaussian distribution 00096 ANNpointArray pa, // point array (modified) 00097 int n, // number of points 00098 int dim, // dimension 00099 int n_clus, // number of colors (clusters) 00100 ANNbool new_clust, // generate new cluster centers 00101 double std_dev); // standard deviation within clusters 00102 00103 void annClusOrthFlats( // clustered along orthogonal flats 00104 ANNpointArray pa, // point array (modified) 00105 int n, // number of points 00106 int dim, // dimension 00107 int n_clus, // number of colors 00108 ANNbool new_clust, // generate new clusters. 00109 double std_dev, // standard deviation within clusters 00110 int max_dim); // maximum dimension of the flats 00111 00112 void annClusEllipsoids( // clustered around ellipsoids 00113 ANNpointArray pa, // point array (modified) 00114 int n, // number of points 00115 int dim, // dimension 00116 int n_clus, // number of colors 00117 ANNbool new_clust, // generate new clusters. 00118 double std_dev_small, // small standard deviation 00119 double std_dev_lo, // low standard deviation for ellipses 00120 double std_dev_hi, // high standard deviation for ellipses 00121 int max_dim); // maximum dimension of the flats 00122 00123 void annPlanted( // planted nearest neighbors 00124 ANNpointArray pa, // point array (modified) 00125 int n, // number of points 00126 int dim, // dimension 00127 ANNpointArray src, // source point array 00128 int n_src, // source size 00129 double std_dev); // standard deviation about source 00130 00131 #endif