public MyMatrix(IMyMatrixFileReader matrixReader) { if (typeof(T) == typeof(int)) { Matrix = (dynamic)matrixReader.ReadIntMatrix().Clone(); DefaultMatrix = (dynamic)matrixReader.ReadIntMatrix().Clone(); } else if (typeof(T) == typeof(double)) { Matrix = (dynamic)matrixReader.ReadDoubleMatrix().Clone(); DefaultMatrix = (dynamic)matrixReader.ReadDoubleMatrix().Clone(); } }
public void SwapRowsTest() { //Arrange _matrixFileReader = new StubIMyMatrixFileReader { ReadDoubleMatrix = () => new[, ] { { 0.3, 0.6, 0.6, 0.1 }, { 0.4, 0.4, 0.2, 0.6 }, { 0.3, 0.2, 0.3, 0.2 } } }; var matrixValues = _matrixFileReader.ReadDoubleMatrix(); var vector = new[] { 0.3, 0.8, 0.4 }; const int numberOfFirstRow = 0; const int numberOfSecondRow = 2; var matrix = new MyMatrix <double>(matrixValues); //Act matrix.SwapRows(numberOfFirstRow, numberOfSecondRow, vector); //Assert CollectionAssert.AreEqual(new[, ] { { 0.3, 0.2, 0.3, 0.2 }, { 0.4, 0.4, 0.2, 0.6 }, { 0.3, 0.6, 0.6, 0.1 } }, matrix.Matrix); }