当前位置: 首页>>代码示例>>Java>>正文


Java DoubleMatrix1D.set方法代码示例

本文整理汇总了Java中cern.colt.matrix.DoubleMatrix1D.set方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix1D.set方法的具体用法?Java DoubleMatrix1D.set怎么用?Java DoubleMatrix1D.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cern.colt.matrix.DoubleMatrix1D的用法示例。


在下文中一共展示了DoubleMatrix1D.set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Mult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
static DoubleMatrix1D Mult(DoubleMatrix2D M, DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, boolean transposeA, EdgeGenerator edgeGen) {
    // z = alpha * A * y + beta*z
    for (int i = 0; i < z.size(); z.set(i,z.get(i)*beta),i++);
    for (int j = 0; j < M.columns(); j++) {
        for (int i = (edgeGen==null)?j:edgeGen.first(j); i < M.rows(); i = (edgeGen==null)?i+1:edgeGen.next(j,i)) {
            int r = i;
            int c = j;
            if (transposeA) {
                r = j;
                c = i;
            }
            z.set(r, z.getQuick(r) + M.getQuick(i,j)*y.getQuick(c)*alpha);
        }
    }
    return z;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:17,代码来源:RobustMath.java

示例2: computeLogMiTrainMode

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
protected boolean computeLogMiTrainMode(FeatureGenerator featureGen, double lambda[], 
        DataSequence dataSeq, int i, 
        DoubleMatrix2D Mi_YY,
        DoubleMatrix1D Ri_Y, boolean takeExp, boolean reuseM, boolean initMDone) {
    boolean retVal = Trainer.computeLogMi(featureGen,lambda,dataSeq,i,fMi_YY,Ri_Y,false,reuseM,initMDone);
    int iterNum = icall;
    for (int c = 0; c < Ri_Y.size();c++) {
        int loss =  (dataSeq.y(i)!=c)?1:0;
        Ri_Y.set(c,eta*C*(Ri_Y.get(c)+iterNum*loss));
        /*
         * don't need loss for this since it is already accounted for in Ri_Y
         */
        if (i > 0) {
            for (int r = 0; r < Mi_YY.rows(); r++) {
                Mi_YY.set(r,c,eta*C*(fMi_YY.get(r,c)));
            }
        }
    }
    return retVal;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:21,代码来源:ExponentiatedGradientTrainer.java

示例3: computeLogMi

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
protected void computeLogMi(DataSequence dataSeq, int i, DoubleMatrix2D kMi, DoubleMatrix1D kRi, DataSequence consData, YSequence yseq, double alpha) {
    if (consData==null) return;
    for (int j = 0; j < consData.length(); j++) {
        int consY = yseq.getY(j);
        int ypp = consData.y(j);
        if (consY != ypp) {
            double kval = kernelValue(dataSeq, i, consData, j);
            kRi.set(consY, kRi.get(consY)-alpha*kval);
            kRi.set(ypp, kRi.get(ypp)+alpha*kval);
        }
        if ((i > 0) && (j > 0)) {
            int consPrevY = yseq.getY(j-1);
            int yprev = consData.y(j-1);
            if ((consY != consData.y(j)) || (consPrevY != consData.y(j-1))) {
                kMi.set(consPrevY, consY, kMi.get(consPrevY, consY)-alpha);
                kMi.set(yprev, ypp, kMi.get(yprev, ypp)+alpha);
            }
        }
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:21,代码来源:KernelViterbi.java

示例4: logMult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public static DoubleMatrix1D logMult(DoubleMatrix2D M, DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, boolean transposeA) {
        // z = alpha * A * y + beta*z
        double lalpha = 0;
        if (alpha != 1)
            lalpha = Math.log(alpha);
        if (beta != 0) {
            if (beta != 1) {
                double lbeta = Math.log(beta);
                for (int i = 0; i < z.size(); z.set(i,z.get(i)+lbeta),i++);
            }
        } else {
            z.assign(RobustMath.LOG0);
        }
        // in log domain this becomes: 
        logMult.M = M;
        logMult.z = z;
        logMult.lalpha = lalpha;
        logMult.transposeA = transposeA;
        logMult.y = y;
        logMult.cnt=0;
        M.forEachNonZero(logMult);
//      System.out.println("Matrix "+M.size()+" "+M.columns()+ " "+logMult.cnt);
        return z;
    }
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:25,代码来源:RobustMath.java

示例5: initLogMi

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public static double initLogMi(double defaultValue, Iterator constraints,
        DoubleMatrix2D Mi, DoubleMatrix1D Ri) {
    if (constraints != null) {
        defaultValue = RobustMath.LOG0;
        if (Mi != null) Mi.assign(defaultValue);
        Ri.assign(defaultValue);
        for (; constraints.hasNext();) {
            Constraint constraint = (Constraint)constraints.next();
            if (constraint.type() == Constraint.ALLOW_ONLY) {
                RestrictConstraint cons = (RestrictConstraint)constraint;
                /*
                 for (int c = cons.numAllowed()-1; c >= 0; c--) {
                 Ri.set(cons.allowed(c),0);
                 }
                 */
                for (cons.startScan(); cons.hasNext();) {
                    cons.advance();
                    int y = cons.y();
                    int yprev = cons.yprev();
                    if (yprev < 0) {
                        Ri.set(y,0);
                    } else {
                        if (Mi != null) Mi.set(yprev,y,0);
                    }
                }
            }
        }
    } else {
        if (Mi != null) Mi.assign(defaultValue);
        Ri.assign(defaultValue);    
    } 
    return defaultValue;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:34,代码来源:Trainer.java

示例6: adjustScore

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
private void adjustScore(DataSequence dataSeq, DoubleMatrix1D ri, MatrixWithRange openri, int i, int ell) {
    Segmentation segmentation = (Segmentation)dataSeq;
    int segNum = segmentation.getSegmentId(openri.start);
    int segStart = segmentation.segmentStart(segNum);
    for (int y = 0; y < numY; y++) {
        ri.set(y, ri.get(y)+1);
    }
    if (segStart == openri.start) {
        ri.set(dataSeq.y(segStart), ri.get(dataSeq.y(segStart))-1);
    } else {
        // because the previous segment ended wrongly..
        for (int y = 0; y < numY; y++) {
            ri.set(y, ri.get(y)+1);
        }
    }
    // now see if there is a corr seg included in this segment.
    if (openri.start+1 <= i) {
        segNum = segmentation.getSegmentId(openri.start+1);
        if (segmentation.segmentStart(segNum)==openri.start+1) {
            for (int y = 0; y < numY; y++) {
                ri.set(y, ri.get(y)+1);
                openri.mat.set(y, openri.mat.get(y)+1);
            } 
        }
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:27,代码来源:BSegmentViterbi.java

示例7: addFeatures3

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
private void addFeatures3(FeatureGenCache.AllFeatureCache.Flist vector, DoubleMatrix1D mat, boolean add) {
    for (Iterator<Feature> iter = vector.iterator(); iter.hasNext();) {
        Feature feature = iter.next();
        if (printFeatures)
            System.out.println(feature);
        int f = feature.index();
        double oldVal = mat.get(feature.y());
        if (add) {
            if (oldVal == DEFAULT_VALUE)
                oldVal = 0;
            mat.set(feature.y(),oldVal+lambda[f]*feature.value());
        } else {
            mat.set(feature.y(),oldVal-lambda[f]*feature.value()); 
        }
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:17,代码来源:FeatureStore.java

示例8: addFeatures

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * @param vector
 * @param mat
 * @param add
 */
private void addFeatures(FeatureGenCache.AllFeatureCache.Flist vector, DoubleMatrix1D mat, boolean add) {
    if (vector.size()==0) {
        if (printFeatures) {System.out.println("No features");}
        return;
    }
    DoubleMatrix1D precomputedMat = vector.mat;
    for (int y = mat.size()-1; y >= 0; y--) {
        double val = precomputedMat.get(y);
        if (val == DEFAULT_VALUE) continue;
        double oldVal = mat.get(y);
        if (add) {
            if (oldVal==DEFAULT_VALUE) 
                oldVal = 0;
            mat.set(y,oldVal+val);
        } else
            mat.set(y,oldVal-val);
    }
    if (printFeatures) {
        for (Iterator<Feature> iter = vector.iterator(); iter.hasNext();) {
            Feature feature = iter.next();
            System.out.println(bfgen.featureName(feature.index()));
        }
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:30,代码来源:FeatureStore.java

示例9: doubleTest31

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 */
public static void doubleTest31(int size) {

System.out.println("\ninit");
DoubleMatrix1D a = Factory1D.dense.descending(size);
DoubleMatrix1D b = new WrapperDoubleMatrix1D(a);
DoubleMatrix1D c = b.viewPart(2,3);
DoubleMatrix1D d = c.viewFlip();
//DoubleMatrix1D c = b.viewFlip();
//DoubleMatrix1D d = c.viewFlip();
d.set(0,99);
b = b.viewSorted();
System.out.println("a = "+a);
System.out.println("b = "+b);
System.out.println("c = "+c);
System.out.println("d = "+d);

System.out.println("done");

}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:22,代码来源:TestMatrix2D.java

示例10: getStationaryDistribution

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Loads the stationary distribution into a vector if it was passed in,
 * or calculates it if not.
 *
 * @return DoubleMatrix1D
 */
private DoubleMatrix1D getStationaryDistribution() {
    DoubleMatrix1D piVector = new DenseDoubleMatrix1D(getVertexCount());
    PageRank<V,E> pageRank = new PageRank<V,E>(getGraph(), 
            MapTransformer.getInstance(getEdgeWeights()), 0);
    pageRank.evaluate();
    
    for (V v : getGraph().getVertices())
        piVector.set(mIndexer.get(v), pageRank.getVertexScore(v));
    return piVector;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:17,代码来源:MarkovCentrality.java

示例11: mapTo1DMatrix

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Converts a Map of (Vertex, Double) pairs to a DoubleMatrix1D.
 * 
 * <p>Note: the vertices will appear in the output array in the order given
 * by {@code map}'s iterator.  If you want a particular ordering, use a {@code Map}
 * implementation that provides such an ordering ({@code SortedMap, LinkedHashMap}, etc.).
 */
public static <V> DoubleMatrix1D mapTo1DMatrix(Map<V,Number> map)
{
    int numVertices = map.size();
    DoubleMatrix1D vector = new DenseDoubleMatrix1D(numVertices);
    int i = 0;
    for (V v : map.keySet())
    {
        vector.set(i, map.get(v).doubleValue());
        i++;
    }
    return vector;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:20,代码来源:GraphMatrixOperations.java

示例12: logSumExp

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
static void logSumExp(DoubleMatrix1D v1, DoubleMatrix1D v2) {
    for (int i = 0; i < v1.size(); i++) {
        v1.set(i,logSumExp(v1.get(i), v2.get(i)));
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:6,代码来源:RobustMath.java


注:本文中的cern.colt.matrix.DoubleMatrix1D.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。