示例#1
0
 public CoolMatrix(int[,] arr)
 {
     if (arr == null) throw  new ArgumentNullException();
     this._arr = arr;
     Size = new Size(arr.GetLength(1), arr.GetLength(0));
     IsSquare = Size.IsSquare;
 }
示例#2
0
 public CoolMatrix(int[,] arr)
 {
     if (arr == null)
         throw new ArgumentNullException();
     Arr = arr;
     Size = new Size(Arr.GetLength(0), Arr.GetLength(1));
 }
示例#3
0
        public void Constructor_WhenPassedArray_ReturnsCorrectSize()
        {
            var arr = new int[3, 2];
            var matrix = new CoolMatrix(arr);

            var expectedSize = new Size(width: 3, height: 2);

            Assert.AreEqual(expectedSize, matrix.Size);
        }
示例#4
0
        public CoolMatrix(int[,] array)
        {
            if (ReferenceEquals(null, array)) throw new ArgumentNullException(nameof(array));

            Size = new Size(array.GetLength(0), array.GetLength(1));

            _arrInts = new int[Size.Width, Size.Height];
            Array.Copy(array, _arrInts, array.Length);
        }
示例#5
0
        public CoolMatrix(int[,] arr)
        {
            if (arr == null)
            {
                throw new ArgumentNullException();
            }

            Size = new Size(arr.GetLength(0), arr.GetLength(1));
            values = arr;
        }
 public CoolMatrix(int[,] arr)
 {
     if (arr == null) throw new ArgumentNullException(nameof(arr), "Can't create matrix from null array");
     _matrix = arr;
     Size = new Size(arr.GetLength(0), arr.GetLength(1));
 }
示例#7
0
        public CoolMatrix Transpose()
        {
            int[,] transposedArray = new int[Size.Height, Size.Width];

            for (var i = 0; i < Size.Width; i++)
                for (var j = 0; j < Size.Height; j++)
                    transposedArray[j, i] = _arrInts[i, j];

            Size = new Size(transposedArray.GetLength(0), transposedArray.GetLength(1));
            _arrInts = transposedArray;

            return this;
        }
示例#8
0
 public bool Equals(Size s)
 {
     if (ReferenceEquals(null, s)) return false;
     if (ReferenceEquals(this, s)) return true;
     return Width == s.Width && Height == s.Height;
 }
示例#9
0
 protected bool Equals(Size other)
 {
     return Width == other.Width && Height == other.Height;
 }