Merge branch 'main' of https://gitea.lionarius.ru/lionarius/computational-math
This commit is contained in:
@@ -29,3 +29,8 @@
|
||||
22 -9 -3 2 300 0 -8 -21
|
||||
-5 -3 15 3 15 4 16 -1
|
||||
0 -2 -11 -2 -2 10 -150 -6
|
||||
|
||||
# task
|
||||
8 -4 -1 33
|
||||
-18 15 6 -30
|
||||
0 7 -2 58
|
||||
|
||||
@@ -207,6 +207,8 @@ class MainWindow(QMainWindow):
|
||||
matrix_a: np.matrix
|
||||
matrix_b: np.matrix
|
||||
|
||||
eps_input: InputField
|
||||
n_input: InputField
|
||||
det_display: DisplayField
|
||||
cond_display: DisplayField
|
||||
|
||||
@@ -230,9 +232,19 @@ class MainWindow(QMainWindow):
|
||||
label1 = QLabel("Вариант 6", self)
|
||||
layout.addWidget(label1)
|
||||
|
||||
inputs_row = QWidget()
|
||||
inputs_row_layout = QHBoxLayout()
|
||||
|
||||
self.n_input = InputField(self, " n: ", "число строк", str(4), "left")
|
||||
self.n_input.on_change(lambda w: self.on_n_input_changed(w))
|
||||
layout.addWidget(self.n_input)
|
||||
inputs_row_layout.addWidget(self.n_input)
|
||||
|
||||
self.eps_input = InputField(self, " eps: ", "точность", str(0.001), "left")
|
||||
self.eps_input.on_change(lambda w: self.on_eps_input_changed(w))
|
||||
inputs_row_layout.addWidget(self.eps_input)
|
||||
|
||||
inputs_row.setLayout(inputs_row_layout)
|
||||
layout.addWidget(inputs_row)
|
||||
|
||||
buttons_row = QWidget()
|
||||
buttons_row_layout = QHBoxLayout()
|
||||
@@ -274,6 +286,17 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.central_widget.setLayout(layout)
|
||||
|
||||
def on_eps_input_changed(self, widget: InputField):
|
||||
on_input_float_number(widget)
|
||||
|
||||
eps = widget.get_value()
|
||||
try:
|
||||
if float(eps) < 0:
|
||||
eps = 0
|
||||
self.eps_input.set_value(eps)
|
||||
except:
|
||||
return
|
||||
|
||||
def on_random_button_clicked(self):
|
||||
n = int(self.n_input.get_value())
|
||||
self.matrix_a = np.round(np.random.rand(n, n) * 10, 2)
|
||||
@@ -287,7 +310,11 @@ class MainWindow(QMainWindow):
|
||||
except:
|
||||
print("Numpy could not solve the system")
|
||||
|
||||
x = solution.iterative_method(self.matrix_a, self.matrix_b)
|
||||
try:
|
||||
eps = float(self.eps_input.get_value())
|
||||
except:
|
||||
eps = 0
|
||||
x = solution.iterative_method(self.matrix_a, self.matrix_b, eps)
|
||||
print(f"Iterative solution: {x}")
|
||||
|
||||
if x is None:
|
||||
@@ -346,6 +373,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def on_reset_button_clicked(self):
|
||||
self.n_input.set_value(str(4))
|
||||
self.eps_input.set_value(str(0.001))
|
||||
self.set_matrix(task.A(), task.B())
|
||||
|
||||
def on_matrix_changed(self, widget: InputField):
|
||||
|
||||
Reference in New Issue
Block a user