File tree Expand file tree Collapse file tree 3 files changed +123
-0
lines changed Expand file tree Collapse file tree 3 files changed +123
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ #######################################################
3+ # Copyright (c) 2024, ArrayFire
4+ # All rights reserved.
5+ #
6+ # This file is distributed under 3-clause BSD license.
7+ # The complete license agreement can be obtained at:
8+ # http://arrayfire.com/licenses/BSD-3-Clause
9+ ########################################################
10+
11+ import arrayfire as af
12+
13+
14+ def main ():
15+ try :
16+ af .info ()
17+
18+ n = 5
19+ t = af .randu ((n , n ))
20+ arr_in = af .matmul (t , t , rhs_opts = af .MatProp .TRANS ) + af .identity ((n , n )) * n
21+
22+ print ("Running Cholesky InPlace\n " )
23+ cin_upper = arr_in .copy ()
24+ cin_lower = arr_in .copy ()
25+
26+ af .cholesky (cin_upper , True )
27+ af .cholesky (cin_lower , False )
28+
29+ print (cin_upper )
30+ print (cin_lower )
31+
32+ print ("\n Running Cholesky Out of place\n " )
33+
34+ out_upper , upper_success = af .cholesky (arr_in , True )
35+ out_lower , lower_success = af .cholesky (arr_in , False )
36+
37+ if upper_success == 0 :
38+ print (out_upper )
39+ if lower_success == 0 :
40+ print (out_lower )
41+
42+ except Exception as e :
43+ print ("Error: " , str (e ))
44+
45+
46+ if __name__ == "__main__" :
47+ main ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ #######################################################
3+ # Copyright (c) 2024, ArrayFire
4+ # All rights reserved.
5+ #
6+ # This file is distributed under 3-clause BSD license.
7+ # The complete license agreement can be obtained at:
8+ # http://arrayfire.com/licenses/BSD-3-Clause
9+ ########################################################
10+
11+ import arrayfire as af
12+
13+
14+ def main ():
15+ try :
16+ af .info ()
17+
18+ in_array = af .randu ((5 , 8 ))
19+
20+ print ("Running LU InPlace\n " )
21+ pivot = af .lu (in_array , inplace = True )
22+ print (in_array )
23+ print (pivot )
24+
25+ print ("Running LU with Upper Lower Factorization\n " )
26+ lower , upper , pivot = af .lu (in_array )
27+ print (lower )
28+ print (upper )
29+ print (pivot )
30+
31+ except Exception as e :
32+ print ("Error: " , str (e ))
33+
34+
35+ if __name__ == "__main__" :
36+ main ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ #######################################################
3+ # Copyright (c) 2024, ArrayFire
4+ # All rights reserved.
5+ #
6+ # This file is distributed under 3-clause BSD license.
7+ # The complete license agreement can be obtained at:
8+ # http://arrayfire.com/licenses/BSD-3-Clause
9+ ########################################################
10+
11+ import arrayfire as af
12+
13+
14+ def main ():
15+ try :
16+ af .info ()
17+ in_array = af .randu ((5 , 8 ))
18+
19+ print ("Running QR InPlace\n " )
20+ q_in = in_array .copy ()
21+ print (q_in )
22+
23+ tau = af .qr (q_in , inplace = True )
24+
25+ print (q_in )
26+ print (tau )
27+
28+ print ("Running QR with Q and R factorization\n " )
29+ q , r , tau = af .qr (in_array )
30+
31+ print (q )
32+ print (r )
33+ print (tau )
34+
35+ except Exception as e :
36+ print ("Error: " , str (e ))
37+
38+
39+ if __name__ == "__main__" :
40+ main ()
You can’t perform that action at this time.
0 commit comments