class SparseVector extends Vector {

    @Override
    public Vector plus(Vector vec) {
        if (this.size() != vec.size()) {
            throw new IllegalArgumentException("The size of the two vectors are different.");
        }

        if (vec instanceof DenseVector) {
            DenseVector r = ((DenseVector) vec).clone();
            for (int i = 0; i < this.indices.length; i++) {
                r.add(this.indices[i], this.values[i]);
            }
            return r;
        } else {
            return MatVecOp.apply(this, (SparseVector) vec, ((a, b) -> a + b));
        }
    }

    public  SparseVector();
    public  SparseVector(int n);
    public  SparseVector(int n, int[] indices, double[] values);
    public  SparseVector(int n, Map<Integer, Double> kv);

}