private void _btnCalc_Click(object sender, EventArgs e) { IMatrix matrix = new MathnetMatrixSolver(); Stopwatch stopwatch = new Stopwatch(); string formulaA = _tbAformula.Text, formulaB = _tbBformula.Text; int columnA = Convert.ToInt32(_tbAcolumn.Text), rowA = Convert.ToInt32(_tbArow.Text); int columnB = Convert.ToInt32(_tbBcolumn.Text), rowB = Convert.ToInt32(_tbBrow.Text); bool sparse = _chbSparseA.Checked && _chbSparseB.Checked; int opp = _cmbbOpperation.SelectedIndex; Cursor.Current = Cursors.WaitCursor; stopwatch.Start(); double[,] m = matrix.ParsedSolve(formulaA, formulaB, columnA, rowA, columnB, rowB, sparse, opp); stopwatch.Stop(); _rtbDialog.Text = "Время вычисления: " + stopwatch.ElapsedMilliseconds.ToString() + "милисекунд\n"; for (int i = 0; i < 5 && i < m.GetLength(0); i++) { for (int j = 0; j < 5 && j < m.GetLength(1); j++) { _rtbDialog.Text += m[i, j] + " "; } _rtbDialog.Text += "\n"; } Cursor.Current = Cursors.Default; }
public void TestLargeMultiply() { IMatrix matrix = new MathnetMatrixSolver(); string formulaA = "1", formulaB = "x+y"; int columnA = 100, rowA = 100; int columnB = 100, rowB = 100; bool sparse = false; int opp = 0; bool testComplete = true; double[,] m = matrix.ParsedSolve(formulaA, formulaB, columnA, rowA, columnB, rowB, sparse, opp); for (int i = 0; i < columnA; i++) { for (int j = 0; j < rowB; j++) { if (m[i, j] != 4950 + j * 100) { testComplete = false; } } } Assert.True(testComplete); }
public void TestTransponse() { IMatrix matrix = new MathnetMatrixSolver(); string formulaA = "x*2", formulaB = "y*3"; int columnA = 100, rowA = 100; int columnB = 100, rowB = 100; bool sparse = false; int opp = 1; bool testComplete = true; double[,] m = matrix.ParsedSolve(formulaA, formulaB, columnA, rowA, columnB, rowB, sparse, opp); for (int i = 0; i < columnA; i++) { for (int j = 0; j < rowA; j++) { if (m[i, j] != j * 2) { testComplete = false; } } } Assert.True(testComplete); }