@@ -1038,7 +1038,7 @@ pure subroutine math_eigh33(w,v,m)
1038
1038
1039
1039
T = maxval (abs (w))
1040
1040
U = max (T, T** 2 )
1041
- threshold = sqrt (5.68e-14_pREAL * U** 2 )
1041
+ threshold = max ( sqrt (5.68e-14_pREAL * U** 2 ),PREAL_MIN )
1042
1042
1043
1043
v(1 :3 ,1 ) = [m(1 ,3 )* w(1 ) + v(1 ,2 ), &
1044
1044
m(2 ,3 )* w(1 ) + v(2 ,2 ), &
@@ -1468,6 +1468,23 @@ subroutine math_selfTest()
1468
1468
error stop ' math_normal(sigma)'
1469
1469
end block normal_distribution
1470
1470
1471
+ t33 = 0.0_pREAL
1472
+ call math_eigh33(v3_1,t33_2,t33)
1473
+ if (any (dNeq0(v3_1))) error stop ' math_eigh33/zero eigenvalues (values)'
1474
+ if (any (dNeq(t33_2,math_I3))) error stop ' math_eigh33/zero eigenvalues (vectors)'
1475
+
1476
+ t33 = math_I3
1477
+ call random_number (r)
1478
+ d = nint (r* 2.0_pREAL ) + 1
1479
+ t33(d,d) = 5.0_pREAL + r* 10.0_pREAL
1480
+ t33(mod (d,3 )+ 1 ,mod (d,3 )+ 1 ) = 20.0_pREAL + r* 10.0_pREAL
1481
+ call math_eigh33(v3_1,t33_2,t33)
1482
+ if (any (dNeq(v3_1,[1.0_pREAL ,t33(d,d),t33(mod (d,3 )+ 1 ,mod (d,3 )+ 1 )]))) &
1483
+ error stop ' math_eigh33/non-zero eigenvalues (values)'
1484
+ if (any (dNeq(math_I3(1 :3 ,mod (d+1 ,3 )+ 1 ),t33_2(1 :3 ,1 )))) error stop ' math_eigh33/min eigenvector'
1485
+ if (any (dNeq(math_I3(1 :3 ,d ),t33_2(1 :3 ,2 )))) error stop ' math_eigh33/mid eigenvector'
1486
+ if (any (dNeq(math_I3(1 :3 ,mod (d,3 )+ 1 ),t33_2(1 :3 ,3 )))) error stop ' math_eigh33/max eigenvector'
1487
+
1471
1488
end subroutine math_selfTest
1472
1489
1473
1490
end module math
0 commit comments