Exemple #1
0
        public static MaTran operator -(MaTran A, MaTran B)
        {
            var C = new MaTran(A.M, A.N);

            C = A + -B;
            return(C);
        }
Exemple #2
0
        public void BienDoiTrenHang(int hangA, int hangB, XuLyHaiHang xuLyHang)
        {
            MaTran B = this.Copy();

            for (int i = 0; i < B.N; i++)
            {
                double a = B[hangA, i];
                double b = B[hangB, i];
                xuLyHang(ref a, ref b);
                B[hangA, i] = a;
                B[hangB, i] = b;
            }
            if (MTGhep != null)
            {
                for (int i = 0; i < B.MTGhep.N; i++)
                {
                    double a = B.MTGhep[hangA, i];
                    double b = B.MTGhep[hangB, i];
                    xuLyHang(ref a, ref b);
                    B.MTGhep[hangA, i] = a;
                    B.MTGhep[hangB, i] = b;
                }
            }
            this.Copy(B);
        }
Exemple #3
0
        public void Copy(MaTran B)
        {
            MaTran A = B.Copy();

            MT     = A.MT;
            MTGhep = A.MTGhep;
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var a = new MaTran(@"MaTran\a.txt");
            var b = new MaTran(@"MaTran\b.txt");

            Console.WriteLine((a * b).ToString());
            Console.ReadKey();
        }
Exemple #5
0
        public static MaTran DonVi(int length)
        {
            var mtDonVi = new MaTran(length, length);

            for (int i = 0; i < length; i++)
            {
                mtDonVi[i, i] = 1;
            }
            return(mtDonVi);
        }
Exemple #6
0
 public MaTran(MaTran B)
 {
     newMaTran(B.M, B.N);
     for (int i = 0; i < M; i++)
     {
         for (int j = 0; j < N; j++)
         {
             this[i, j] = B[i, j];
         }
     }
     if (MTGhep != null)
     {
         MTGhep = B.MTGhep.Copy();
     }
 }
Exemple #7
0
        public MaTran Copy()
        {
            var a = new MaTran(M, N);

            for (int i = 0; i < M; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    a[i, j] = this[i, j];
                }
            }
            if (MTGhep != null)
            {
                a.MTGhep = MTGhep.Copy();
            }
            return(a);
        }
Exemple #8
0
 public MaTran CongVoiMaTran(MaTran B)
 {
     if (M == B.M && N == B.N)
     {
         MaTran C = new MaTran(M, N);
         for (int i = 0; i < M; i++)
         {
             for (int j = 0; j < N; j++)
             {
                 C[i, j] = this[i, j] + B[i, j];
             }
         }
         return(C);
     }
     else
     {
         throw new Exception("Không cộng được");
     }
 }
Exemple #9
0
 public MaTran NhanVoiMaTran(MaTran B)
 {
     if (N == B.M)
     {
         var C = new MaTran(M, B.N);
         for (int i = 0; i < C.M; i++)
         {
             for (int j = 0; j < C.N; j++)
             {
                 for (int k = 0; k < N; k++)
                 {
                     C[i, j] += this[i, k] * B[k, j];
                 }
             }
         }
         return(C);
     }
     else
     {
         throw new Exception("không nhân được");
     }
 }