float Marker::getRatio(float o) { // deprivated // derivate of old2new // hardcode the derivate to improve performance switch (getInterpolationMode()) { // linear case 0: { int i=getAreaOld(o); if (i<0 || i+1>getLength()-1) return 0; float dold=(getOld(i+1)-getOld(i)); if (dold<=0) return 0; return (getNew(i+1)-getNew(i))/dold; } break; default: { // approxmiate ratio float n=100; // TODO automate this float o1=o-1/n; if (o1<0) o1=0; if (o1>1) return 0; float o2=o+1/n; if (o2<0) return 0; if (o2>1) o2=1; if (o2-o1<=0) return 0; return ((old2new(o2)-old2new(o1))/(o2-o1)); } } }
void Marker::print() { std::cout << "Marker" << std::endl; for (int i=0; i<getLength(); ++i) { std::cout << i << " "; std::cout << getOld(i) << " "; std::cout << getNew(i) << std::endl; } }
float Marker::old2new(float o) { // this one does all the interpolation! // for performance reasons you should also hard code the interpolation modes to getRatio(float) and new2old switch (getInterpolationMode()) { // case 0: // linear is default case 1: { // polynominal spline return int_poly(this, o); } break; default: { int i=getAreaOld(o); if (i<0 || i+1>getLength()-1) return 0; // linear interpolation // n - n_i o - o_i // -------------- = -------------- // n_{i+1} - n_i o_{i+1} - o_i return (o-getOld(i))/(getOld(i+1)-getOld(i))*(getNew(i+1)-getNew(i))+getNew(i); } } }
float Marker::new2old(float n) { // inverse of old2new // hardcode the derivate to improve performance switch (getInterpolationMode()) { // linear case 0: { int i=getAreaNew(n); if (i<0 || i+1>getLength()-1) return 0; return (n-getNew(i))/(getNew(i+1)-getNew(i))*(getOld(i+1)-getOld(i))+getOld(i); } break; default: { // TODO // approximate o; float o=n; for (int i=1; i<10; ++i) { o+=(n-old2new(o))/i; } return o; } } }
JNIEXPORT jobject JNICALL Java_com_sun_netstorage_samqfs_mgmt_SamFSConnection_getNewSetTimeout( JNIEnv *env, jclass connCls, jstring hostName, jlong timeout) { return (getNew(env, connCls, hostName, timeout)); }
JNIEXPORT jobject JNICALL Java_com_sun_netstorage_samqfs_mgmt_SamFSConnection_getNew( JNIEnv *env, jclass connCls, jstring hostName) { return (getNew(env, connCls, hostName, DEF_TIMEOUT_SEC)); }
float Marker::getLengthf() { if (getLength()>0) return getNew(getLength()-1)-getNew(0); else return NULL; }
int Marker::getAreaNew(float n) { // TODO n=getNew(i) for (int i=0; i<getLength(); ++i) if (n<getNew(i)) return i-1; return getLength()-1; }
float Marker::nnew2new(float nn) { return nn*(getNew(getLength()-1)-getNew(0))+getNew(0); }
float Marker::new2nnew(float n) { return (n-getNew(0))/(getNew(getLength()-1)-getNew(0)); }