/** * Create a string representation of the given array, as a matrix, * interpreting it as a matrix that is stored in column-major order. The * given array may be <code>null</code>. If it is not <code>null</code>, * then it must either have 3x3 elements or 4x4 elements. * * @param array The array * @return The string representation */ public static String createMatrixString(float array[]) { if (array == null) { return "null"; } if (array.length == 9) { return createMatrixString(array, 3, 3); } if (array.length == 16) { return createMatrixString(array, 4, 4); } return "WARNING: Not a matrix: "+Arrays.toString(array); }
/** * Adds the operation to print a log message about the current matrix * * @param name The name of the matrix, which will be part of the message * @param level The log level * @return This builder */ MatrixOps log(String name, Level level) { functions.add(named("log "+name, input -> { if (logger.isLoggable(level)) { logger.log(level, name + ":\n" + MathUtils.createMatrixString(input)); } return input; })); return this; }