Changeset 19156


Ignore:
Timestamp:
02/25/15 16:51:50 (10 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixes covertree by computing maxdist on the fly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/kriging/Observations.cpp

    r19153 r19156  
    155155
    156156        /*Intermediaries*/
    157     int          maxdepth = 20;
    158157         IssmPDouble  minspacing,mintrimming,maxtrimming;
    159158
     
    166165        options->Get(&minspacing,"minspacing",0.01);
    167166        if(minspacing<=0) _error_("minspacing must > 0");
     167
     168        /*Get maximum distance between 2 points
     169         *  maxDist should be the maximum distance that any two points
     170         *  can have between each other. IE p.distance(q) < maxDist for all
     171         *  p,q that you will ever try to insert. The cover tree may be invalid
     172         *  if an inaccurate maxDist is given.*/
     173        IssmPDouble xmin = x[0];
     174        IssmPDouble xmax = x[0];
     175        IssmPDouble ymin = y[0];
     176        IssmPDouble ymax = y[0];
     177        for(int i=1;i<n;i++){
     178                if(x[i]<xmin) xmin=x[i];
     179                if(x[i]>xmax) xmax=x[i];
     180                if(y[i]<ymin) ymin=y[i];
     181                if(y[i]>ymax) ymax=y[i];
     182        }
     183        IssmPDouble maxDist = sqrt(pow(xmax-xmin,2)+pow(ymax-ymin,2));
     184        IssmPDouble base    = 2.;
     185        int         maxdepth = ceilf(log(maxDist)/log(base));
    168186
    169187         _printf0_("Generating covertree with a maximum depth " <<  maxdepth <<"... ");
     
    534552        /*First: Create semivariogram matrix for observations*/
    535553        for(i=0;i<n_obs;i++){
     554                //printf("%g %g ==> %g\n",x[i],y[i],sqrt(pow(x[i]-x_interp,2)+pow(y[i]-y_interp,2)));
    536555                for(j=0;j<=i;j++){
    537556                        A[i*(n_obs+1)+j] = variogram->Covariance(x[i]-x[j],y[i]-y[j]);
Note: See TracChangeset for help on using the changeset viewer.