@Override protected double dotSelf() { double result = 0.0; int max = size(); for (int i = 0; i < max; i++) { result += values[i] * values[i]; } return result; }
private void lookAhead() { lookAheadIndex++; while (lookAheadIndex < size() && values[lookAheadIndex] == 0.0) { lookAheadIndex++; } }
@Override public boolean hasNext() { return element.index + 1 < size(); }
@Override public Element next() { if (element.index + 1 >= size()) { // If the end is reached. throw new NoSuchElementException(); } element.index++; return element; }
@Override public boolean hasNext() { if (lookAheadIndex == index) { // User calls hasNext() after a next() lookAhead(); } // else user called hasNext() repeatedly. return lookAheadIndex < size(); }
@Override public DenseVector like() { return new DenseVector(size()); }
@Override public Element next() { if (lookAheadIndex == index) { // If user called next() without checking hasNext(). lookAhead(); } Preconditions.checkState(lookAheadIndex > index); index = lookAheadIndex; if (index >= size()) { // If the end is reached. throw new NoSuchElementException(); } element.index = index; return element; }
private void lookAhead() { lookAheadIndex++; while (lookAheadIndex < size() && values[lookAheadIndex] == 0.0) { lookAheadIndex++; } }
@Override protected double dotSelf() { double result = 0.0; int max = size(); for (int i = 0; i < max; i++) { result += values[i] * values[i]; } return result; }
@Override public Element next() { if (element.index + 1 >= size()) { // If the end is reached. throw new NoSuchElementException(); } element.index++; return element; }
@Override public boolean hasNext() { if (lookAheadIndex == index) { // User calls hasNext() after a next() lookAhead(); } // else user called hasNext() repeatedly. return lookAheadIndex < size(); }
@Override public DenseVector like() { return new DenseVector(size()); }
@Override public double dotSelf() { double result = 0.0; int max = size(); for (int i = 0; i < max; i++) { double value = this.getQuick(i); result += value * value; } return result; }
@Override protected Element computeNext() { if (element.index + 1 < size()) { element.index++; return element; } else { return endOfData(); } }