class_docstr: Linear operator for the L-BFGS approximate inverse Hessian.
  
  This operator computes the product of a vector with the approximate inverse
  of the Hessian of the objective function, using the L-BFGS limited
  memory approximation to the inverse Hessian, accumulated during the
  optimization.
  
  Objects of this class implement the ``scipy.sparse.linalg.LinearOperator``
  interface.
  
  Parameters
  ----------
  sk : array_like, shape=(n_corr, n)
      Array of `n_corr` most recent updates to the solution vector.
      (See [1]).
  yk : array_like, shape=(n_corr, n)
      Array of `n_corr` most recent updates to the gradient. (See [1]).
  
  References
  ----------
  .. [1] Nocedal, Jorge. "Updating quasi-Newton matrices with limited
     storage." Mathematics of computation 35.151 (1980): 773-782.
class_docstr_tok: ["Linear","operator","for","the","L-BFGS","approximate","inverse","Hessian",".","This","operator","computes","the","product","of","a","vector","with","the","approximate","inverse","of","the","Hessian","of","the","objective","function",",","using","the","L-BFGS","limited","memory","approximation","to","the","inverse","Hessian",",","accumulated","during","the","optimization",".","Objects","of","this","class","implement","the","``","scipy.sparse.linalg.LinearOperator","``","interface",".","Parameters","--","--","--","--","--","sk",":","array_like",",","shape=","(","n_corr",",","n",")","Array","of","`","n_corr","`","most","recent","updates","to","the","solution","vector",".","(","See","[","1","]",")",".","yk",":","array_like",",","shape=","(","n_corr",",","n",")","Array","of","`","n_corr","`","most","recent","updates","to","the","gradient",".","(","See","[","1","]",")",".","References","--","--","--","--","--","..","[","1","]","Nocedal",",","Jorge",".","``","Updating","quasi-Newton","matrices","with","limited","storage",".","''","Mathematics","of","computation","35.151","(","1980",")",":","773-782","."]
docstr: Efficient matrix-vector multiply with the BFGS matrices.
  
  This calculation is described in Section (4) of [1].
  
  Parameters
  ----------
  x : ndarray
      An array with shape (n,) or (n,1).
  
  Returns
  -------
  y : ndarray
      The matrix-vector product
docstr_tok: ["Efficient","matrix-vector","multiply","with","the","BFGS","matrices",".","This","calculation","is","described","in","Section","(","4",")","of","[","1","]",".","Parameters","--","--","--","--","--","x",":","ndarray","An","array","with","shape","(","n",",",")","or","(","n,1",")",".","Returns","--","--","--","-","y",":","ndarray","The","matrix-vector","product"]
code: def _matvec(self, x):
      """Efficient matrix-vector multiply with the BFGS matrices.
  
      This calculation is described in Section (4) of [1].
  
      Parameters
      ----------
      x : ndarray
          An array with shape (n,) or (n,1).
  
      Returns
      -------
      y : ndarray
          The matrix-vector product
  
      """
      s, y, n_corrs, rho = self.sk, self.yk, self.n_corrs, self.rho
      q = np.array(x, dtype=self.dtype, copy=True)
      if q.ndim == 2 and q.shape[1] == 1:
          q = q.reshape(-1)
  
      alpha = np.empty(n_corrs)
  
      for i in range(n_corrs - 1, -1, -1):
          alpha[i] = rho[i] * np.dot(s[i], q)
          q = q - alpha[i] * y[i]
  
      r = q
      for i in range(n_corrs):
          beta = rho[i] * np.dot(y[i], r)
          r = r + s[i] * (alpha[i] - beta)
  
      return r
  
file_path: catboost/contrib/python/scipy/py3/scipy/optimize/lbfgsb.py
imports: import numpy
  from numpy import array, asarray, float64, zeros
  from .None import _lbfgsb
  from .optimize import MemoizeJac, OptimizeResult, _check_unknown_options, _prepare_scalar_function
  from ._constraints import old_bound_to_new
  from scipy.sparse.linalg import LinearOperator
label_desc: Use image node_id 2 for calling the LbfgsInvHessProduct obj's underlying member method code with example usage: obj._matvec(x) and returns: r