First and foremost, I'm not a native english speaker (just to make that clear)
I have written a script for my numeric class in which i computed all necessary functions to pass my class. Now I want to implement everything into a GUI to make things easier.
For the whole testing I worked with a 'test' file to see what types the outputs are and so on. The file is called Numerik_Funktionen1 and is imported to every file im working on. Now here is the problem:
This is a class and function i've written:
class LR:
def LR_zerlegung(self, A, b = 0.):
'''
splits Matrix A in L and R
L = lower triangular matrix -> linke untere Dreiecksmatrix
R = upper triangular matrix -> rechte obere Dreiecksmatrix
returns (L, R) as tupel
'''
self.A = np.copy(A) * 1.
self.ALr = A * 1.
self.n = len(self.A[0])
self.b = b
self.L = np.eye(self.n)
for k in range(self.n-1):
for i in range(self.n)[k+1:self.n]:
self.L[i, k] = self.ALr[i, k] / self.ALr[k, k]
self.ALr[i, k] = 0
for j in range(self.n)[k+1:self.n]:
self.ALr[i, j] = self.ALr[i, j] - self.L[i, k] * self.ALr[k, j]
self.R = self.ALr
print('Ax = b')
print('A', '\n', self.A,"\n")
print('b', '\n', self.b,"\n")
print('L', '\n', self.L,"\n")
print('R', '\n', self.R,"\n")
return self.L, self.R
The problem I run into is best described with code (I now it's neither well written nor good looking code, sorry)
import Numerik_Funktionen1
a = input("a eingeben: ")
b = input("b eingeben: ")
array_from_string = [s.split(',') for s in a.split(';')]
array_from_string2 = [s.split(',') for s in b.split(';')]
c = np.asarray(array_from_string)
d = np.asarray(array_from_string2)
A = c.astype(int)
b = d.astype(int)
The input for a looks like this: 2,3;5,4 and for b 2;4
After the proceeding A is an array
(array([[2, 3],
[5, 4]])
)
and b as well (array([[2],
[2]])
)
The call of the function looks like this: Numerik_Funktionen1.LR.LR_zerlegung(A, b)
So far so good, but if I want to take the previously described function LR_zerlegung, it returns this: 'numpy.ndarray' object has no attribute 'A'
I don't know what I do wrong and why it won't correspond with the Numerik_Funktionen1. I know my question in not well formulated and im sorry for that in advance.
Thank you