'Converts elementwise gradient into a diagonal matrix for Atom._grad()
Args:
value: A scalar or NumPy matrix.
Returns:
A SciPy CSC sparse matrix.'

@staticmethod
def elemwise_grad_to_diag(value, rows, cols):

    if (not np.isscalar(value)):
        value = value.A.ravel(order='F')
    return sp.dia_matrix((value, [0]), shape=(rows, cols)).tocsc()
