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


Java RealVector.getEntry方法代码示例

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


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

示例1: apply

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Compute the LSH for a given vector.
 */
public long apply(RealVector vector)
{
  /*
   * The hash is just floor(<v, a>/w)
   */
   double ret = b;
  
   for(int i = 0;i < dim;++i)
   {
      ret += vector.getEntry(i)*a[i];
   }
   return (long)Math.floor(ret/w);
}
 
开发者ID:apache,项目名称:incubator-datafu,代码行数:17,代码来源:AbstractStableDistributionFunction.java

示例2: testSparseVectors

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
@Test
public void testSparseVectors() throws IOException, ParseException
{
  RandomGenerator rg = new JDKRandomGenerator();
  rg.setSeed(0);
  RandomData rd = new RandomDataImpl(rg);
  int n = 20;
  List<RealVector> vectors = LSHTest.getVectors(rd, 1000, n);
  PigTest test = createPigTestFromString(sparseVectorTest);
  writeLinesToFile("input", getSparseLines(vectors));
  test.runScript();
  List<Tuple> neighbors = this.getLinesForAlias(test, "PTS");
  Assert.assertEquals(neighbors.size(), n);
  int idx = 0;
  for(Tuple t : neighbors)
  {
    Assert.assertTrue(t.get(0) instanceof DataBag);
    Assert.assertEquals(t.size(), 1);
    RealVector interpreted = DataTypeUtil.INSTANCE.convert(t, 3);
    RealVector original = vectors.get(idx);
    Assert.assertEquals(original.getDimension(), interpreted.getDimension());
    for(int i = 0;i < interpreted.getDimension();++i)
    {
      double originalField = original.getEntry(i);
      double interpretedField = interpreted.getEntry(i);
      Assert.assertTrue(Math.abs(originalField - interpretedField) < 1e-5);
    }
    
    idx++;
  }
}
 
开发者ID:apache,项目名称:incubator-datafu,代码行数:32,代码来源:LSHPigTest.java

示例3: solveUpperTriangular

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * <p>Uses back substitution to solve the system</p>
 * 
 * <p>coefficients X = constants</p>
 * 
 * <p>coefficients must upper-triangular and constants must be a column 
 * matrix.  The solution is returned as a column matrix.</p>
 * 
 * <p>The number of columns in coefficients determines the length
 * of the returned solution vector (column matrix).  If constants
 * has more rows than coefficients has columns, excess rows are ignored.
 * Similarly, extra (zero) rows in coefficients are ignored</p>
 * 
 * @param coefficients upper-triangular coefficients matrix
 * @param constants column RHS constants vector
 * @return solution matrix as a column vector
 * 
 */
private static RealVector solveUpperTriangular(RealMatrix coefficients,
                                               RealVector constants) {
    checkUpperTriangular(coefficients, 1E-12);
    int length = coefficients.getColumnDimension();
    double x[] = new double[length];
    for (int i = 0; i < length; i++) {
        int index = length - 1 - i;
        double sum = 0;
        for (int j = index + 1; j < length; j++) {
            sum += coefficients.getEntry(index, j) * x[j];
        }
        x[index] = (constants.getEntry(index) - sum) / coefficients.getEntry(index, index);
    } 
    return new ArrayRealVector(x);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:34,代码来源:OLSMultipleLinearRegression.java


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