@@ -1885,6 +1885,16 @@ def _apply_pivots_rows(A_dp, piv_dp):
18851885 rows = dpnp .asarray (rows )
18861886 return A_dp [rows ]
18871887
1888+ @staticmethod
1889+ def _make_nonsingular_np (shape , dtype , order ):
1890+ A = generate_random_numpy_array (shape , dtype , order )
1891+ m , n = shape
1892+ k = min (m , n )
1893+ for i in range (k ):
1894+ off = numpy .sum (numpy .abs (A [i , :n ])) - numpy .abs (A [i , i ])
1895+ A [i , i ] = A .dtype .type (off + 1.0 )
1896+ return A
1897+
18881898 @staticmethod
18891899 def _split_lu (lu , m , n ):
18901900 L = dpnp .tril (lu , k = - 1 )
@@ -1899,7 +1909,7 @@ def _split_lu(lu, m, n):
18991909 @pytest .mark .parametrize ("order" , ["C" , "F" ])
19001910 @pytest .mark .parametrize ("dtype" , get_all_dtypes (no_bool = True ))
19011911 def test_lu_factor (self , shape , order , dtype ):
1902- a_np = generate_random_numpy_array (shape , dtype , order )
1912+ a_np = self . _make_nonsingular_np (shape , dtype , order )
19031913 a_dp = dpnp .array (a_np , order = order )
19041914
19051915 lu , piv = dpnp .linalg .lu_factor (
@@ -2001,12 +2011,7 @@ def test_empty_inputs(self, shape):
20012011 ],
20022012 )
20032013 def test_strided (self , sl ):
2004- base = (
2005- numpy .arange (7 * 7 , dtype = dpnp .default_float_type ()).reshape (
2006- 7 , 7 , order = "F"
2007- )
2008- + 0.1
2009- )
2014+ base = self ._make_nonsingular_np ((7 , 7 ), dpnp .default_float_type (), "F" )
20102015 a_np = base [sl ]
20112016 a_dp = dpnp .array (a_np )
20122017
0 commit comments