def METHOD_NAME(dim: int, axis: int) -> sp.csc_matrix:
    """Return a sparse matrix representation of first order difference operator.
    Parameters
    ----------
    dim : int
       The length of the matrix dimensions.
    axis : int
       The axis to take the difference along.
    Returns
    -------
    SciPy CSC matrix
        A square matrix representing first order difference.
    """
    # Construct a sparse matrix representation.
    val_arr = []
    row_arr = []
    col_arr = []
    for i in range(dim):
        val_arr.append(1.)
        row_arr.append(i)
        col_arr.append(i)
        if i > 0:
            val_arr.append(-1.)
            row_arr.append(i)
            col_arr.append(i-1)
    mat = sp.csc_matrix((val_arr, (row_arr, col_arr)),
                        (dim, dim))
    if axis == 0:
        return mat
    else:
        return mat.T