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

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

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

Vector.subSampling介绍

[英]Returns a view which contain the values of this vector in a given index range. The returned view will contain the values from index first inclusive to (first + step*length) exclusive with index incremented by the given step value, which can be negative. More specifically the index i in the returned vector will maps the element at index (first + step*i) in this vector.

This method does not copy the values. Consequently any modification to the values of this vector will be reflected in the returned view and vice-versa.
[中]返回一个视图,其中包含给定索引范围内此向量的值。返回的视图将包含从index first inclusive到(first+step*length)exclusive的值,索引按给定的步长值递增,可以是负数。更具体地说,返回向量中的索引i将映射该向量中索引(first + step*i)处的元素。
此方法不会复制值。因此,对该向量值的任何修改都将反映在返回的视图中,反之亦然。

代码示例

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

/**
 * Returns a view which contain the values of this vector in the given index range.
 * The returned view will contain the values from index {@code lower} inclusive to
 * {@code upper} exclusive.
 *
 * <div class="note"><b>Implementation note:</b> this method delegates its work
 * <code>{@linkplain #subSampling(int,int,int) subSampling}(lower, 1, upper - lower)</code>.
 * This method is declared final in order to force subclasses to override {@code subSampling(…)} instead.</div>
 *
 * @param  lower  index of the first value to be included in the returned view.
 * @param  upper  index after the last value to be included in the returned view.
 * @return a view of this vector containing values in the given index range.
 * @throws IndexOutOfBoundsException if an index is outside the [0 … {@linkplain #size() size}-1] range.
 */
@Override
public final Vector subList(final int lower, final int upper) {
  return subSampling(lower, 1, upper - lower);
}

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

/**
 * Returns a view which contain the values of this vector in the given index range.
 * The returned view will contain the values from index {@code lower} inclusive to
 * {@code upper} exclusive.
 *
 * <div class="note"><b>Implementation note:</b> this method delegates its work
 * <code>{@linkplain #subSampling(int,int,int) subSampling}(lower, 1, upper - lower)</code>.
 * This method is declared final in order to force subclasses to override {@code subSampling(…)} instead.</div>
 *
 * @param  lower  index of the first value to be included in the returned view.
 * @param  upper  index after the last value to be included in the returned view.
 * @return a view of this vector containing values in the given index range.
 * @throws IndexOutOfBoundsException if an index is outside the [0 … {@linkplain #size() size}-1] range.
 */
@Override
public final Vector subList(final int lower, final int upper) {
  return subSampling(lower, 1, upper - lower);
}

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

/**
 * Delegates to the backing vectors if possible.
 */
@Override
Vector createSubSampling(final int first, final int step, final int length) {
  if (first >= limit) {
    return second.subSampling(first - limit, step, length);
  }
  if (first + step*length <= limit) {
    return this.first.subSampling(first, step, length);
  }
  return super.createSubSampling(first, step, length);
}

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

/**
 * Delegates to the backing vectors if possible.
 */
@Override
Vector createSubSampling(final int first, final int step, final int length) {
  if (first >= limit) {
    return second.subSampling(first - limit, step, length);
  }
  if (first + step*length <= limit) {
    return this.first.subSampling(first, step, length);
  }
  return super.createSubSampling(first, step, length);
}

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

/** Delegates to the enclosing vector. */
@Override Vector createSubSampling(int first, int step, final int length) {
  first = toBacking(first);
  step *= this.step;
  return Vector.this.subSampling(first, step, length);
}

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

/** Delegates to the enclosing vector. */
@Override Vector createSubSampling(int first, int step, final int length) {
  first = toBacking(first);
  step *= this.step;
  return Vector.this.subSampling(first, step, length);
}

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

/**
 * Returns a view which contains the values of this vector in reverse order.
 *
 * <div class="note"><b>Implementation note:</b> this method delegates its work
 * to <code>{@linkplain #subSampling(int,int,int) subSampling}(size-1, -1, {@linkplain #size() size})</code>.
 * This method is declared final in order to force subclasses to override {@code subSampling(…)} instead.</div>
 *
 * @return the vector values in reverse order.
 */
public final Vector reverse() {
  final int length = size();
  return (length > 1) ? subSampling(length-1, -1, length) : this;
}

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

