示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ClearOutpur();
            Matrixx matrixA = new Matrixx(2, 2);
            string  text    = "1 2 ; 3 4 ;";

            matrixA.setMatrix(text);
            Matrixx matrixx = new Matrixx(2, 4);
            int     ri      = 2;
            int     rj      = 2;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    matrixx[i, j]  = matrixA[i, j];
                    matrixx[i, rj] = matrixA[i, j];
                    rj++;
                }
                rj = 2;
                //ri++;
            }



            List <Matrixx> listA = new List <Matrixx>();

            listA.Add(matrixA);
            PrintToGrid(listA, tabControl1);
            List <Matrixx> listB = new List <Matrixx>();

            listB.Add(matrixx);
            PrintToGrid(listB, tabControl2);
        }
示例#2
0
        public List <Matrixx> Kronekera(List <Matrixx> list1, List <Matrixx> list2)
        {
            var numbersAndWords = list1.Zip(list2, (matrixA, matrixB) => new { matrixA = matrixA, matrixB = matrixB });
            //foreach (var nw in numbersAndWords)


            List <Matrixx> resalt = new List <Matrixx>();

            foreach (var item in numbersAndWords)
            {
                Matrixx matrixC = new Matrixx(item.matrixA.column * 3, item.matrixA.row * 3);
                for (int i = 0; i < item.matrixA.column; i++)
                {
                    for (int j = 0; j < item.matrixA.row; j++)
                    {
                        for (int ri = 0; ri < item.matrixA.column; ri++)
                        {
                            for (int rj = 0; rj < item.matrixA.row; rj++)
                            {
                                matrixC[ri + i * item.matrixA.column, rj + j * item.matrixA.row] = item.matrixA[i, j] * item.matrixB[ri, rj];
                            }
                        }
                    }
                }
                resalt.Add(matrixC);
            }
            return(resalt);
        }
示例#3
0
        public static Matrixx operator /(Matrixx A, Matrixx B)
        {
            Matrixx       C    = new Matrixx(A.column * A.column, A.row);
            List <double> temp = new List <double>();

            for (int i = 0; i < A.row; i++)
            {
                for (int j = 0; j < A.column; j++)
                {
                    for (int k = 0; k < A.column; k++)
                    {
                        temp.Add(A[j, i] * B[k, i]);
                    }
                }
            }
            int count = 0;

            for (int j = 0; j < A.row; j++)
            {
                for (int i = 0; i < A.column * A.column; i++)
                {
                    C[i, j] = temp[count];
                    count++;
                }
            }
            return(C);
        }
示例#4
0
        public void Norma(TextBox textBox, Matrixx matrix)
        {
            double sum = 0;

            for (int i = 0; i < matrix.column; i++)
            {
                for (int j = 0; j < matrix.row; j++)
                {
                    sum += matrix[i, j] * matrix[i, j];
                }
            }

            textBox.Text += "Норма Тензора= " + Math.Sqrt(sum).ToString();
        }
示例#5
0
        public List <Matrixx> XariRao(List <Matrixx> list1, List <Matrixx> list2)
        {
            var numbersAndWords = list1.Zip(list2, (matrixA, matrixB) => new { matrixA = matrixA, matrixB = matrixB });
            //foreach (var nw in numbersAndWords)


            List <Matrixx> resalt = new List <Matrixx>();

            foreach (var item in numbersAndWords)
            {
                Matrixx matrix2 = item.matrixA / item.matrixB;

                resalt.Add(matrix2);
            }
            return(resalt);
        }
示例#6
0
        private void button3_Click(object sender, EventArgs e)
        {
            Matrixx matrix1 = new Matrixx(3, 3);
            string  text    = "1 1 1 ; 1 1 1 ; 1 1 1 ;";

            matrix1.setMatrix(text);
            Matrixx matrix2 = new Matrixx(3, 3);

            text = "2 2 2 ; 2 2 2 ; 2 2 2 ;";
            matrix2.setMatrix(text);
            Matrixx matrix3 = new Matrixx(3, 3);

            text = "3 3 3 ; 3 3 3 ; 3 3 3 ;";
            matrix3.setMatrix(text);

            List <Matrixx> matricesx = new List <Matrixx>();

            matricesx.Add(matrix1);
            matricesx.Add(matrix2);
            matricesx.Add(matrix3);
            PrintToGrid(matricesx, tabControl1);
            Matrixx        matrix01   = new Matrixx(3, 3);
            Matrixx        matrix02   = new Matrixx(3, 3);
            Matrixx        matrix03   = new Matrixx(3, 3);
            List <Matrixx> matricesx0 = new List <Matrixx>();

            matricesx0.Add(matrix01);
            matricesx0.Add(matrix02);
            matricesx0.Add(matrix03);
            PrintToGrid(matricesx0, tabControl2);

            int[] u = { 1, 2, 3 };
            int[] v = { 1, 2, 3 };
            int[] w = { 1, 2, 3 };
            for (int i = 0; i < matricesx[0].row; i++)
            {
                for (int j = 0; j < matricesx[0].row; j++)
                {
                    for (int k = 0; k < matricesx[0].row; k++)
                    {
                        matricesx0[i][j, k] = u[i] * v[j] * w[k];
                    }
                }
            }

            PrintToGrid(matricesx0, tabControl3);
        }
