Exemplo n.º 1
0
        private Matrix CreateMatrix()
        {
            Matrix matrix = new Matrix
            {
                ArrE = new float[8, 8]
                {
                    { 4.792F, 4.417F, 4.244F, 2.406F, 1.798F, 0.790F, 0.785F, 2.993F },
                    { 4.417F, 5.074F, 4.636F, 2.798F, 1.824F, 0.639F, 0.644F, 2.799F },
                    { 4.244F, 4.636F, 5.428F, 3.224F, 2.111F, 0.903F, 1.131F, 2.943F },
                    { 2.406F, 2.798F, 3.224F, 5.287F, 3.006F, 1.326F, 1.897F, 2.648F },
                    { 1.798F, 1.824F, 2.111F, 3.006F, 3.574F, 2.229F, 2.471F, 1.915F },
                    { 0.790F, 0.639F, 0.903F, 1.326F, 2.229F, 4.008F, 2.405F, 1.106F },
                    { 0.785F, 0.644F, 1.131F, 1.897F, 2.471F, 2.405F, 4.507F, 1.727F },
                    { 2.993F, 2.799F, 2.943F, 2.648F, 1.915F, 1.106F, 1.727F, 3.972F },
                },
                ArrK = new float[8]
                {
                    5.760F, 5.715F, 5.705F, 4.150F, 6.225F, 6.960F, 6.750F, 3.910F
                }
            };

            WorkWithMatrix worker = new WorkWithMatrix(matrix, 0.0001F);

            matrix.ArrSum = worker.SummaTerm();

            return(matrix);
        }
Exemplo n.º 2
0
        private async void ButGiveYMatrix_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (matrix.ArrE == null || matrix.ArrK == null)
                {
                    PrintingMassives.GiveMeMatrixFromTextBoxes(ref matrix, richTextBoxE, richTextBoxK);
                    richTextBoxE.PrintMassiveE(matrix.ArrE, true);
                    richTextBoxK.PrintMassiveK(matrix.ArrK);
                }

                WorkWithMatrix worker = new WorkWithMatrix(matrix, accuracy);

                matrix.ArrEPlus = await Task <float[, ]> .Factory.StartNew(worker.MatricaKPlusOne);

                matrix.ArrSum = await Task <float[, ]> .Factory.StartNew(worker.SummaTerm);

                matrix.ArrF = worker.MyMatrix.ArrF;


                if (listRiches.Count < 3)
                {
                    WindowExtension();
                }

                GetRichBox("richTextBoxSumm").PrintMassiveE(matrix.ArrSum);
                GetRichBox("richTextBoxA").PrintMassiveE(matrix.ArrEPlus);
                GetRichBox("richTextBoxF").PrintMassiveE(matrix.ArrF);

                textBlockKolIter.Text = string.Format("Итераций: {0}", worker.KolIter.ToString());

                butDefaultSizeWindow.Visibility = Visibility.Visible;

                this.ToCenterScreen();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show(string.Format("Отсутвуют матрицы в полях."), "Ошибочка.", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (FormatException)
            {
                MessageBox.Show(string.Format("Неверно введена матрица."), "Ошибочка.", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show(string.Format("Матрицы введены криво."), "Ошибочка.", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(ex.Message), "Ошибочка.", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }