Coverage for src/nncg/__init__.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-15 07:01 +0000

1"""Non-negative conjugate gradients. 

2 

3Solves the strictly convex non-negative quadratic program 

4``min_{x >= 0} 1/2 x^T A x - b^T x`` (and its equality-augmented variant 

5``B x = c``) by wrapping matrix-free conjugate gradients in a primal-dual 

6active-set loop with an unconditional finite-termination guarantee — no 

7non-degeneracy assumption. 

8 

9Reference implementation of the paper "Non-Negative Conjugate Gradients" 

10(Schmelzer & Stoll), whose numerical study doubles as this package's test 

11suite: https://github.com/Jebel-Quant/mean_variance_solvers. 

12""" 

13 

14import importlib.metadata 

15 

16from .api import InnerKind, solve_nnqp, solve_nnqp_eq, solve_nnqp_mprgp 

17from .certificate import kkt_violation 

18from .inner import CG, Exact, GlobalNystrom, Jacobi, Nystrom, NystromConfig 

19from .krylov import KrylovConfig 

20from .mprgp import MPRGP, MPRGPConfig, MPRGPResult 

21from .solver import ActiveSetConfig, ActiveSetSolver, InnerSolver, Result 

22 

23__all__ = [ 

24 "CG", 

25 "MPRGP", 

26 "ActiveSetConfig", 

27 "ActiveSetSolver", 

28 "Exact", 

29 "GlobalNystrom", 

30 "InnerKind", 

31 "InnerSolver", 

32 "Jacobi", 

33 "KrylovConfig", 

34 "MPRGPConfig", 

35 "MPRGPResult", 

36 "Nystrom", 

37 "NystromConfig", 

38 "Result", 

39 "kkt_violation", 

40 "solve_nnqp", 

41 "solve_nnqp_eq", 

42 "solve_nnqp_mprgp", 

43] 

44 

45try: 

46 __version__ = importlib.metadata.version("nncg") 

47except importlib.metadata.PackageNotFoundError: 

48 # Package metadata not available (development/editable install) 

49 __version__ = "0.0.0"