示例#7
0
 public static Matrixx operator *(Matrixx A, Matrixx B)
 {
     if (A.column == B.column && A.row == B.row)
     {
         Matrixx C = new Matrixx(A.column, A.row);
         for (int i = 0; i < A.column; i++)
         {
             for (int j = 0; j < A.row; j++)
             {
                 C[i, j] = A[i, j] * B[i, j];
             }
         }
         return(C);
     }
     MessageBox.Show("Помилка!!! Розмірність матриць різна!");
     return(new Matrixx(0, 0));
 }
示例#8
0
        private void button5_Click(object sender, EventArgs e)
        {
            ClearOutpur();
            Matrixx matrixA = new Matrixx(2, 2);
            string  text    = "1 2 ; 3 4 ;";

            matrixA.setMatrix(text);
            Matrixx matrixB = new Matrixx(2, 2);

            text = "5 6 ; 7 8 ;";
            matrixB.setMatrix(text);
            Matrixx matrixx = new Matrixx(2, 4);
            int     i       = 0;

            foreach (var m in matrixA.m)
            {
                matrixx[0, i] = m;
                i++;
            }
            i = 0;
            foreach (var m in matrixB.m)
            {
                matrixx[1, i] = m;
                i++;
            }
            List <Matrixx> listA = new List <Matrixx>();

            listA.Add(matrixA);
            PrintToGrid(listA, tabControl1);

            List <Matrixx> listB = new List <Matrixx>();

            listB.Add(matrixB);
            PrintToGrid(listB, tabControl2);



            List <Matrixx> listC = new List <Matrixx>();

            listC.Add(matrixx);
            PrintToGrid(listC, tabControl3);
        }
示例#9
0
        private void button2_Click(object sender, EventArgs e)
        {
            Matrixx matrix1 = new Matrixx(3, 3);
            string  text    = "1 1 1 ; 1 1 1 ; 1 1 1 ;";

            matrix1.setMatrix(text);
            Matrixx matrix2 = new Matrixx(3, 3);

            text = "1 1 1 ; 1 5 1 ; 1 1 1 ;";
            matrix2.setMatrix(text);



            List <Matrixx> matricesx = new List <Matrixx>();

            matricesx.Add(matrix1);
            matricesx.Add(matrix2);
            matricesx.Add(matrix1);
            PrintToGrid(matricesx, tabControl1);
            SuperSemetr(matricesx, textBox1);

            MainDiagonal(matricesx, textBox1);
        }
示例#10
0
        public void DefMatrixParni()
        {
            Matrixx matrix1 = new Matrixx(3, 3);
            string  text    = "2 4 6 ; 8 10 12 ; 14 16 18 ;";

            matrix1.setMatrix(text);

            Matrixx matrix2 = new Matrixx(3, 3);

            text = "1 3 5 ; 7 9 11 ; 13 15 17 ;";
            matrix2.setMatrix(text);

            Matrixx matrix3 = new Matrixx(3, 3);

            text = "1 1 2 ; 3 5 8 ; 13 21 1 ;";
            matrix3.setMatrix(text);

            List <Matrixx> listA = new List <Matrixx>();

            listA.Add(matrix1);
            listA.Add(matrix2);
            listA.Add(matrix3);
            GlobalList.Add(listA);
        }
示例#11
0
        public void DefMatrix123()
        {
            Matrixx matrix1 = new Matrixx(3, 3);
            string  text    = "1 2 3 ; 4 5 6 ; 7 8 9 ;";

            matrix1.setMatrix(text);

            Matrixx matrix2 = new Matrixx(3, 3);

            text = "10 11 12 ; 13 14 15 ; 16 17 18 ;";
            matrix2.setMatrix(text);

            Matrixx matrix3 = new Matrixx(3, 3);

            text = "19 20 21 ; 22 23 24 ; 25 26 27 ;";
            matrix3.setMatrix(text);

            List <Matrixx> listA = new List <Matrixx>();

            listA.Add(matrix1);
            listA.Add(matrix2);
            listA.Add(matrix3);
            GlobalList.Add(listA);
        }
示例#12
0
        public void DefMatrix111()
        {
            Matrixx matrix1 = new Matrixx(3, 3);
            string  text    = "1 1 1 ; 1 1 1 ; 1 1 1 ;";

            matrix1.setMatrix(text);

            Matrixx matrix2 = new Matrixx(3, 3);

            text = "1 1 1 ; 1 5 1 ; 1 1 1 ;";
            matrix2.setMatrix(text);

            Matrixx matrix3 = new Matrixx(3, 3);

            text = "1 1 1 ; 1 1 1 ; 1 1 1 ;";
            matrix3.setMatrix(text);

            List <Matrixx> listA = new List <Matrixx>();

            listA.Add(matrix1);
            listA.Add(matrix2);
            listA.Add(matrix3);
            GlobalList.Add(listA);
        }