DataBlock implements IDataBlock, Cloneable { @Override public DataBlock extract(int start, int count) { return extract(start, count, 1); } DataBlock(final double[] data);  DataBlock(final double[] data, final int beg, final int end, final int inc);  DataBlock(final int n);  DataBlock(final IReadDataBlock data); static DataBlock random(final int len); static DataBlock of(IReadDataBlock data); static DataBlock create(final double[] data, final int istart, final int len, final int inc); static DataBlock create(final int n); static DataBlock select(IReadDataBlock data, boolean[] sel); static DataBlock select(IReadDataBlock data, int[] isel); static DataBlock create(final double[] data, final int istart, final int len); void add(final DataBlock r); void add(final double d); void add(int idx, double d); void addAY(double a, DataBlock y); void addAXY(double a, DataBlock x, DataBlock y); void setAY(double a, DataBlock y); void bshift(ShiftOption option); void chs(); void sqrt(); void inv(); void square(); @Override DataBlock clone(); void copy(DataBlock data); void copy(IReadDataBlock data); @Override void copyFrom(double[] buffer, int start); @Override void copyTo(double[] buffer, int start); void cumul(); void cumul(double c); void cumul(double c, int lag); DataBlock deepClone(); void difference(); void difference(DataBlock l, DataBlock r); void difference(double delta); void difference(double c, int lag); double distance(DataBlock data); double dot(DataBlock data); double dot(double[] data); double jdot(int p, DataBlock data); double dotReverse(DataBlock data); double dotReverse(double[] data); double reverseDot(double[] data); DataBlock drop(int nbeg, int nend); boolean bshrink(); boolean eshrink(); boolean shrink(int nbeg, int nend); boolean expand(int nbeg, int nend); DataBlock extend(int nbeg, int nend); @Override DataBlock extract(int start, int count); DataBlock extract(int start, int count, int inc); void fshift(int n); void bshift(int n); void fshift(ShiftOption option); @Override double get(int idx); double[] getData(); int getEndPosition(); int getLastPosition(); int getLastIndex(); int getEndIndex(); int getIncrement(); @Override int getLength(); int getStartPosition(); boolean isConstant(); boolean isConstant(double c); int getMissingCount(); boolean isEmpty(); boolean isZero(); void move(int del); void mul(double d); void mul(DataBlock data); void div(DataBlock data); void div(double d); void mul(int idx, double d); double nrm2(); double nrmInf(); double min(); double max(); double product(); void product(DataBlock row, DataBlockIterator cols); void addProduct(DataBlock row, DataBlockIterator cols); void product(DataBlock l, double d); void product(DataBlockIterator rows, DataBlock col); void addProduct(DataBlockIterator rows, DataBlock col); DataBlock range(int c0, int c1); DataBlock reverse(); @Override DataBlock rextract(int start, int count); void set(double d); @Override void set(int idx, double value); void slide(int del); @Override double ssq(); double ssqc(double m); void sub(DataBlock data); void sub(double d); @Override double sum(); void sum(DataBlock l, DataBlock r); LogSign sumLog(); static double hypot(double a, double b); void round(final int ndec); @Override String toString(); String toString(String fmt); void randomize(); void randomize(int seed); boolean isZero(double zero); void next(int nitems); void previous(int nitems); DataBlock start(); DataBlock end(); @Override double computeRecursively(final double initial, DoubleBinaryOperator fn); @Override void apply(DoubleUnaryOperator fn); @Override void applyIf(DoublePredicate pred, DoubleUnaryOperator fn); @Override void applyRecursively(final double initial, DoubleBinaryOperator fn); @Override boolean check(DoublePredicate pred); @Override int count(DoublePredicate pred); @Override int first(DoublePredicate pred); @Override int last(DoublePredicate pred); void apply(DoubleBinaryOperator fn, DataBlock x); @Override void apply(IReadDataBlock x, DoubleBinaryOperator fn); @Override void set(DoubleSupplier fn); @Override void set(IntToDoubleFunction fn); void set(DoubleUnaryOperator fn, DataBlock x); @Override void set(IReadDataBlock x, DoubleUnaryOperator fn); @Override void setIf(DoublePredicate pred, DoubleSupplier fn); void set(DataBlock x, DataBlock y, DoubleBinaryOperator fn); @Override void set(IReadDataBlock x, IReadDataBlock y, DoubleBinaryOperator fn); DataBlock select(DoublePredicate pred); static DataBlock select(IReadDataBlock data, DoublePredicate pred); static final DataBlock EMPTY; static final double ZERO; static final double ONE; static final double EPSILON; }
@Test public void testExtract() { DataBlock A = new DataBlock(100); DataBlock B = A.extract(0, -1, 3); B.set(1); DataBlock C = B.extract(4, -1, 7); C.set(-1); DataBlock AM = new DataBlock(100).reverse(); DataBlock BM = AM.extract(0, -1, 3); BM.set(1); DataBlock CM = BM.extract(4, -1, 7); CM.set(-1); assertTrue(ReadDataBlock.equals(A, AM, 0)); }