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


Java OpenIntToDoubleHashMap类代码示例

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


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

示例1: add

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/**
 * Compute the sum of this matrix and {@code m}.
 *
 * @param m Matrix to be added.
 * @return {@code this} + {@code m}.
 * @throws MatrixDimensionMismatchException if {@code m} is not the same
 * size as {@code this}.
 */
public OpenMapRealMatrix add(OpenMapRealMatrix m)
    throws MatrixDimensionMismatchException {

    MatrixUtils.checkAdditionCompatible(this, m);

    final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
    for (OpenIntToDoubleHashMap.Iterator iterator = m.entries.iterator(); iterator.hasNext();) {
        iterator.advance();
        final int row = iterator.key() / columns;
        final int col = iterator.key() - row * columns;
        out.setEntry(row, col, getEntry(row, col) + iterator.value());
    }

    return out;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:OpenMapRealMatrix.java

示例2: multiply

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @throws NumberIsTooLargeException if {@code m} is an
 * {@code OpenMapRealMatrix}, and the total number of entries of the product
 * is larger than {@code Integer.MAX_VALUE}.
 */
@Override
public RealMatrix multiply(final RealMatrix m)
    throws DimensionMismatchException, NumberIsTooLargeException {
    try {
        return multiply((OpenMapRealMatrix) m);
    } catch (ClassCastException cce) {

        MatrixUtils.checkMultiplicationCompatible(this, m);

        final int outCols = m.getColumnDimension();
        final BlockRealMatrix out = new BlockRealMatrix(rows, outCols);
        for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) {
            iterator.advance();
            final double value = iterator.value();
            final int key      = iterator.key();
            final int i        = key / columns;
            final int k        = key % columns;
            for (int j = 0; j < outCols; ++j) {
                out.addToEntry(i, j, value * m.getEntry(k, j));
            }
        }

        return out;
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:33,代码来源:OpenMapRealMatrix.java

示例3: add

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/**
 * Optimized method to add two OpenMapRealVectors.
 * It copies the larger vector, then iterates over the smaller.
 *
 * @param v Vector to add.
 * @return the sum of {@code this} and {@code v}.
 * @throws DimensionMismatchException if the dimensions do not match.
 */
public OpenMapRealVector add(OpenMapRealVector v)
    throws DimensionMismatchException {
    checkVectorDimensions(v.getDimension());
    boolean copyThis = entries.size() > v.entries.size();
    OpenMapRealVector res = copyThis ? this.copy() : v.copy();
    Iterator iter = copyThis ? v.entries.iterator() : entries.iterator();
    OpenIntToDoubleHashMap randomAccess = copyThis ? entries : v.entries;
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (randomAccess.containsKey(key)) {
            res.setEntry(key, randomAccess.get(key) + iter.value());
        } else {
            res.setEntry(key, iter.value());
        }
    }
    return res;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:OpenMapRealVector.java

示例4: add

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/**
 * Compute the sum of this matrix and {@code m}.
 *
 * @param m Matrix to be added.
 * @return {@code this} + {@code m}.
 * @throws org.apache.commons.math3.exception.DimensionMismatchException
 * if {@code m} is not the same size as this matrix.
 */
public OpenMapRealMatrix add(OpenMapRealMatrix m) {

    // safety check
    MatrixUtils.checkAdditionCompatible(this, m);

    final OpenMapRealMatrix out = new OpenMapRealMatrix(this);
    for (OpenIntToDoubleHashMap.Iterator iterator = m.entries.iterator(); iterator.hasNext();) {
        iterator.advance();
        final int row = iterator.key() / columns;
        final int col = iterator.key() - row * columns;
        out.setEntry(row, col, getEntry(row, col) + iterator.value());
    }

    return out;

}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:25,代码来源:OpenMapRealMatrix.java

示例5: multiply

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public RealMatrix multiply(final RealMatrix m) {
    try {
        return multiply((OpenMapRealMatrix) m);
    } catch (ClassCastException cce) {

        // safety check
        MatrixUtils.checkMultiplicationCompatible(this, m);

        final int outCols = m.getColumnDimension();
        final BlockRealMatrix out = new BlockRealMatrix(rows, outCols);
        for (OpenIntToDoubleHashMap.Iterator iterator = entries.iterator(); iterator.hasNext();) {
            iterator.advance();
            final double value = iterator.value();
            final int key      = iterator.key();
            final int i        = key / columns;
            final int k        = key % columns;
            for (int j = 0; j < outCols; ++j) {
                out.addToEntry(i, j, value * m.getEntry(k, j));
            }
        }

        return out;
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:27,代码来源:OpenMapRealMatrix.java

示例6: add

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/**
 * Optimized method to add two OpenMapRealVectors.
 * It copies the larger vector, then iterates over the smaller.
 *
 * @param v Vector to add.
 * @return the sum of {@code this} and {@code v}.
 * @throws org.apache.commons.math3.exception.DimensionMismatchException
 * if the dimensions do not match.
 */
public OpenMapRealVector add(OpenMapRealVector v) {
    checkVectorDimensions(v.getDimension());
    boolean copyThis = entries.size() > v.entries.size();
    OpenMapRealVector res = copyThis ? this.copy() : v.copy();
    Iterator iter = copyThis ? v.entries.iterator() : entries.iterator();
    OpenIntToDoubleHashMap randomAccess = copyThis ? entries : v.entries;
    while (iter.hasNext()) {
        iter.advance();
        int key = iter.key();
        if (randomAccess.containsKey(key)) {
            res.setEntry(key, randomAccess.get(key) + iter.value());
        } else {
            res.setEntry(key, iter.value());
        }
    }
    return res;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:27,代码来源:OpenMapRealVector.java

示例7: updateTile

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/** Update the tile according to the Digital Elevation Model.
 * @param tile to update
 * @exception RuggedException if tile cannot be updated
 */
public void updateTile(final UpdatableTile tile)
    throws RuggedException {

    tile.setGeometry(minLatitude, minLongitude,
                     latitudeStep, longitudeStep,
                     latitudeRows, longitudeColumns);

    final OpenIntToDoubleHashMap.Iterator iterator = elevations.iterator();
    while (iterator.hasNext()) {
        iterator.advance();
        final int    index          = iterator.key();
        final int    latitudeIndex  = index / longitudeColumns;
        final int    longitudeIndex = index % longitudeColumns;
        final double elevation      = iterator.value();
        tile.setElevation(latitudeIndex, longitudeIndex, elevation);
    }

}
 
开发者ID:CS-SI,项目名称:Rugged,代码行数:23,代码来源:DumpReplayer.java

示例8: add

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
/**
 * Optimized method to add two OpenMapRealVectors.
 * It copies the larger vector, then iterates over the smaller.
 *
 * @param v Vector to add.
 * @return the sum of {@code this} and {@code v}.
 * @throws DimensionMismatchException if the dimensions do not match.
 */
public OpenMapRealVector add(OpenMapRealVector v) {
  checkVectorDimensions(v.getDimension());
  boolean copyThis = entries.size() > v.entries.size();
  OpenMapRealVector res = copyThis ? this.copy() : v.copy();
  OpenIntToDoubleHashMap.Iterator iter = copyThis ? v.entries.iterator() : entries.iterator();
  OpenIntToDoubleHashMap randomAccess = copyThis ? entries : v.entries;
  while (iter.hasNext()) {
    iter.advance();
    int key = iter.key();
    if (randomAccess.containsKey(key)) {
      res.setEntry(key, randomAccess.get(key) + iter.value());
    } else {
      res.setEntry(key, iter.value());
    }
  }
  return res;
}
 
开发者ID:apsaltis,项目名称:oryx,代码行数:26,代码来源:OpenMapRealVector.java

示例9: getSubVector

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
@Override
public OpenMapRealVector getSubVector(int index, int n) {
  checkIndex(index);
  if (n < 0) {
    throw new NotPositiveException(LocalizedFormats.NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE, n);
  }
  checkIndex(index + n - 1);
  OpenMapRealVector res = new OpenMapRealVector(n);
  int end = index + n;
  OpenIntToDoubleHashMap.Iterator iter = entries.iterator();
  while (iter.hasNext()) {
    iter.advance();
    int key = iter.key();
    if (key >= index && key < end) {
      res.setEntry(key - index, iter.value());
    }
  }
  return res;
}
 
开发者ID:apsaltis,项目名称:oryx,代码行数:20,代码来源:OpenMapRealVector.java

示例10: isInfinite

import org.apache.commons.math3.util.OpenIntToDoubleHashMap; //导入依赖的package包/类
@Override
public boolean isInfinite() {
  boolean infiniteFound = false;
  OpenIntToDoubleHashMap.Iterator iter = entries.iterator();
  while (iter.hasNext()) {
    iter.advance();
    double value = iter.value();
    if (Double.isNaN(value)) {
      return false;
    }
    if (Double.isInfinite(value)) {
      infiniteFound = true;
    }
  }
  return infiniteFound;
}
 
开发者ID:apsaltis,项目名称:oryx,代码行数:17,代码来源:OpenMapRealVector.java


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