예제 #1
0
 public MatrixTypedLong TransponseMatrix()
 {
     MatrixTypedLong R = new MatrixTypedLong(XLength , YLength);
     for (long y = 0; y < YLength; y++)
     {
         R[y] = this.Column(y);
     }
     return R;
 }
예제 #2
0
 private long DetAux(MatrixTypedLong A, long 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 MatrixTypedLong ComplementaryMinorMatrix(long xTerm, long yTerm, bool isAdjugate = false)
        {
            MatrixTypedLong R = new MatrixTypedLong(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 MatrixTypedLong AdjugateMatrix()
 {
     MatrixTypedLong R = new MatrixTypedLong(XLength , YLength);
     for (long y = 0; y < YLength; y++)
     {
         for (long x = 0; x < XLength; x++)
         {
             R[x][y] = (x - y)  % 2 == 0 ? (long)ComplementaryMinorMatrix(x,y).Det() : (long)(ComplementaryMinorMatrix(x,y).Det() * - 1);
         }
     }
     return R;
 }
예제 #5
0
 public static MatrixTypedLong operator +(MatrixTypedLong A, long scalar)
 {
     MatrixTypedLong B = new MatrixTypedLong(A.YLength, A.XLength, scalar);
     return A + B;
 }
예제 #6
0
        public static MatrixTypedLong operator +(MatrixTypedLong A, MatrixTypedLong B)
        {
            MatrixTypedLong R = new MatrixTypedLong(A.YLength, A.XLength);
            for (long y = 0; y < A.YLength; y++)
            {
                Action<long[], long[], long[]> act = delegate (long[] valArrayA, long[] valArrayB, long[] valArrayR)
                {
                    for (long x = 0; x < valArrayA.LongLength; x++)
                    {
                        valArrayR[x] = valArrayA[x] + valArrayB[x];
                    }
                };

                ThreadPoolUtil.Instance.DoAction<long>(act, A[y], B[y], R[y]);
            }
            ThreadPoolUtil.Instance.WaitAll();
            return R;
        }
예제 #7
0
 public static MatrixTypedLong operator *(MatrixTypedLong A, MatrixTypedLong B)
 {
     MatrixExceptionTrigger.CanMultiply(A, B);
     MatrixTypedLong R = new MatrixTypedLong(A.YLength, B.XLength);
     for (long y = 0; y < A.XLength; y++)
     {
             for (long Rx = 0; Rx < A.XLength; Rx++)
             {
                 Action<long[], long[], long> act = delegate (long[] valArrayA, long[] 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<long>(act, A[y], B.Column(Rx), y);
             }
     }
     ThreadPoolUtil.Instance.WaitAll();
     return R;
 }