コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: Lezrec/TSAMatrixProject
        public void Integer_Matrix_Value_Change_Test()
        {
            //Arrange
            int           row      = rand.Next(1, 10);
            int           col      = rand.Next(1, 10);
            int           rowIndex = rand.Next(1, row - 1);
            int           colIndex = rand.Next(1, col - 1);
            IntegerMatrix m1       = new IntegerMatrix(row, col);

            //Act
            m1.Replace(rowIndex, colIndex, 5); //value doesnt matter just cant be zero
            //Assert
            Assert.AreEqual(m1.Get(rowIndex, colIndex), 5);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: Lezrec/TSAMatrixProject
        private Random rand = new Random(); //TODO: Figure out whether to keep the same seed every time or not.

        public IntegerMatrix GenerateRandomIntegerMatrix()
        {
            int           row = rand.Next(1, 10);
            int           col = rand.Next(1, 10);
            IntegerMatrix ret = new IntegerMatrix(row, col);

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    ret.Replace(i, j, rand.Next(9, 255));
                }
            }
            return(ret);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Lezrec/TSAMatrixProject
        public static void Main(string[] args)
        {
            Random        rand = new Random();
            IntegerMatrix m1   = new IntegerMatrix(2, 3);

            m1.Replace(1, 1, 5);
            Console.WriteLine(m1.ToString());
            IntegerMatrix m2 = new IntegerMatrix(2, 3);

            m2.Replace(0, 2, 15);
            IntegerMatrix m3 = (IntegerMatrix)m1.AppendByRow(m2);
            IntegerMatrix m4 = (IntegerMatrix)m1.AppendByColumn(m2);

            Console.WriteLine(m3.ToString());
            Console.WriteLine(m4.ToString());
            SquareIntegerMatrix sq1 = new SquareIntegerMatrix(3);
            SquareIntegerMatrix sq2 = new SquareIntegerMatrix(3);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    sq1.Replace(i, j, rand.Next(0, 10));
                    sq2.Replace(i, j, rand.Next(0, 10));
                }
            }
            Console.WriteLine(sq1.ToString());
            Console.WriteLine(sq2.ToString());
            SquareIntegerMatrix prod1 = sq1.Multiply(sq2);

            Console.WriteLine(prod1.ToString());
            IntegerMatrix minor1 = prod1.GetMinor(0);
            IntegerMatrix minor2 = prod1.GetMinor(1);
            IntegerMatrix minor3 = prod1.GetMinor(2);

            Console.WriteLine(minor1);
            Console.WriteLine(minor2);
            Console.WriteLine(minor3);
            TestAlgebra();
            Console.Read();
        }