Class MatFileUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidensureDirectoryExists(String filename) Ensures the directory exists for the given filenamestatic voidEnsures the appropriate workspace directory existsstatic StringgenFilename(String prefix) Generates a timestamp-based filename for .mat files in the appropriate workspace directorystatic StringThe directory thekeepoption writes its.matworkspaces to.static voidsaveCTMCWorkspace(Matrix stateSpace, Matrix infGen, Matrix pi, String filename) Saves CTMC solver workspace to a .mat filestatic voidsaveMatrix(Matrix matrix, String variableName, String filename) Saves a single matrix to a .mat filestatic voidsaveWorkspace(Map<String, Matrix> matrices, String filename) Saves multiple matrices to a .mat file as a workspace
-
Constructor Details
-
MatFileUtils
public MatFileUtils()
-
-
Method Details
-
saveMatrix
public static void saveMatrix(Matrix matrix, String variableName, String filename) throws IOException Saves a single matrix to a .mat file- Parameters:
matrix- The matrix to savevariableName- The name of the variable in the .mat filefilename- The output filename- Throws:
IOException- if file writing fails
-
saveWorkspace
Saves multiple matrices to a .mat file as a workspace- Parameters:
matrices- Map of variable names to matricesfilename- The output filename- Throws:
IOException- if file writing fails
-
saveCTMCWorkspace
public static void saveCTMCWorkspace(Matrix stateSpace, Matrix infGen, Matrix pi, String filename) throws IOException Saves CTMC solver workspace to a .mat file- Parameters:
stateSpace- The state space matrixinfGen- The infinitesimal generator matrixpi- The steady-state probability vectorfilename- The output filename- Throws:
IOException- if file writing fails
-
genFilename
Generates a timestamp-based filename for .mat files in the appropriate workspace directory- Parameters:
prefix- The prefix for the filename- Returns:
- A filename with timestamp in the appropriate workspace directory
-
getWorkspaceDirectory
The directory thekeepoption writes its.matworkspaces to.$LINE_WORKSPACE_ROOT/line_workspace/mat, or the system temp dir under the same name, which is where the MATLAB twin puts them too:solver_ctmc_marg.mand its siblings name the file withlineTempName.This used to resolve
<installRoot>/jar/workspace, or<installRoot>/python/workspacewhen the working directory happened to contain the substring "python". Both are wrong for the same reason: an installation directory is not a place to write to. It may be read-only, it may be shared between users, and on a release archive the only trace of the scheme was a pair of emptyworkspacefolders shipped so that the write would have somewhere to land. The cwd substring test was also a guess about the caller that a caller under, say,/home/python-devanswered wrongly.- Returns:
- the workspace directory path, which need not exist yet
-
ensureDirectoryExists
Ensures the directory exists for the given filename- Parameters:
filename- The filename to create directory for- Throws:
IOException- if directory creation fails
-
ensureWorkspaceDirectoryExists
Ensures the appropriate workspace directory exists- Throws:
IOException- if directory creation fails
-