org.apache.sis.math.Vector.doubleValue()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.apache.sis.math.Vector.doubleValue()方法的一些代码示例,展示了Vector.doubleValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.doubleValue()方法的具体详情如下:
包路径:org.apache.sis.math.Vector
类名称:Vector
方法名:doubleValue

Vector.doubleValue介绍

[英]Returns the value at the given index as a double. This is the safest method since all primitive types supported by Vectorare convertible to the double type.
[中]以双精度形式返回给定索引处的值。这是最安全的方法,因为Vector支持的所有基元类型都可以转换为double类型。

代码示例

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Return the ordinate value at the given dimension.
 */
@Override
public double getOrdinate(final int dimension) {
  return ordinates[dimension].doubleValue(index);
}

代码示例来源:origin: apache/sis

/**
 * Return the ordinate value at the given dimension.
 */
@Override
public double getOrdinate(final int dimension) {
  return ordinates[dimension].doubleValue(index);
}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns the value at the given index.
 */
@Override
public double doubleValue(int index) {
  final Vector v;
  if (index < limit) {
    v = first;
  } else {
    v = second;
    index -= limit;
  }
  return v.doubleValue(index);
}

代码示例来源:origin: apache/sis

/**
 * Returns the value at the given index.
 */
@Override
public double doubleValue(int index) {
  final Vector v;
  if (index < limit) {
    v = first;
  } else {
    v = second;
    index -= limit;
  }
  return v.doubleValue(index);
}

代码示例来源:origin: org.apache.sis.core/sis-utility

@Override public double   doubleValue(int i)    {return Vector.this.doubleValue(indices[i]);}
@Override public float    floatValue (int i)    {return Vector.this.floatValue (indices[i]);}

代码示例来源:origin: apache/sis

@Override public double   doubleValue(int i)    {return Vector.this.doubleValue(indices[i]);}
@Override public float    floatValue (int i)    {return Vector.this.floatValue (indices[i]);}

代码示例来源:origin: org.apache.sis.core/sis-feature

