class SparseVector extends Vector {

    private double dot(SparseVector other) {
        if (this.size() != other.size()) {
            throw new RuntimeException("the size of the two vectors are different");
        }

        double d = 0;
        int p0 = 0;
        int p1 = 0;
        while (p0 < this.values.length && p1 < other.values.length) {
            if (this.indices[p0] == other.indices[p1]) {
                d += this.values[p0] * other.values[p1];
                p0++;
                p1++;
            } else if (this.indices[p0] < other.indices[p1]) {
                p0++;
            } else {
                p1++;
            }
        }
        return d;
    }

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

}