public Vector add(Vector y) { return add(1, y); }
public double norm(Norm type) { if (type == Norm.One) return norm1(); else if (type == Norm.Two) return norm2(); else if (type == Norm.TwoRobust) return norm2_robust(); else // Infinity return normInf(); }
public void set(double value) { AbstractVector.this.set(index, value); }
@Override public double dot(Vector y) { if (!(y instanceof DenseVector)) return super.dot(y); checkSize(y); double[] yd = ((DenseVector) y).getData(); double dot = 0.; for (int i = 0; i < size; ++i) dot += data[i] * yd[i]; return dot; }
public double dot(Vector y) { checkSize(y); double ret = 0; for (VectorEntry e : this) ret += e.get() * y.get(e.index()); return ret; }
public Vector scale(double alpha) { if (alpha == 0) return zero(); else if (alpha == 1) return this; for (VectorEntry e : this) e.set(alpha * e.get()); return this; }
public double get() { return AbstractVector.this.get(index); }
public double norm(Norm type) { if (type == Norm.One) return norm1(); else if (type == Norm.Two) return norm2(); else if (type == Norm.TwoRobust) return norm2_robust(); else // Infinity return normInf(); }
public void set(double value) { AbstractVector.this.set(index, value); }
@Override public double dot(Vector y) { if (!(y instanceof DenseVector)) return super.dot(y); checkSize(y); double[] yd = ((DenseVector) y).getData(); double ret = 0; for (int i = 0; i < used; ++i) ret += data[i] * yd[index[i]]; return ret; }
public double dot(Vector y) { checkSize(y); double ret = 0; for (VectorEntry e : this) ret += e.get() * y.get(e.index()); return ret; }
public Vector scale(double alpha) { if (alpha == 0) return zero(); else if (alpha == 1) return this; for (VectorEntry e : this) e.set(alpha * e.get()); return this; }
public double get() { return AbstractVector.this.get(index); }
public Vector set(Vector y) { return set(1, y); }