/**
 * Returns a view which contains the values of this vector in reverse order.
 *
 * <div class="note"><b>Implementation note:</b> this method delegates its work
 * to <code>{@linkplain #subSampling(int,int,int) subSampling}(size-1, -1, {@linkplain #size() size})</code>.
 * This method is declared final in order to force subclasses to override {@code subSampling(…)} instead.</div>
 *
 * @return the vector values in reverse order.
 */
public final Vector reverse() {
  final int length = size();
  return (length > 1) ? subSampling(length-1, -1, length) : this;
}

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

/** Delegates to the enclosing vector if possible. */
@Override Vector createConcatenate(final Vector toAppend) {
  if (toAppend instanceof SubSampling && toAppend.backingVector() == Vector.this) {
    final SubSampling other = (SubSampling) toAppend;
    if (other.step == step && other.first == first + step*length) {
      return Vector.this.subSampling(first, step, length + other.length);
    }
  }
  return super.createConcatenate(toAppend);
}

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

/** Delegates to the enclosing vector if possible. */
@Override Vector createConcatenate(final Vector toAppend) {
  if (toAppend instanceof SubSampling && toAppend.backingVector() == Vector.this) {
    final SubSampling other = (SubSampling) toAppend;
    if (other.step == step && other.first == first + step*length) {
      return Vector.this.subSampling(first, step, length + other.length);
    }
  }
  return super.createConcatenate(toAppend);
}

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

/**
 * Creates a vector of repeated data from the result of a call to {@link Vector#repetitions(int...)}.
 *
 * @param base         the vector on which this vector is derived from.
 * @param repetitions  results of {@link Vector#repetitions(int...)}. Must be non-empty.
 * @param tolerance    tolerance factor for compression of the base vector.
 */
RepeatedVector(final Vector base, final int[] repetitions, final double tolerance) {
  size        = base.size();
  occurrences = repetitions[0];
  cycleLength = (repetitions.length >= 2) ? repetitions[1] : size / occurrences;
  this.base   = base.subSampling(0, occurrences, cycleLength).compress(tolerance);
}

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

return base.subSampling(lower, bs, length);

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

return subSampling(first, step, indices.length);

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

return subSampling(first, step, indices.length);

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

data = data.subSampling(0, step, length);
if (coordinates.trySetTransform(gridToCRS, srcDim, tgtDim, data)) {
  return true;

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

assertEquals(18, vec.intValue  (17));
Vector sub = vec.subSampling(0, 1, 6);
assertFalse("Expected the backing array.", sub instanceof RepeatedVector);
assertArrayEquals(new float[] {10, 10, 10, 12, 15, 18}, sub.floatValues(), (float) STRICT);
sub = vec.subSampling(0, 1, 12);
assertArrayEquals(new float[] {10, 10, 10, 12, 15, 18,
                10, ip, 10, 12, 15, 18}, sub.floatValues(), (float) STRICT);

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

/**
 * Tests the case where values in a grid are repeated horizontally.
 */
@Test
public void testHorizontal() {
  Vector vec = Vector.create(new int[] {
      10, 10, 10, 10,
      12, 12, 12, 12,
      15, 15, 15, 15}, false);
  vec = new RepeatedVector(vec, vec.repetitions(), 0);
  assertArrayEquals(new int[] {4}, vec.repetitions());
  assertEquals(10, vec.intValue  ( 0));
  assertEquals(10, vec.shortValue( 1));
  assertEquals(10, vec.longValue ( 2));
  assertEquals(10, vec.intValue  ( 3));
  assertEquals(12, vec.intValue  ( 4));
  assertEquals(12, vec.shortValue( 7));
  assertEquals(15, vec.longValue ( 8));
  assertEquals(15, vec.intValue  (11));
  Vector sub = vec.subSampling(0, 4, 3);
  assertFalse("Expected the backing array.", sub instanceof RepeatedVector);
  assertArrayEquals(new float[] {10, 12, 15}, sub.floatValues(), (float) STRICT);
}

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

vector = vector.subSampling(100, 2, 100);
assertEquals(100, vector.size());
for (int i=0; i<100; i++) {

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

final Vector sub = vec.subSampling(1, 2, 2);
range = sub.range();
assertEquals(message, 2, range.getMinDouble(), STRICT);

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

assertEquals(12, vec.intValue  (28));
Vector sub = vec.subSampling(0, 3, 4);
assertFalse("Expected the backing array.", sub instanceof RepeatedVector);
assertArrayEquals(new float[] {10, 12, 15, 18}, sub.floatValues(), (float) STRICT);

相关文章