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

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

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

Vector.createSequence介绍

[英]Creates a sequence of the given type.
[中]创建给定类型的序列。

代码示例

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

/**
 * Creates a sequence of numbers in a given range of values using the given increment.
 * The range of values will be {@code first} inclusive to {@code (first + increment*length)} exclusive.
 * Note that the value given by the {@code first} argument is equivalent to a "lowest" or "minimum" value
 * only if the given increment is positive.
 *
 * <p>The {@linkplain #getElementType() element type} will be inferred from the type of the given
 * {@code Number} instances. If will typically be {@code Integer.class} for the [100:1:120] range
 * and {@code Double.class} for the [0:0.1:1] range.</p>
 *
 * @param  first      the first value, inclusive.
 * @param  increment  the difference between the values at two adjacent indexes.
 * @param  length     the length of the desired vector.
 * @return the given sequence as a vector.
 */
public static Vector createSequence(final Number first, final Number increment, final int length) {
  Class<? extends Number> type;
  type = Numbers.widestClass(first, increment);
  type = Numbers.widestClass(type,
      Numbers.narrowestClass(first.doubleValue() + increment.doubleValue() * (length-1)));
  return createSequence(type, first, increment, length);
}

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

/**
 * Creates a sequence of numbers in a given range of values using the given increment.
 * The range of values will be {@code first} inclusive to {@code (first + increment*length)} exclusive.
 * Note that the value given by the {@code first} argument is equivalent to a "lowest" or "minimum" value
 * only if the given increment is positive.
 *
 * <p>The {@linkplain #getElementType() element type} will be inferred from the type of the given
 * {@code Number} instances. If will typically be {@code Integer.class} for the [100:1:120] range
 * and {@code Double.class} for the [0:0.1:1] range.</p>
 *
 * @param  first      the first value, inclusive.
 * @param  increment  the difference between the values at two adjacent indexes.
 * @param  length     the length of the desired vector.
 * @return the given sequence as a vector.
 */
public static Vector createSequence(final Number first, final Number increment, final int length) {
  Class<? extends Number> type;
  type = Numbers.widestClass(first, increment);
  type = Numbers.widestClass(type,
      Numbers.narrowestClass(first.doubleValue() + increment.doubleValue() * (length-1)));
  return createSequence(type, first, increment, length);
}

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

final Number inc = increment(tolerance);
if (inc != null) {
  return createSequence(getElementType(), get(0), inc, length);

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

final Number inc = increment(tolerance);
if (inc != null) {
  return createSequence(getElementType(), get(0), inc, length);
do if (i >= length) {
  final Double NaN = Numerics.valueOf(Double.NaN);
  return createSequence(getElementType(), NaN, NaN, length);
} while (isNaN(i++));

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

/**
 * Tests {@link SequenceVector} with byte values.
 */
@Test
public void testSequenceOfBytes() {
  vector = Vector.createSequence(100, 2, 10);
  assertEquals(Integer.class, vector.getElementType());
  assertEquals(10, vector.size());
  for (int i=0; i<vector.size(); i++) {
    assertEquals(100 + 2*i, vector.byteValue(i));
  }
}

代码示例来源: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

c = line.fit(vector(sources[0]), vector(targets[j]));
} else {
  c = line.fit(Vector.createSequence(0, 1, gridSize[0]),
         Vector.create(targets[j], false));

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

c = line.fit(vector(sources[0]), vector(targets[j]));
} else {
  c = line.fit(Vector.createSequence(0, 1, gridSize[0]),
         Vector.create(targets[j], false));

相关文章