/** * Bring each element to the power d * * @param degree * @param d * @return the input */ public static <T extends Vector> T powInplace(T degree, double d) { for (final VectorEntry ent : degree) { degree.setElement(ent.getIndex(), Math.pow(ent.getValue(), d)); } return degree; }
@Override public void forEachEntry( final IndexValueConsumer consumer) { // Default implementation uses an iterator. However, specialized // sub-classes can add optimizations. for (final VectorEntry entry : this) { consumer.consume(entry.getIndex(), entry.getValue()); } }
@Override public void forEachEntry( final IndexValueConsumer consumer) { // Default implementation uses an iterator. However, specialized // sub-classes can add optimizations. for (final VectorEntry entry : this) { consumer.consume(entry.getIndex(), entry.getValue()); } }
@Override public void forEachEntry( final IndexValueConsumer consumer) { // Default implementation uses an iterator. However, specialized // sub-classes can add optimizations. for (final VectorEntry entry : this) { consumer.consume(entry.getIndex(), entry.getValue()); } }
@Override public void dotTimesEquals( final Vector other) { for (final VectorEntry entry : this) { entry.setValue( entry.getValue() * other.getElement(entry.getIndex()) ); } }
@Override public void dotTimesEquals( final Vector other) { for (final VectorEntry entry : this) { entry.setValue( entry.getValue() * other.getElement(entry.getIndex()) ); } }
@Override public void minusEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.decrement(entry.getIndex(), entry.getValue()); } }
@Override public void dotTimesEquals( final Vector other) { for (final VectorEntry entry : this) { entry.setValue( entry.getValue() * other.getElement(entry.getIndex()) ); } }
@Override public void plusEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.increment(entry.getIndex(), entry.getValue()); } }
@Override public void plusEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.increment(entry.getIndex(), entry.getValue()); } }
@Override public void minusEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.decrement(entry.getIndex(), entry.getValue()); } }
@Override public void plusEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.increment(entry.getIndex(), entry.getValue()); } }
@Override public void scaledPlusEquals( final double scaleFactor, final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.increment(entry.getIndex(), scaleFactor * entry.getValue()); } }
@Override public void minusEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : other) { this.decrement(entry.getIndex(), entry.getValue()); } }
@Override public void dotTimesEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : this) { entry.setValue(entry.getValue() * other.get(entry.getIndex())); } }
@Override public void dotTimesEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : this) { entry.setValue(entry.getValue() * other.get(entry.getIndex())); } }
@Override public void dotTimesEquals( final Vector other) { // This is a generic implementation to support interoperability. // Sub-classes should make custom ones for performance. this.assertSameDimensionality(other); for (final VectorEntry entry : this) { entry.setValue(entry.getValue() * other.get(entry.getIndex())); } }