parameters: (covariance, points_sampled)
return_statement: return cov_mat
docstring: r"""Build ``A_{jik} = \pderiv{K_{ij}}{\theta_k}``.
  
      .. NOTE:: These comments are copied from BuildHyperparameterGradCovarianceMatrix() in gpp_model_selection.cpp.
  
      Build ``A_{jik} = \pderiv{K_{ij}}{\theta_k}``
      Hence the outer loop structure is identical to BuildCovarianceMatrix().
  
      Note the structure of the resulting tensor is ``num_hyperparameters`` blocks of size
      ``num_sampled X num_sampled``.  Consumers of this want ``dK/d\theta_k`` located sequentially.
      However, for a given pair of points (x, y), it is more efficient to compute all
      hyperparameter derivatives at once.  Thus the innermost loop writes to all
      ``num_hyperparameters`` blocks at once.
  
      Consumers of this result generally require complete storage (i.e., will not take advantage
      of its symmetry), so instead of ignoring the upper triangles, we copy them from the
      (already-computed) lower triangles to avoid redundant work.
  
      Since CovarianceInterface.HyperparameterGradCovariance() returns a vector of size ``|\theta_k|``,
      the inner loop writes all relevant entries of ``A_{jik}`` simultaneously to prevent recomputation.
  
      :param covariance: the covariance function encoding assumptions about the GP's behavior on our data
      :type covariance: interfaces.covariance_interface.CovarianceInterface subclass
      :param points_sampled: points, ``X_i``
      :type points_sampled: array of float64 with shape (points_sampled.shape[0], dim)
      :return: gradient of covariance matrix wrt hyperparameters
      :rtype: array of float64 with shape (points_sampled.shape[0], points_sampled.shape[0], num_hyperparameters), order='F'
  
      .. Note:: Fortran ordering is important here; scipy.linalg factor/solve methods
          (e.g., cholesky, solve_triangular) implicitly require order='F' to enable
          overwriting. This output is commonly overwritten.
docstring_summary: r"""Build ``A_{jik} = \pderiv{K_{ij}}{\theta_k}``.
docstring_tokens: r Build A_ { jik } = \ pderiv { K_ { ij }} { \ theta_k } .
function: def build_hyperparameter_grad_covariance_matrix(covariance, points_sampled):
      r"""Build ``A_{jik} = \pderiv{K_{ij}}{\theta_k}``.
  
      .. NOTE:: These comments are copied from BuildHyperparameterGradCovarianceMatrix() in gpp_model_selection.cpp.
  
      Build ``A_{jik} = \pderiv{K_{ij}}{\theta_k}``
      Hence the outer loop structure is identical to BuildCovarianceMatrix().
  
      Note the structure of the resulting tensor is ``num_hyperparameters`` blocks of size
      ``num_sampled X num_sampled``.  Consumers of this want ``dK/d\theta_k`` located sequentially.
      However, for a given pair of points (x, y), it is more efficient to compute all
      hyperparameter derivatives at once.  Thus the innermost loop writes to all
      ``num_hyperparameters`` blocks at once.
  
      Consumers of this result generally require complete storage (i.e., will not take advantage
      of its symmetry), so instead of ignoring the upper triangles, we copy them from the
      (already-computed) lower triangles to avoid redundant work.
  
      Since CovarianceInterface.HyperparameterGradCovariance() returns a vector of size ``|\theta_k|``,
      the inner loop writes all relevant entries of ``A_{jik}`` simultaneously to prevent recomputation.
  
      :param covariance: the covariance function encoding assumptions about the GP's behavior on our data
      :type covariance: interfaces.covariance_interface.CovarianceInterface subclass
      :param points_sampled: points, ``X_i``
      :type points_sampled: array of float64 with shape (points_sampled.shape[0], dim)
      :return: gradient of covariance matrix wrt hyperparameters
      :rtype: array of float64 with shape (points_sampled.shape[0], points_sampled.shape[0], num_hyperparameters), order='F'
  
      .. Note:: Fortran ordering is important here; scipy.linalg factor/solve methods
          (e.g., cholesky, solve_triangular) implicitly require order='F' to enable
          overwriting. This output is commonly overwritten.
  
      """
      cov_mat = numpy.empty((points_sampled.shape[0], points_sampled.shape[0], covariance.num_hyperparameters), order='F')
      for i, point_one in enumerate(points_sampled):
          for j, point_two in enumerate(points_sampled):
              cov_mat[j, i, ...] = covariance.hyperparameter_grad_covariance(point_one, point_two)
  
      return cov_mat
function_tokens: def build_hyperparameter_grad_covariance_matrix ( covariance , points_sampled ) : cov_mat = numpy . empty ( ( points_sampled . shape [ 0 ] , points_sampled . shape [ 0 ] , covariance . num_hyperparameters ) , order = 'F' ) for i , point_one in enumerate ( points_sampled ) : for j , point_two in enumerate ( points_sampled ) : cov_mat [ j , i , ... ] = covariance . hyperparameter_grad_covariance ( point_one , point_two ) return cov_mat