class MatVecOp {

    public static double sumAbsDiff(Vector vec1, Vector vec2) {
        if (vec1 instanceof DenseVector) {
            if (vec2 instanceof DenseVector) {
                return MatVecOp.applySum((DenseVector)vec1, (DenseVector)vec2, (a, b) -> Math.abs(a - b));
            } else {
                return MatVecOp.applySum((DenseVector)vec1, (SparseVector)vec2, (a, b) -> Math.abs(a - b));
            }
        } else {
            if (vec2 instanceof DenseVector) {
                return MatVecOp.applySum((SparseVector)vec1, (DenseVector)vec2, (a, b) -> Math.abs(a - b));
            } else {
                return MatVecOp.applySum((SparseVector)vec1, (SparseVector)vec2, (a, b) -> Math.abs(a - b));
            }
        }
    }

}