Package jline.util

Class MatFileUtils

java.lang.Object
jline.util.MatFileUtils

public class MatFileUtils extends Object
Utility class for saving matrices and workspaces to MATLAB .mat files using the MFL (MATLAB File Library) for Java.
  • 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 save
      variableName - The name of the variable in the .mat file
      filename - The output filename
      Throws:
      IOException - if file writing fails
    • saveWorkspace

      public static void saveWorkspace(Map<String,Matrix> matrices, String filename) throws IOException
      Saves multiple matrices to a .mat file as a workspace
      Parameters:
      matrices - Map of variable names to matrices
      filename - 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 matrix
      infGen - The infinitesimal generator matrix
      pi - The steady-state probability vector
      filename - The output filename
      Throws:
      IOException - if file writing fails
    • genFilename

      public static String genFilename(String prefix)
      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

      public static String getWorkspaceDirectory()
      Determines the appropriate workspace directory based on the runtime context
      Returns:
      The workspace directory path relative to the JAR location
    • ensureDirectoryExists

      public static void ensureDirectoryExists(String filename) throws IOException
      Ensures the directory exists for the given filename
      Parameters:
      filename - The filename to create directory for
      Throws:
      IOException - if directory creation fails
    • ensureWorkspaceDirectoryExists

      public static void ensureWorkspaceDirectoryExists() throws IOException
      Ensures the appropriate workspace directory exists
      Throws:
      IOException - if directory creation fails