Skip to content

Commit f519ac5

Browse files
committed
Merge branch 'MindTraper-master'
2 parents 1da1e20 + af3d867 commit f519ac5

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed
File renamed without changes.
File renamed without changes.

Diff for: ArithmeticAnalysis/LUdecomposition.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import math
2+
import numpy
3+
4+
def LUDecompose (table): #table that contains our data
5+
#table has to be a square array so we need to check first
6+
rows,columns=numpy.shape(table)
7+
L=numpy.zeros((rows,columns))
8+
U=numpy.zeros((rows,columns))
9+
if rows!=columns:
10+
return
11+
for i in range (columns):
12+
for j in range(i-1):
13+
sum=0
14+
for k in range (j-1):
15+
sum+=L[i][k]*U[k][j]
16+
L[i][j]=(table[i][j]-sum)/U[j][j]
17+
L[i][i]=1
18+
for j in range(i-1,columns):
19+
sum1=0
20+
for k in range(i-1):
21+
sum1+=L[i][k]*U[k][j]
22+
U[i][j]=table[i][j]-sum1
23+
return L,U
24+
25+
26+
27+
28+
29+
30+
31+
matrix =numpy.array([[2,-2,1],[0,1,2],[5,3,1]])
32+
L,U = LUDecompose(matrix)
33+
print(L)
34+
print(U)
File renamed without changes.

0 commit comments

Comments
 (0)