示例#1
0
FeatureRef StandardPcaVlatBuilder::getVlat(string & format){
    FeatureRef vlat;
    size_t dim = getDim(format);
    vlat = boost::make_shared<Feature>(dim);
    float * data = vlat->data();
    
    for(size_t i = 0 ; i < clusters.size(); i++){
        FeatureRef subVlat = clusters[i]->getData(format);
        memcpy(data, subVlat->data(), subVlat->dim()*sizeof(float));
        data += subVlat->dim();
        if((size_t)(data - vlat->data()) > dim)
            retinThrowException("StandardPcaVlatCluster::getVlat => data - vlat->data() > dim");
    }
    return vlat;
}
示例#2
0
JNIEXPORT jobject JNICALL Java_retin_feature_vlat_SparseVlatBuilder_runNativeGenerator
  (JNIEnv *env, jobject thisObject, jobject nativePointerObj, jstring keyObj, jint degre, jstring formatObj){
    RETIN_JAVA_METHOD_BEGIN

    JavaEnv je(env);
    string key = je.createString(keyObj);
    
    FeatureListRef centers = je.getDocumentField<FeatureList> (thisObject,"centers");

    vector<FeatureListRef> tensors; 
    je.getDocumentField<FeatureList> (tensors,thisObject,"tensors");
    
    vector<FloatMatrixRef> Ls; je.getDocumentField<FloatMatrix> (Ls,thisObject,"Ls");
    vector<FloatMatrixRef> Ps; je.getDocumentField<FloatMatrix> (Ps,thisObject,"Ps");
           
    string format = je.createString(formatObj);
    
    
    NativePointerRef instance = je.createDocument<NativePointer>(nativePointerObj);
    NativeDocumentGenerator *ngd = instance->getPointerAs<NativeDocumentGenerator>();
    
    FeatureListRef features = boost::static_pointer_cast<FeatureList>(ngd->computeDocument(key));
    
    SparseVlatBuilder vlat(degre,centers->size(),centers->dim());
    vlat.setCenters(centers->data(),centers->size(),centers->dim());
    for (int d=0;d<degre;d++) {
        FeatureListRef tensor = tensors[d];
        vlat.setMeanTensors(d+1,tensor->data(),tensor->size(),tensor->dim());
    }
    for (int i=0;i<Ls.size();i++) {
        vlat.setEigenDecomposition(i, Ps[i]->data(), Ls[i]->data(), Ps[i]->vectorSize(), Ps[i]->vectorCount());
    }
    
    vlat.setSparsityOn(je.getField<jint>(thisObject,"sparsityOn"));
    vlat.setSparsityStrategy(je.getField<jint>(thisObject,"sparsityStrategy"));
    vlat.setDimSparsity(je.getField<jint>(thisObject,"sparsityDim"));
    vlat.setEnergySparsity(je.getField<jfloat>(thisObject,"sparsityEnergy"));

    vlat.process(features->data(),features->size(),features->dim());

    FeatureRef outputRef = boost::make_shared<Feature>(vlat.getVlatDim(format));
    vlat.getVlat(outputRef->data(),format);

    return je.createObject (outputRef);
    
    RETIN_JAVA_METHOD_END
    return NULL;
}
示例#3
0
void StandardPcaVlatCluster::add(FeatureRef feat){
    add(feat->data(), feat->dim());    
}