Пример #1
0
 public MatrixTypedInt TransponseMatrix()
 {
     MatrixTypedInt R = new MatrixTypedInt(XLength , YLength);
     for (long y = 0; y < YLength; y++)
     {
         R[y] = this.Column(y);
     }
     return R;
 }
Пример #2
0
 private long DetAux(MatrixTypedInt A, int Aij)
 {
     long result = 0;
     if (A.Dimension.Equals("2x2"))
     {
         result = ((A[0][0] * A[1][1] ) - (A[0][1] * A[1][0])) * Aij;
     }
     else
     {
         for (int x = 0; x < A.XLength; x++)
         {
             if ((x - 0)%2 == 0)
             {
                 result+=  DetAux(A.ComplementaryMinorMatrix(0, x), A[0][x]) * Aij;
             }
             else
             {
                 result+=  -1*DetAux(A.ComplementaryMinorMatrix(0, x), A[0][x]) * Aij;
             }
         }
     }
     return result;
 }
Пример #3
0
        public MatrixTypedInt ComplementaryMinorMatrix(long xTerm, long yTerm, bool isAdjugate = false)
        {
            MatrixTypedInt R = new MatrixTypedInt(XLength - 1, YLength -1);
            long xAux = 0, yAux = 0;

            for (long y = 0; y < YLength; y++)
            {
                if (yTerm != y)
                {
                    for (long x = 0; x < XLength; x++)
                    {
                        if (xTerm != x)
                        {
                            if (isAdjugate)
                            {
                                R[xAux][yAux] = (xTerm - yTerm) % 2 == 0 ? this[x][y] : this[x][y] * -1;
                            }
                            else
                            {
                                R[xAux][yAux] =  this[x][y];
                            }
                            xAux++;
                        }
                    }
                    xAux = 0;
                    yAux++;
                }
            }
            return R;
        }
Пример #4
0
 public MatrixTypedInt AdjugateMatrix()
 {
     MatrixTypedInt R = new MatrixTypedInt(XLength , YLength);
     for (long y = 0; y < YLength; y++)
     {
         for (long x = 0; x < XLength; x++)
         {
             R[x][y] = (x - y)  % 2 == 0 ? (int)ComplementaryMinorMatrix(x,y).Det() : (int)(ComplementaryMinorMatrix(x,y).Det() * - 1);
         }
     }
     return R;
 }
Пример #5
0
 public static MatrixTypedInt operator +(MatrixTypedInt A, int scalar)
 {
     MatrixTypedInt B = new MatrixTypedInt(A.YLength, A.XLength, scalar);
     return A + B;
 }
Пример #6
0
        public static MatrixTypedInt operator +(MatrixTypedInt A, MatrixTypedInt B)
        {
            MatrixTypedInt R = new MatrixTypedInt(A.YLength, A.XLength);
            for (long y = 0; y < A.YLength; y++)
            {
                Action<int[], int[], int[]> act = delegate (int[] valArrayA, int[] valArrayB, int[] valArrayR)
                {
                    for (long x = 0; x < valArrayA.LongLength; x++)
                    {
                        valArrayR[x] = valArrayA[x] + valArrayB[x];
                    }
                };

                ThreadPoolUtil.Instance.DoAction<int>(act, A[y], B[y], R[y]);
            }
            ThreadPoolUtil.Instance.WaitAll();
            return R;
        }
Пример #7
0
 public static MatrixTypedInt operator *(MatrixTypedInt A, MatrixTypedInt B)
 {
     MatrixExceptionTrigger.CanMultiply(A, B);
     MatrixTypedInt R = new MatrixTypedInt(A.YLength, B.XLength);
     for (long y = 0; y < A.XLength; y++)
     {
             for (long Rx = 0; Rx < A.XLength; Rx++)
             {
                 Action<int[], int[], long> act = delegate (int[] valArrayA, int[] valArrayB, long row)
                 {
                     for (long x = 0; x < valArrayA.LongLength; x++)
                     {
                         for (long Ry = 0; Ry < valArrayB.LongLength; Ry++)
                             R[row][x] += valArrayA[x] * valArrayB[Ry];
                     }
                 };
                 ThreadPoolUtil.Instance.DoAction<int>(act, A[y], B.Column(Rx), y);
             }
     }
     ThreadPoolUtil.Instance.WaitAll();
     return R;
 }