class SparseVector extends Vector {

    public DenseVector toDenseVector() {
        if (n >= 0) {
            DenseVector r = new DenseVector(n);
            for (int i = 0; i < this.indices.length; i++) {
                r.set(this.indices[i], this.values[i]);
            }
            return r;
        } else {
            if (this.indices.length == 0) {
                return new DenseVector();
            } else {
                int n = this.indices[this.indices.length - 1] + 1;
                DenseVector r = new DenseVector(n);
                for (int i = 0; i < this.indices.length; i++) {
                    r.set(this.indices[i], this.values[i]);
                }
                return r;
            }
        }
    }

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

}