class Blas {

    public static void scal(Double a, Vector x) {
        if (x.isArrayBased())
            f2jBlas.dscal(x.size(), a, x.getStorage().data(), 1);
        else if (x instanceof SparseVector) {
            Set<Integer> indexes = ((SparseVector)x).indexes();

            for (Integer i : indexes)
                x.compute(i, (ind, v) -> v * a);
        }
        else
            throw new IllegalArgumentException();
    }

}