• API Main Page
  • Documentation
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

src/nnsearch.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2010 by Matthias Ihrke                                  *
00003  *   ihrke@nld.ds.mpg.de
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   aint with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00032 #ifndef NNSEARCH_H
00033 # define NNSEARCH_H
00034 #include "mathadd.h"
00035 #include "distances.h"
00036 #include "definitions.h"
00037 #include "optarg.h"
00038 #include "distances.h"
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043   /*-----------------------------------------------------------
00044      - Search Tree
00045      ---------------------------------------------------------*/
00046 
00048   struct btree{
00049      int c;     /* center */
00050      double R;  /* maximal distance from c to any point */
00051      double g;  /* min[ d(c,x)-d(sister,x) ] */
00052      int start; /* start of cluster in A */
00053      int end;   /* end of cluster in A */
00054      double *cdist; /* distances from center for terminal nodes */
00055      struct btree *left;
00056      struct btree *right;
00057   };
00058   typedef struct btree TreeNode;
00061   typedef struct {
00062      int *A;       
00063      const double **d;    
00064      int m, N;      
00065      VectorDistanceFunction distfct; 
00066      TreeNode *root; 
00067      OptArgList *optargs;
00068   } SearchTree;
00069 
00071   TreeNode*   tnode_init();
00072   bool tnode_isleaf( TreeNode *C );
00073   void build_tree_recursive( TreeNode *C, double **D, int N, int *A, int maxel );
00074   SearchTree* searchtree_init( int n );
00078   SearchTree* nn_prepare( const double **X, int m, int N, OptArgList *optargs );
00079   void        nn_search_k( const SearchTree *S, const double *x, int k, 
00080                                     int *nn_idx, double *nn_dist );
00081   void        nn_searck_k_slow( const double **X, int N, int m, 
00082                                           const double *x, int k, int *nn_idx,
00083                                           double *nn_dist, OptArgList *optargs );
00084 
00085 #ifdef __cplusplus
00086 }
00087 #endif
00088 
00089 
00090 #endif

Generated on Fri Jun 25 2010 14:10:20 for libeegtools by  doxygen 1.7.0