/** * Writes the content of this parameter to the specified table. * * @param table The table where to format the parameter value. * @throws IOException if an error occurs during output operation. */ @Override protected void write(final TableWriter table) throws IOException { table.write(getName(descriptor)); table.nextColumn(); table.write('='); table.nextColumn(); table.write(getMatrix().toString()); table.nextLine(); } }
if (parameters instanceof MatrixParameters) { return ((MatrixParameters) parameters).getMatrix();
/** Tests the storage of matrix parameters. */ @Test public void testMatrixEdit() { final int size = 8; final Random random = new Random(47821365); final GeneralMatrix matrix = new GeneralMatrix(size); for (int j = 0; j < size; j++) { for (int i = 0; i < size; i++) { matrix.setElement(j, i, 200 * random.nextDouble() - 100); } } final MatrixParameterDescriptors descriptor = new MatrixParameterDescriptors(Collections.singletonMap("name", "Test")); for (int height = 2; height <= size; height++) { for (int width = 2; width <= size; width++) { MatrixParameters parameters = (MatrixParameters) descriptor.createValue(); GeneralMatrix copy = matrix.clone(); copy.setSize(height, width); parameters.setMatrix(copy); assertEquals( "height", height, ((Parameter) parameters.parameter("num_row")).intValue()); assertEquals( "width", width, ((Parameter) parameters.parameter("num_col")).intValue()); assertTrue("equals", copy.equals(parameters.getMatrix(), 0)); assertEquals("equals", parameters, parameters.clone()); } } }