-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inversa.cs
59 lines (49 loc) · 1.76 KB
/
Inversa.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
namespace MetodaGauss
{
public partial class Inversa : Form
{
public Inversa()
{
InitializeComponent();
}
private void buttonInversa_Click(object sender, EventArgs e)
{
string[] lines = input.Text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
int rows = lines.Length;
int cols = lines[0].Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Length;
double[,] matrix;
output.Text = "";
try
{
matrix = Functions.ReadMatrix(lines, rows, cols);
}
catch (FormatException ex)
{
MessageBox.Show(ex.Message, "Invalid Matrix Format", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
output.Text += Functions.PrintMatrix("Matricea introdusa:", matrix, rows, cols);
double[,] inverse = InverseFunctions.InverseMatrix(matrix, output);
if (inverse != null)
{
output.Text += Functions.PrintMatrix("Inversa matrici:", inverse, rows, cols);
}
else
{
MessageBox.Show("Matrix is singular and cannot be inverted.", "Result", MessageBoxButtons.OK);
}
}
private void input_TextChanged(object sender, EventArgs e)
{
}
private void output_TextChanged(object sender, EventArgs e)
{
}
private void buttonMeniu_Click(object sender, EventArgs e)
{
MainForm inversa_form = new MainForm();
this.Hide();
inversa_form.Show();
}
}
}