Last active
November 19, 2016 22:29
-
-
Save miho/89714b9aaee741f0b2672361100d036c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.NumberFormat; | |
import java.text.DecimalFormat; | |
@ComponentInfo(name="Matrix2String", category="ODE") | |
public class Matrix2String implements java.io.Serializable { | |
private static final long serialVersionUID=1L; | |
@OutputInfo(style="editor") | |
public String print(@ParamInfo(name="Matrix", options="serialization=false") double[][] matrix) { | |
DecimalFormat df = new DecimalFormat("0.0000") | |
StringBuilder sb = new StringBuilder(); | |
for (int i = 0; i < matrix.length; i++) { | |
sb.append("| ") | |
System.out.print("| ") | |
for (int j = 0; j < matrix[i].length; j++) { | |
String entry = df.format(matrix[i][j]).replace(",",".") + "\t" | |
sb.append(entry) | |
System.out.print(entry) | |
} | |
System.out.println("|") | |
sb.append("|\n") | |
} | |
return sb.toString() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment