def right_multiply(J, d, copy=True):
    if copy and not isinstance(J, LinearOperator):
        J = J.copy()

    if issparse(J):
        J.data *= d.take(J.indices, mode='clip')  # scikit-learn recipe.
    elif isinstance(J, LinearOperator):
        J = right_multiplied_operator(J, d)
    else:
        J *= d

    return J
Compute J diag(d).
dataset/ETHPy150Open scipy/scipy/scipy/optimize/_lsq/common.py/right_multiply