public void TestGetRow() { ObjectMatrix <int> matrix = GetTestMatrix(); int columnCount = matrix.Columns; int rowCount = matrix.Rows; int[] row = matrix.GetRow(0); Assert.AreEqual(matrix.Columns, columnCount); Assert.AreEqual(matrix.Rows, rowCount); Assert.AreEqual(row.Length, matrix.Columns); for (int i = 0; i < row.Length; i++) { Assert.AreEqual(row[i], i); } row = matrix.GetRow(1); Assert.AreEqual(row.Length, matrix.Columns); for (int i = 0; i < row.Length; i++) { Assert.AreEqual(row[i], i + 1); } }
private void Test(string Script, object[][] ExpectedOutput) { Variables v = new Variables(); Expression Exp = new Expression(Script); object Obj = Exp.Evaluate(v); Console.Out.WriteLine(Expression.ToString(Obj)); ObjectMatrix M = Obj as ObjectMatrix; int NrRows, RowIndex; int NrColumns, ColumnIndex; Assert.IsNotNull(M, "Object matrix expected."); Assert.AreEqual(NrRows = ExpectedOutput.Length, M.Rows, "Number of rows in response incorrect."); for (RowIndex = 0; RowIndex < NrRows; RowIndex++) { object[] ExpectedRow = ExpectedOutput[RowIndex]; ObjectVector Row = M.GetRow(RowIndex) as ObjectVector; Assert.IsNotNull(Row, "Object row vector expected."); Assert.AreEqual(NrColumns = ExpectedRow.Length, Row.Dimension, "Number of columns in response incorrect."); for (ColumnIndex = 0; ColumnIndex < NrColumns; ColumnIndex++) { Assert.AreEqual(ExpectedRow[ColumnIndex], Row.GetElement(ColumnIndex).AssociatedObjectValue); } } }
public void GetRowExample() { var matrix = new ObjectMatrix <double>(2, 2); matrix[0, 0] = 1; matrix[0, 1] = 2; matrix[1, 0] = 3; matrix[1, 1] = 4; var row1 = matrix.GetRow(0); Assert.AreEqual(1, row1[0]); Assert.AreEqual(2, row1[1]); var row2 = matrix.GetRow(1); Assert.AreEqual(3, row2[0]); Assert.AreEqual(4, row2[1]); }
public void GetRowExample() { var matrix = new ObjectMatrix<double>(2, 2); matrix[0, 0] = 1; matrix[0, 1] = 2; matrix[1, 0] = 3; matrix[1, 1] = 4; var row1 = matrix.GetRow(0); Assert.AreEqual(1, row1[0]); Assert.AreEqual(2, row1[1]); var row2 = matrix.GetRow(1); Assert.AreEqual(3, row2[0]); Assert.AreEqual(4, row2[1]); }
public void TestInvalidGetRow3() { ObjectMatrix <int> matrix = GetTestMatrix(); int[] row = matrix.GetRow(matrix.Rows + 1); }