@Override
    public double dot(SGDVector other) {
        if (other.size() != elements.length) {
            throw new IllegalArgumentException("Can't dot two vectors of different dimension, this = " + elements.length + ", other = " + other.size());
        }
        double score = 0.0;
        if (other instanceof DenseVector) {
            for (int i = 0; i < elements.length; i++) {
                score += get(i) * other.get(i);
            }
        } else {
            // else must be sparse
            for (VectorTuple tuple : other) {
                score += get(tuple.index) * tuple.value;
            }
        }
        return score;
    }
@Test
    public void overlappingDot() {
        DenseVector a = generateVectorA();
        DenseVector b = generateVectorB();

        assertEquals(a.dot(b), b.dot(a), 1e-10);
        assertEquals(-15.0, a.dot(b), 1e-10);
    }