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


Java Vector.unitVectorEquals方法代码示例

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


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

示例1: initializeAlgorithm

import gov.sandia.cognition.math.matrix.Vector; //导入方法依赖的package包/类
@Override
protected boolean initializeAlgorithm()
{
    // Figure out if there is enough data to run the algorithm.
    if (CollectionUtil.isEmpty(this.data))
    {
        // Can't run the algorithm on empty data.
        return false;
    }

    this.dataSize = this.data.size();
    this.dataList = CollectionUtil.asArrayList(this.data);
    this.dimensionality = DatasetUtil.getInputDimensionality(this.data);
    this.dataSampleSize = Math.min(dataSize, this.sampleSize);

    // Compute a vector to store the update that gets reused between steps.
    final VectorFactory<?> vectorFactory = VectorFactory.getDenseDefault();
    this.update = vectorFactory.createVector(this.dimensionality);

    // Create initial random weights.
    final double lambda = this.regularizationWeight;
    final double sqrtLambda = Math.sqrt(lambda);
    final double initializationRange =
        1.0 / (this.dimensionality * sqrtLambda);
    final Vector initialWeights =
        vectorFactory.createUniformRandom(this.dimensionality,
            -initializationRange, initializationRange, this.random);
    if (initialWeights.norm2() < (1.0 / sqrtLambda))
    {
        initialWeights.unitVectorEquals();
        initialWeights.scaleEquals(1.0 / sqrtLambda);
    }

    this.result = new LinearBinaryCategorizer(initialWeights, 0.0);

    // Compute a vector to store the update that gets reused between steps.
    this.update = vectorFactory.createVector(this.dimensionality);

    return true;
}
 
开发者ID:algorithmfoundry,项目名称:Foundry,代码行数:41,代码来源:PrimalEstimatedSubGradient.java

示例2: estimateEigenvector

import gov.sandia.cognition.math.matrix.Vector; //导入方法依赖的package包/类
/**
     * Estimates the eigenvector corresponding to the largest magnitude 
     * eigenvalue.  The eigenvector will be of unit length, unless the
     * input Matrix is all zeros, in which case the method will return
     * an all-zero Vector.  Please note that all eigenvectors are unique to
     * a direction.  That is, sometimes eigenvectors may be a scale factor 
     * of -1.0 to eigenvectors found by other approaches or initial conditions.
     * <BR><BR>
     * This method is appropriate for sparse matrix problems.
     * 
     * 
     * @return Eigenvector corresponding to the largest magnitude eigenvalue.
     * @param initial 
     * Initial estimate of the eigenvector. This is generally a uniform 
     * (constant nonzero) Vector.
     * @param A The matrix to estimate the eigenvectors for. It must be symmetric.
     *      It will be modified by the algorithm.
     * @param stoppingThreshold The stopping threshold for the power iteration algorithm. The 
     *      algorithm will stop its computation of an eigenvector when the
     * @param maxIterations The maximum number of iterations for the power iteration algorithm.
     */
// TODO: Implement the AnytimeAlgorithm interface here.  --krdixon, 2009-07-02
    public static Vector estimateEigenvector(
        final Vector initial,
        final Matrix A,
        final double stoppingThreshold,
        final int maxIterations )
    {
        // This is the brain-dead algorithm called "Power Iteration"
        Vector v = initial.unitVector();

        double normChange;
        int iteration = 0;
        boolean keepGoing = true;
        while (keepGoing)
        {
            final Vector vPrevious = v;
            v = A.times( v );
            v.unitVectorEquals();
            normChange = v.minus( vPrevious ).norm2();
            iteration++;

            if ((normChange <= stoppingThreshold) || (iteration >= maxIterations))
            {
                keepGoing = false;
            }
        }

        return v;
    }
 
开发者ID:algorithmfoundry,项目名称:Foundry,代码行数:51,代码来源:EigenvectorPowerIteration.java

示例3: normalizeWeights

import gov.sandia.cognition.math.matrix.Vector; //导入方法依赖的package包/类
public void normalizeWeights(
    final Vector weights,
    final Vector counts,
    final Vector globalWeights)
{
    weights.unitVectorEquals();
}
 
开发者ID:algorithmfoundry,项目名称:Foundry,代码行数:8,代码来源:UnitTermWeightNormalizer.java


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