• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SparseDoubleMatrix1D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SparseDoubleMatrix1D类属于cern.colt.matrix.impl包,在下文中一共展示了SparseDoubleMatrix1D类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: normalise

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
/**
 * Normalizes the sum of the vector elements to 1
 * @param vector The vector to normalize
 */
public static void normalise(DoubleMatrix1D vector)
{
    double sum =  vector.zSum();
    if( sum == 0 )
        return;
    
    // Treat sparse vectors different
    if( vector instanceof SparseDoubleMatrix1D ){
        IntArrayList indexList = new IntArrayList();
        DoubleArrayList valueList = new DoubleArrayList();
        vector.getNonZeros(indexList, valueList);
        
        
        for(int i=0; i<indexList.size(); i++){
            int indexpos = indexList.getQuick(i);
            double value = valueList.getQuick(i);
            vector.set(indexpos, value/sum );
        }
        return;
    }
  
    // Dense vectors come here
    SeqBlas.seqBlas.dscal(1/sum, vector);
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:29,代码来源:VectorUtils.java


示例2: setLimits

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
/**
 * Cut a value at its limits
 * @param vector The value to evaluate
 * @param min The minimal value
 * @param max The maximal value
 * @return <pre>min <= x <= max</pre>
 */
public static void setLimits(DoubleMatrix1D vector, double min, double max)
{
    // Treat sparse vectors different
    if( vector instanceof SparseDoubleMatrix1D ){
        IntArrayList indexList = new IntArrayList();
        DoubleArrayList valueList = new DoubleArrayList();
        vector.getNonZeros(indexList, valueList);
        
        
        for(int i=0; i<indexList.size(); i++){
            int indexpos = indexList.getQuick(i);
            vector.set(indexpos, MathUtils.setLimits(vector.get(indexpos), min, max));
        }
        return;
    }
    else
    {
        for(int indexpos=0; indexpos<vector.size(); indexpos++)
            vector.set(indexpos, MathUtils.setLimits(vector.get(indexpos), min, max));
    }
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:29,代码来源:VectorUtils.java


示例3: match

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
@Override
public DoubleMatrix1D match(DoubleMatrix1D matrix1D) throws MatrixSizeException {
    SparseDoubleMatrix1D matchedMatrix = new SparseDoubleMatrix1D(matrix1D.size());
    int windowSize;
    try {
        windowSize = getWindowSize(matrix1D);
    } catch (MatrixSizeException e) {
        logger.error(String.format("Similarity Vector has %d cells. It cannot be generated from NxN matrix",
                matrix1D.size()), e);
        throw e;
    }
    for (int startigIndex = 0; startigIndex < matrix1D.size(); startigIndex += windowSize) {
        DoubleMatrix1D row = matrix1D.viewPart(startigIndex, windowSize);
        Map.Entry<Double, Integer> maxScoreEntry = getMaxEntryInRow(windowSize, startigIndex, row);
        matchedMatrix.setQuick(maxScoreEntry.getValue(), maxScoreEntry.getKey());
    }
    return matchedMatrix;
}
 
开发者ID:sapirgolan,项目名称:MFIBlocking,代码行数:19,代码来源:MaxMatcher.java


示例4: product

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
static public double product(DoubleMatrix1D v1, DoubleMatrix1D v2) {
	if (v1 instanceof SparseDoubleMatrix1D) {
		return productQuick(v1, v2);
	} else if (v2 instanceof SparseDoubleMatrix1D) {
		return productQuick(v2, v1);
	} else {
		return v1.zDotProduct(v2);
	}
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:10,代码来源:Matrix2DUtil.java


示例5: MarkovCentrality

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
public MarkovCentrality(DirectedGraph<V,E> graph, Set<V> rootNodes, Map<E,Number> edgeWeightKey) {
    super.initialize(graph, true, false);
    setPriors(rootNodes);
    if (edgeWeightKey == null)
        assignDefaultEdgeTransitionWeights();
    else
        setEdgeWeights(edgeWeightKey);
    normalizeEdgeTransitionWeights();

    mIndexer = Indexer.<V>create(graph.getVertices());
    mRankings = new SparseDoubleMatrix1D(graph.getVertexCount());
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:13,代码来源:MarkovCentrality.java


示例6: forEachNonZero

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
public SparseDoubleMatrix1D forEachNonZero(IntDoubleFunction func) {
    for (int y = 0; y < size(); y++) {
        if (getQuick(y) != 0) 
            setQuick(y,func.apply(y,get(y)));
    }
    return this;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:8,代码来源:LogSparseDoubleMatrix1D.java


示例7: getFeatures

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
public DoubleMatrix1D getFeatures(final DoubleMatrix1D state) {
    // check if we already calculated the features
    DoubleMatrix1D cached = cache.get(state);
    if(cacheEnabled && cached != null && cached.size() == this.size() )
        return cached;

    // do not apply adaption rule if the cache contains s because the rule
    // has been applied already
    adaptionRule.changeNet(state);

    DoubleMatrix1D feat = new SparseDoubleMatrix1D(net.size());
    
    feat.assign(this.featureGenerator.getFeatureVector(state));

    //log4j.debug("Network size: " + net.size());

    if(isNormalized) {
        double sum = feat.zSum();
        
        if (sum != 0) {
            IntArrayList indexList = new IntArrayList();
            DoubleArrayList valueList = new DoubleArrayList();
            feat.getNonZeros(indexList, valueList);

//            log4j.debug(indexList.size()+ " nonzeros" );

            for(int i=0; i<indexList.size(); i++) {
                int indexpos = indexList.getQuick(i);
                double value = valueList.getQuick(i);
                feat.set(indexpos, value/sum );
            }
        }
    }

    if (this.cacheEnabled)
        cache.put(state, feat);

    return feat;
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:40,代码来源:Network.java


示例8: testNormalizeSparse

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
public static void testNormalizeSparse()
{
    final double DELTA = 0.000001;
    DoubleMatrix1D v = new SparseDoubleMatrix1D(5000000);
    for(int i=0; i<50; i++){
        v.set(Uniform.staticNextIntFromTo(0, v.size()-1), Uniform.staticNextDouble());
    }
            
    VectorUtils.normalise(v);
    assertEquals(1.0, v.zSum(),DELTA);
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:12,代码来源:TestVectorUtils.java


示例9: MarkovCentrality

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
public MarkovCentrality(DirectedGraph graph, Set rootNodes, String edgeWeightKey) {
    super.initialize(graph, true, false);
    setPriors(rootNodes);
    if (edgeWeightKey == null)
        assignDefaultEdgeTransitionWeights();
    else
        setUserDefinedEdgeWeightKey(edgeWeightKey);
    normalizeEdgeTransitionWeights();

    mIndexer = Indexer.getIndexer(graph);
    mRankings = new SparseDoubleMatrix1D(graph.numVertices());
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:13,代码来源:MarkovCentrality.java


示例10: make

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
/**
 * Constructs a matrix with the given shape, each cell initialized with zero.
 */
public DoubleMatrix1D make(int size) {
	if (this==sparse) return new SparseDoubleMatrix1D(size);
	return new DenseDoubleMatrix1D(size);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:8,代码来源:DoubleFactory1D.java


示例11: getFeatures

import cern.colt.matrix.impl.SparseDoubleMatrix1D; //导入依赖的package包/类
public DoubleMatrix1D getFeatures(DoubleMatrix1D feat)
{
    DoubleMatrix1D featureVector = new SparseDoubleMatrix1D(getFeatureVectorSize());
    featureVector.set(sSet.indexOf(feat), 1);
    return featureVector;
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:7,代码来源:TabularFeatureFunction.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CMStatusBarManager类代码示例发布时间:2022-05-22
下一篇:
Java TObjectShortIterator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap