00001 /*************************************************************************** 00002 * @file gnn_utilities.h 00003 * @brief General \ref libgnn utilities. 00004 * 00005 * @date : 06-08-03 09:34 00006 * @author : Pedro Ortega C. <peortega@dcc.uchile.cl> 00007 * Copyright 2003 Pedro Ortega C. 00008 ****************************************************************************/ 00009 /* 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 */ 00024 00025 #ifndef _GNN_UTILITIES_H_ 00026 #define _GNN_UTILITIES_H_ 00027 00028 /******************************************/ 00029 /* Include Files */ 00030 /******************************************/ 00031 00032 #include <gsl/gsl_vector.h> 00033 #include <gsl/gsl_matrix.h> 00034 #include <gsl/gsl_rng.h> 00035 00036 /******************************************/ 00037 /* Macros and Definitions */ 00038 /******************************************/ 00039 00040 /** 00041 * @brief gets the minimum of two values. 00042 * @ingroup gnn_utilities_doc 00043 */ 00044 #define GNN_MIN(x,y) ( ((x) < (y))? (x) : (y) ) 00045 00046 /** 00047 * @brief gets the maximum of two values. 00048 * @ingroup gnn_utilities_doc 00049 */ 00050 #define GNN_MAX(x,y) ( ((x) > (y))? (x) : (y) ) 00051 00052 /** 00053 * @brief gets the sign of a value. 00054 * @ingroup gnn_utilities_doc 00055 */ 00056 #define GNN_SIGN(x) ( ((x) > 0)? 1 : -1 ) 00057 00058 /** 00059 * @brief shifts two to the left. 00060 * @ingroup gnn_utilities_doc 00061 */ 00062 #define GNN_SHIFT2(a,b,c) (a)=(b);(b)=(c); 00063 00064 /** 00065 * @brief shifts three to the left. 00066 * @ingroup gnn_utilities_doc 00067 */ 00068 #define GNN_SHIFT3(a,b,c,d) (a)=(b);(b)=(c);(c)=(d); 00069 00070 /** 00071 * @brief use \c b's sign for \c a. 00072 * @ingroup gnn_utilities_doc 00073 */ 00074 #define GNN_USE_SIGN(a, b) ( (b) >= 0.0 ? fabs(a) : -fabs(a) ) 00075 00076 00077 00078 /******************************************/ 00079 /* Public Interface */ 00080 /******************************************/ 00081 00082 gsl_rng * 00083 gnn_get_rng (); 00084 00085 int 00086 gnn_vector_resize (gsl_vector **v, int new_size); 00087 00088 int 00089 gnn_vector_sum_elements (gsl_vector *v); 00090 00091 double 00092 gnn_vector_euclidian_dist (const gsl_vector *v, const gsl_vector *u); 00093 00094 00095 int 00096 gnn_matrix_check_sizes_from_stream (FILE *stream, size_t *m, size_t *n); 00097 00098 gsl_vector * 00099 gnn_vector_load (const char *filename); 00100 00101 int 00102 gnn_vector_save (const char *filename, gsl_vector *v); 00103 00104 gsl_matrix * 00105 gnn_matrix_load (const char *filename); 00106 00107 int 00108 gnn_matrix_save (const char *filename, gsl_matrix *A); 00109 00110 00111 00112 #endif /* _GNN_UTILITIES_H_ */ 00113 00114
1.2.18