Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
pcor.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006    
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef PCOR_HEADER
00018 #define PCOR_HEADER
00019 
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <math.h>
00023 
00024 
00025 
00026 
00027 
00028 #ifndef  SQR
00029 #define SQR(x)  ((x)*(x))
00030 #endif
00031 
00032 #ifndef MAX
00033 #  define MAX(x,y) (((x)>(y)) ? (x) : (y))
00034 #endif
00035 
00036 #ifndef MIN
00037 #  define MIN(x,y) (((x)<(y)) ? (x) : (y))
00038 #endif
00039 
00040 
00041 
00042 
00043 
00044 #define EXPAND_UPDATE
00045 
00046 #ifdef NO_EXPAND_UPDATE
00047 #undef EXPAND_UPDATE
00048 #endif
00049 
00050 
00051 
00052 
00053 
00054 #ifndef REF_FLOAT_SINGLE           
00055    typedef double ref_float ;      
00056 #  define REF_EPS  1.0e-13         
00057 #else
00058    typedef float ref_float ;
00059 #  define REF_EPS  1.0e-7
00060 #endif  
00061 
00062 
00063 
00064 #ifndef VOX_SHORT                  
00065    typedef float vox_data ;
00066 #else
00067    typedef short vox_data ;
00068 #endif  
00069 
00070 
00071 
00072 
00073 
00074    
00075 
00076 
00077 
00078 typedef struct {
00079           int nref ;                    
00080           int nupdate ;                 
00081           ref_float **chol ,            
00082                     *alp , *ff , *gg ;  
00083           ref_float betasq ;            
00084    } references ;
00085 
00086  
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 #define RCH(rr,ii,jj)  (rr->chol[(ii)][(jj)])
00096 
00097 #ifdef OV_DEBUG1
00098 #define REF_DUMP(rr,str) \
00099   {  int iq,jq ; ref_float qsum ; \
00100      fprintf(stderr,"%s: reference dump, nref=%d betasq=%11.4e\n", \
00101              str , rr->nref , rr->betasq ) ; \
00102      for( iq=0 ; iq < rr->nref ; iq++){ \
00103        fprintf(stderr," ROW %d: ",iq) ; \
00104        qsum = 0.0 ; \
00105        for( jq=0 ; jq <= iq ; jq++ ){ \
00106           fprintf(stderr,"%11.4e ",RCH(rr,iq,jq)); \
00107           qsum += SQR(RCH(rr,iq,jq)) ; \
00108        } \
00109        fprintf(stderr,": qsum=%11.4e\n",qsum) ; \
00110        fprintf(stderr,"      alpha=%11.4e  ff=%11.4e  gg=%11.4e\n", \
00111                rr->alp[iq] , rr->ff[iq] , rr->gg[iq] ) ; \
00112      } \
00113    }
00114 #endif
00115 
00116 
00117 
00118 
00119 
00120 typedef struct {
00121           int nvox ;          
00122           int nref ;          
00123           int nupdate ;       
00124           ref_float *chrow ;  
00125 
00126 
00127    } voxel_corr ;
00128 
00129    
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 #define VCH(vv,vox,jj) (vv->chrow[(jj)+(vox)*(vv->nref+1)])
00138 
00139 #ifdef OV_DEBUG1
00140 #define VD 2001
00141 #define VOX_DUMP(vv,vox,str) \
00142    {  int jq ; ref_float qsum = 0.0 ; \
00143       fprintf(stderr,"%s: voxel_corr dump #%d\n  ",str,vox) ; \
00144       for( jq=0 ; jq < vv->nref ; jq++ ){ \
00145         fprintf(stderr,"%11.4e ",VCH(vv,vox,jq)) ; \
00146         qsum += SQR(VCH(vv,vox,jq)) ; \
00147       } \
00148       qsum += VCH(vv,vox,vv->nref) ; \
00149       fprintf(stderr,"%11.4e : qsum=%11.4e\n",VCH(vv,vox,vv->nref),qsum); \
00150    }
00151 #endif
00152 
00153 
00154 
00155 
00156 
00157 typedef struct {
00158           int   num_pcor_pos , num_pcor_neg , num_coef_pos , num_coef_neg ;
00159           float max_pcor_pos , max_pcor_neg , max_coef_pos , max_coef_neg ;
00160    } thresh_result ;
00161 
00162 #ifdef OV_DEBUG1
00163 #define THR_DUMP(thr,str) \
00164 fprintf(stderr,"thresh_results dump for %s\n:") ; \
00165 fprintf(stderr," num_pcor_pos=%d neg=%d  num_coef_pos=%d neg=%d\n", \
00166  (thr).num_pcor_pos,(thr).num_pcor_neg,(thr).num_coef_pos,(thr).num_coef_neg ) ; \
00167 fprintf(stderr," max_pcor_pos=%11.4g neg=%11.4g  max_coef_pos=%11.4g neg=%11.4g\n", \
00168  (thr).max_pcor_pos,(thr).max_pcor_neg,(thr).max_coef_pos,(thr).max_coef_neg ) ;
00169 #endif
00170 
00171 
00172 
00173 
00174 
00175 extern references * new_references() ;
00176 
00177 extern void update_references() ;
00178 
00179 extern voxel_corr * new_voxel_corr() ;
00180 
00181 extern void free_voxel_corr() ;
00182 
00183 extern void free_references() ;
00184 
00185 extern void update_voxel_corr() ;
00186 
00187 extern void get_pcor() ;
00188 
00189 extern void get_coef() ;
00190 
00191 extern void get_pcor_thresh_coef() ;
00192 
00193 extern void get_variances() ;
00194 
00195 extern void get_lsqfit() ;
00196 
00197 #endif