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; }
public CoolMatrix(int[,] arr) { if (arr == null) throw new ArgumentNullException(); Arr = arr; Size = new Size(Arr.GetLength(0), Arr.GetLength(1)); }
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); }
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); }
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)); }
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; }
public bool Equals(Size s) { if (ReferenceEquals(null, s)) return false; if (ReferenceEquals(this, s)) return true; return Width == s.Width && Height == s.Height; }
protected bool Equals(Size other) { return Width == other.Width && Height == other.Height; }