@Override public final void dotTimesEquals( final DenseVector other) { this.assertSameDimensionality(other); compress(); for (int i = 0; i < values.length; ++i) { values[i] *= other.values[indices[i]]; } }
@Override public final double dotProduct( final DenseVector other) { this.assertSameDimensionality(other); compress(); double result = 0; for (int i = 0; i < indices.length; ++i) { result += values[i] * other.values[indices[i]]; } return result; }
@Override public final void dotTimesEquals( final DenseVector other) { this.assertSameDimensionality(other); compress(); for (int i = 0; i < values.length; ++i) { values[i] *= other.values[indices[i]]; } }
@Override public final double dotProduct( final DenseVector other) { this.assertSameDimensionality(other); compress(); double result = 0; for (int i = 0; i < indices.length; ++i) { result += values[i] * other.values[indices[i]]; } return result; }
@Override public final void dotTimesEquals( final DenseVector other) { this.assertSameDimensionality(other); compress(); for (int i = 0; i < values.length; ++i) { values[i] *= other.values[indices[i]]; } }
@Override public final double dotProduct( final DenseVector other) { this.assertSameDimensionality(other); compress(); double result = 0; for (int i = 0; i < indices.length; ++i) { result += values[i] * other.values[indices[i]]; } return result; }
@Override public final double euclideanDistanceSquared( final DenseVector other) { this.assertSameDimensionality(other); compress(); double dist = 0; int idx = 0; for (int i = 0; i < dimensionality; ++i) { double tmp = other.values[i]; if ((idx < indices.length) && (indices[idx] == i)) { tmp -= values[idx]; ++idx; } dist += tmp * tmp; } return dist; }
@Override public final double euclideanDistanceSquared( final DenseVector other) { this.assertSameDimensionality(other); compress(); double dist = 0; int idx = 0; for (int i = 0; i < dimensionality; ++i) { double tmp = other.values[i]; if ((idx < indices.length) && (indices[idx] == i)) { tmp -= values[idx]; ++idx; } dist += tmp * tmp; } return dist; }
@Override public final double euclideanDistanceSquared( final DenseVector other) { this.assertSameDimensionality(other); compress(); double dist = 0; int idx = 0; for (int i = 0; i < dimensionality; ++i) { double tmp = other.values[i]; if ((idx < indices.length) && (indices[idx] == i)) { tmp -= values[idx]; ++idx; } dist += tmp * tmp; } return dist; }
final double scaleFactor) this.assertSameDimensionality(other); compress();
final double scaleFactor) this.assertSameDimensionality(other); compress();
final double scaleFactor) this.assertSameDimensionality(other); compress();
@Override public final double dotProduct( final SparseVector other) { this.assertSameDimensionality(other); compress(); other.compress(); double result = 0; int otheridx = 0; final int thisLength = this.indices.length; final int otherLength = other.indices.length; for (int i = 0; i < thisLength && otheridx < otherLength; ++i) { while (other.indices[otheridx] < indices[i]) { ++otheridx; if (otheridx >= otherLength) { return result; } } if (other.indices[otheridx] == indices[i]) { result += values[i] * other.values[otheridx]; ++otheridx; } } return result; }
@Override public final double dotProduct( final SparseVector other) { this.assertSameDimensionality(other); compress(); other.compress(); double result = 0; int otheridx = 0; final int thisLength = this.indices.length; final int otherLength = other.indices.length; for (int i = 0; i < thisLength && otheridx < otherLength; ++i) { while (other.indices[otheridx] < indices[i]) { ++otheridx; if (otheridx >= otherLength) { return result; } } if (other.indices[otheridx] == indices[i]) { result += values[i] * other.values[otheridx]; ++otheridx; } } return result; }
@Override public final double dotProduct( final SparseVector other) { this.assertSameDimensionality(other); compress(); other.compress(); double result = 0; int otheridx = 0; final int thisLength = this.indices.length; final int otherLength = other.indices.length; for (int i = 0; i < thisLength && otheridx < otherLength; ++i) { while (other.indices[otheridx] < indices[i]) { ++otheridx; if (otheridx >= otherLength) { return result; } } if (other.indices[otheridx] == indices[i]) { result += values[i] * other.values[otheridx]; ++otheridx; } } return result; }
final SparseVector other) this.assertSameDimensionality(other); compress(); other.compress();
final double scaleFactor) this.assertSameDimensionality(other); compress();
@Override public final void dotTimesEquals( final SparseVector other) { this.assertSameDimensionality(other); compress(); other.compress(); int nnz = numNonZeroAfterOp(other, SparseMatrix.Combiner.AND); double[] valsAfter = new double[nnz]; int[] locsAfter = new int[nnz]; int outidx = 0; int otheridx = 0; for (int i = 0; i < values.length; ++i) { while (other.indices[otheridx] < indices[i]) { ++otheridx; } if (other.indices[otheridx] == indices[i]) { valsAfter[outidx] = values[i] * other.values[otheridx]; locsAfter[outidx] = indices[i]; ++outidx; ++otheridx; } } values = valsAfter; indices = locsAfter; }
@Override public final void dotTimesEquals( final SparseVector other) { this.assertSameDimensionality(other); compress(); other.compress(); int nnz = numNonZeroAfterOp(other, SparseMatrix.Combiner.AND); double[] valsAfter = new double[nnz]; int[] locsAfter = new int[nnz]; int outidx = 0; int otheridx = 0; for (int i = 0; i < values.length; ++i) { while (other.indices[otheridx] < indices[i]) { ++otheridx; } if (other.indices[otheridx] == indices[i]) { valsAfter[outidx] = values[i] * other.values[otheridx]; locsAfter[outidx] = indices[i]; ++outidx; ++otheridx; } } values = valsAfter; indices = locsAfter; }
@Override public final void dotTimesEquals( final SparseVector other) { this.assertSameDimensionality(other); compress(); other.compress(); int nnz = numNonZeroAfterOp(other, SparseMatrix.Combiner.AND); double[] valsAfter = new double[nnz]; int[] locsAfter = new int[nnz]; int outidx = 0; int otheridx = 0; for (int i = 0; i < values.length; ++i) { while (other.indices[otheridx] < indices[i]) { ++otheridx; } if (other.indices[otheridx] == indices[i]) { valsAfter[outidx] = values[i] * other.values[otheridx]; locsAfter[outidx] = indices[i]; ++outidx; ++otheridx; } } values = valsAfter; indices = locsAfter; }