private float multilinearInterpolate(float[] encoded,int od){
  float[] dists=new float[encoded.length];
  for (int i=0; i < dists.length; i++) {
    dists[i]=(float)(encoded[i] - Math.floor(encoded[i]));
  }
  int map=0;
  float val=getSample(encoded,map,od);
  float prev=val;
  for (int i=0; i < dists.length; i++) {
    int idx=0;
    float largest=-1;
    for (int c=0; c < dists.length; c++) {
      if (dists[c] > largest) {
        largest=dists[c];
        idx=c;
      }
    }
    map|=(0x1 << idx);
    float cur=getSample(encoded,map,od);
    val+=dists[idx] * (cur - prev);
    prev=val;
    dists[idx]=-1;
  }
  return val;
}

private float multilinearInterpolate ( float [ ] encoded , int od ) { float [ ] dists = new float [ encoded . length ] ; for ( int i = 0 ; i < dists . length ; i ++ ) { dists [ i ] = ( float ) ( encoded [ i ] - Math . floor ( encoded [ i ] ) ) ; } int map = 0 ; float val = getSample ( encoded , map , od ) ; float prev = val ; for ( int i = 0 ; i < dists . length ; i ++ ) { int idx = 0 ; float largest = - 1 ; for ( int c = 0 ; c < dists . length ; c ++ ) { if ( dists [ c ] > largest ) { largest = dists [ c ] ; idx = c ; } } map |= ( 0x1 << idx ) ; float cur = getSample ( encoded , map , od ) ; val += dists [ idx ] * ( cur - prev ) ; prev = val ; dists [ idx ] = - 1 ; } return val ; }
perform a piecewise multilinear interpolation . the provides a close approximation to the standard linear interpolation , at a far lower cost , since every element is not evaluated at every iteration . instead , a walk of the most significant axes is performed , following the algorithm desribed at : http : / / osl . iu . edu / ~ tveldhui / papers / mascthesis / node33 . html
