Coverage for gpaw/test/linalg/test_gemm_complex.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-20 00:19 +0000

1# for n > 4 (?) 

2# when run with gpaw-python built with MKL matrices b and c have ~zero elements 

3# running with python (uses cgpaw.so) gives right (non-zero) results! 

4 

5import numpy as np 

6from gpaw.utilities.blas import mmm 

7 

8 

9def test_linalg_gemm_complex(): 

10 n = 5 # works for n = 4 

11 a1 = np.eye(n) + 1.j 

12 a2 = a1 + 1.j 

13 

14 b = np.zeros((n, n), dtype=complex) 

15 

16 c = np.dot(a2, a1) 

17 

18 mmm(1.0, a2, 'N', a1, 'N', 0.0, b) 

19 

20 thresh = 1.0e-7 

21 ref_max_value = -9.0 

22 

23 # print b 

24 # print c 

25 numpy_dot = np.max(b).real 

26 gpaw_gemm = np.max(c).real 

27 # print gpaw_gemm 

28 assert abs(gpaw_gemm - numpy_dot) < thresh, (gpaw_gemm, numpy_dot, thresh) 

29 assert abs(gpaw_gemm - ref_max_value) < thresh, (gpaw_gemm, 

30 ref_max_value, thresh)