ncubicInterpolation<scalartype_>::ncubicInterpolation(vectortype minCoord_, vectortype maxCoord_) : dim(minCoord_.size()), minCoord(minCoord_), maxCoord(maxCoord_) { minChild = NULL; maxChild = NULL; };
NGram::vectortype NGram::NGramData::CleanUpWhiteSpace(const vectortype &original, int between_space_count) const { vectortype tempvec; // insert space character in the beginning and end of the vector: if(original.size() > 0) tempvec.insert(tempvec.begin(), between_space_count, (datatype)' '); else return tempvec; // Make a copy of the character keycode vector. // Replace any number of successive white-space characters with // a predefined number of spaces: for(unsigned int i = 0; i < original.size(); i++) { if(original[i] != (datatype)' ' && original[i] != (datatype)'\t' && original[i] != (datatype)'\n') tempvec.push_back(original[i]); else { // skip to the whitespace character that is before the next // non-whitespace-char: while(i < original.size() && (original[i] == (datatype)' ' || original[i] == (datatype)'\t' || original[i] == (datatype)'\n')) i++; i--; // after skipping the whitespaces, add space characters to the copy tempvec.insert(tempvec.end(), between_space_count, (datatype)' '); } } // if the text doesn't end in a space, add some spaces: if(tempvec[tempvec.size()-1] != (datatype)' ') tempvec.insert(tempvec.end(), between_space_count, (datatype)' '); return tempvec; }
typename unicubicInterpolation<scalartype_>::matrixtype unicubicInterpolation<scalartype_>::makeAlpha(covafill<scalartype>* cf,vectortype minCoord,vectortype maxCoord) { matrixtype coords(2,minCoord.size()); for(int i = 0; i < minCoord.size(); ++i){ coords(0,i) = minCoord(i); coords(1,i) = maxCoord(i); } matrixtype Minv = getMinv(); int ncoef = 4; vectortype d = maxCoord - minCoord; vectortype mult(2); mult << 1, d(0); vectortype x(ncoef); x.setZero(); for(int i = 0; i < coords.rows(); ++i){ vectortype tmp(1); tmp(0) = coords(i,0); vectortype vals = cf->operator()(tmp); x.segment(2*i,2) = vals.head(2) * mult; } vectortype alphaCoef = Minv * x.matrix(); matrixtype coefs(4,ncoef/4); coefs.setZero(); int indx = 0; for(int j = 0; j < ncoef/4; ++j) for(int i = 0; i < 4; ++i) coefs(i,j) = alphaCoef(indx++); return coefs; };