pyeeg.solvers.block_conjugate_gradient

pyeeg.solvers.block_conjugate_gradient(A, B, X0=None, tol=1e-10, max_iter=None, lambda_=0.0, verbose=False)

Block Conjugate Gradient: solve A X = B for multiple right-hand sides.

Solves all channels simultaneously using Frobenius inner products, eliminating the per-channel Python loop. Converges in a single set of iterations (governed by the hardest channel), but amortizes the matrix-matrix products A @ P across all channels.

Parameters:
  • A (ndarray (n, n)) – Symmetric positive-definite matrix.

  • B (ndarray (n, k)) – Right-hand sides (k channels).

  • X0 (ndarray (n, k), optional) – Initial guess. Defaults to zeros.

  • tol (float) – Convergence tolerance on the global residual norm.

  • max_iter (int, optional) – Maximum iterations. Defaults to n.

  • lambda (float) – Tikhonov regularization (added to A).

Returns:

X – Solution for all channels.

Return type:

ndarray (n, k)