/**
   * Returns {@code true} if the last coordinate of the {@code previous} vector is equals to the first
   * coordinate of the {@code next} vector.
   *
   * @param previous   the previous vector.
   * @param next       the next vector.
   * @param dimension  number of dimension in each coordinate.
   */
  private static boolean equals(final Vector previous, final Vector next, int dimension) {
    int p = previous.size();
    while (--dimension >= 0) {
      if (next.doubleValue(dimension) != previous.doubleValue(--p)) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: apache/sis

/**
   * Returns {@code true} if the last coordinate of the {@code previous} vector is equals to the first
   * coordinate of the {@code next} vector.
   *
   * @param previous   the previous vector.
   * @param next       the next vector.
   * @param dimension  number of dimension in each coordinate.
   */
  private static boolean equals(final Vector previous, final Vector next, int dimension) {
    int p = previous.size();
    while (--dimension >= 0) {
      if (next.doubleValue(dimension) != previous.doubleValue(--p)) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: org.apache.sis.storage/sis-netcdf

/**
   * Returns a coordinate for the given two-dimensional grid coordinate axis.
   * This is (indirectly) a callback method for {@link #getAxes()}.
   */
  @Override
  protected double coordinateForAxis(final Object axis, final int j, final int i) throws IOException, DataStoreException {
    final VariableInfo v = ((VariableInfo) axis);
    final int n = v.dimensions[0].length;
    return v.read().doubleValue(j + n*i);
  }
}

代码示例来源:origin: apache/sis

/**
 * Returns a coordinate for the given two-dimensional grid coordinate axis.
 * This is (indirectly) a callback method for {@link #getAxes()}.
 *
 * @throws ArithmeticException if the axis size exceeds {@link Integer#MAX_VALUE}, or other overflow occurs.
 */
@Override
protected double coordinateForAxis(final Variable axis, final int j, final int i) throws IOException, DataStoreException {
  final VariableInfo v = (VariableInfo) axis;
  final int n = v.dimensions[0].length;
  return v.read().doubleValue(j + n*i);
}

代码示例来源:origin: org.apache.sis.core/sis-utility

@Override public double  doubleValue(int index)     {return Vector.this.doubleValue(toBacking(index));}
@Override public float   floatValue (int index)     {return Vector.this.floatValue (toBacking(index));}

代码示例来源:origin: apache/sis

@Override public final double  doubleValue(int i) {return base.doubleValue(toBase(i));}
@Override public final float   floatValue (int i) {return base.floatValue (toBase(i));}

代码示例来源:origin: apache/sis

@Override public double  doubleValue(int index)     {return Vector.this.doubleValue(toBacking(index));}
@Override public float   floatValue (int index)     {return Vector.this.floatValue (toBacking(index));}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns {@code true} if this vector contains only integer values.
 * This method may iterate over all values for performing this verification.
 *
 * @return {@code true} if this vector contains only integer values.
 */
public boolean isInteger() {
  if (!Numbers.isInteger(getElementType())) {
    for (int i=size(); --i >= 0;) {
      final double v = doubleValue(i);
      if (v != Math.floor(v)) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: apache/sis

/**
 * Returns {@code true} if this vector contains only integer values.
 * This method may iterate over all values for performing this verification.
 *
 * @return {@code true} if this vector contains only integer values.
 */
public boolean isInteger() {
  if (!Numbers.isInteger(getElementType())) {
    for (int i=size(); --i >= 0;) {
      final double v = doubleValue(i);
      if (v != Math.floor(v)) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: apache/sis

/**
 * Sets the {@link #affine} transform from a complete matrix.
 *
 * @param  terms  the matrix in a row-major fashion.
 * @param  size   the matrix size, either 3 or 4.
 */
public void setGridToCRS(final Vector terms, final int size) {
  final int length = terms.size();
  completeMatrixSpecified = true;
  affine = Matrices.createZero(size, size);
  affine.setElement(size-1, size-1, 1);
  for (int i=0; i<length; i++) {
    affine.setElement(i / size, i % size, terms.doubleValue(i));
  }
}

代码示例来源:origin: apache/sis

/**
   * Asserts that the content of the given vector are equal.
   * The vectors do not need to use the same element type.
   */
  private static void assertContentEquals(final Vector expected, final Vector actual) {
    final int length = expected.size();
    assertEquals("size", length, actual.size());
    for (int i=0; i<length; i++) {
      assertEquals("value", expected.doubleValue(i), actual.doubleValue(i), STRICT);
    }
  }
}

代码示例来源:origin: apache/sis

/**
 * Sets only the scale terms of the {@link #affine} transform.
 * The translation terms are set to NaN, meaning they will need to be determined later.
 */
public void setScaleFactors(final Vector terms) {
  final int size = terms.size();
  completeMatrixSpecified = false;
  affine = Matrices.createZero(size+1, size+1);
  affine.setElement(size, size, 1);
  for (int i=0; i<size; i++) {
    double e = terms.doubleValue(i);
    if (i == 1) e = -e;                             // Make y scale factor negative.
    affine.setElement(i, i, e);
    affine.setElement(i, size, Double.NaN);
  }
}

代码示例来源:origin: apache/sis

/**
 * Tests {@link SequenceVector} with float values.
 */
@Test
public void testSequenceOfFloats() {
  vector = Vector.createSequence(100, 0.1, 10);
  assertEquals(Double.class, vector.getElementType());
  assertEquals(10, vector.size());
  for (int i=0; i<vector.size(); i++) {
    assertEquals(100 + 0.1*i, vector.doubleValue(i), 1E-10);
  }
}

代码示例来源:origin: apache/sis

/**
 * Tests a vector backed by an array of strings.
 * This is not recommended, but happen in GDAL extensions of GeoTIFF.
 * See {@code org.apache.sis.storage.geotiff.Type.ASCII}.
 */
@Test
public void testStringArray() {
  vector = Vector.create(new String[] {"100", "80", "-20"}, false);
  assertEquals(  3, vector.size());
  assertEquals(100, vector.intValue(0));
  assertEquals( 80, vector.shortValue(1));
  assertEquals(-20, vector.doubleValue(2), STRICT);
}

相关文章