Class MatlabUtils


  • public class MatlabUtils
    extends Object
    Helper class for Matlab data structures.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Summary

      Constructors 
      Constructor Description
      MatlabUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String arrayDimensionsToString​(us.hebi.matlab.mat.types.Array array)
      Generates a string representation of the array dimensions, uses 'x' as separator.
      static String arrayDimensionsToString​(us.hebi.matlab.mat.types.Array array, String separator)
      Generates a string representation of the array dimensions.
      static String charToString​(us.hebi.matlab.mat.types.Char matChar)
      Converts a character cell into a string.
      static Object getElement​(us.hebi.matlab.mat.types.Matrix source, int[] index, ArrayElementType type)
      Returns the element according to the specified type.
      static boolean increment​(int[] index, int[] dims)
      Increments the index.
      static boolean increment​(int[] index, int[] dims, int[] open)
      Increments the index.
      static String setElement​(us.hebi.matlab.mat.types.Matrix target, int[] index, ArrayElementType type, Object value)
      Sets the element according to the specified type.
      static void transfer​(us.hebi.matlab.mat.types.Matrix source, int[] indexSource, int[] dimsSource, int[] openSource, us.hebi.matlab.mat.types.Matrix target, int[] indexTarget, int[] dimsTarget, int[] openTarget, ArrayElementType type)
      For transferring the subset from the original matrix into the new one.
      static void transfer​(us.hebi.matlab.mat.types.Matrix source, int[] dimsSource, int[] openSource, int[] indexSource, us.hebi.matlab.mat.types.Matrix target, int[] dimsTarget, ArrayElementType type)
      For transferring the subset from the original matrix into the new one.
      static void transfer​(us.hebi.matlab.mat.types.Matrix source, int[] sourceIndex, us.hebi.matlab.mat.types.Matrix target, int[] targetIndex, ArrayElementType type)
      Transfers a single cell from one matrix to another.
    • Constructor Detail

      • MatlabUtils

        public MatlabUtils()
    • Method Detail

      • charToString

        public static String charToString​(us.hebi.matlab.mat.types.Char matChar)
        Converts a character cell into a string. Rows are interpreted as lines.
        Parameters:
        matChar - the cell to convert
        Returns:
        the generated string
      • increment

        public static boolean increment​(int[] index,
                                        int[] dims)
        Increments the index.
        Parameters:
        index - the current index
        dims - the dimensions (ie max values)
        Returns:
        true if finished
      • increment

        public static boolean increment​(int[] index,
                                        int[] dims,
                                        int[] open)
        Increments the index.
        Parameters:
        index - the current index
        dims - the dimensions (ie max values)
        open - the indices that are "open" to be incremented
        Returns:
        true if finished
      • transfer

        public static void transfer​(us.hebi.matlab.mat.types.Matrix source,
                                    int[] sourceIndex,
                                    us.hebi.matlab.mat.types.Matrix target,
                                    int[] targetIndex,
                                    ArrayElementType type)
        Transfers a single cell from one matrix to another.
        Parameters:
        source - the source matrix
        sourceIndex - the index of the cell in the source matrix
        target - the target matrix
        targetIndex - the index of the cell in the target matrix
        type - the type of element to transfer
      • transfer

        public static void transfer​(us.hebi.matlab.mat.types.Matrix source,
                                    int[] dimsSource,
                                    int[] openSource,
                                    int[] indexSource,
                                    us.hebi.matlab.mat.types.Matrix target,
                                    int[] dimsTarget,
                                    ArrayElementType type)
        For transferring the subset from the original matrix into the new one.
        Parameters:
        source - the source matrix
        dimsSource - the dimensions of the source matrix
        openSource - the indices of the "open" dimensions
        indexSource - the indices in the source to use
        target - the target matrix
        dimsTarget - the dimensions of the target matrix
        type - the element type to use for transferring the data
      • transfer

        public static void transfer​(us.hebi.matlab.mat.types.Matrix source,
                                    int[] indexSource,
                                    int[] dimsSource,
                                    int[] openSource,
                                    us.hebi.matlab.mat.types.Matrix target,
                                    int[] indexTarget,
                                    int[] dimsTarget,
                                    int[] openTarget,
                                    ArrayElementType type)
        For transferring the subset from the original matrix into the new one.
        Parameters:
        source - the source matrix
        indexSource - the source index template to use, initializes with all 0s if null
        dimsSource - the dimensions of the source matrix
        openSource - the indices of the "open" dimensions
        target - the target matrix
        indexTarget - the target index template to use, initializes with all 0s if null
        dimsTarget - the dimensions of the target matrix
        openTarget - the indices of the "open" dimensions
        type - the element type to use for transferring the data
      • getElement

        public static Object getElement​(us.hebi.matlab.mat.types.Matrix source,
                                        int[] index,
                                        ArrayElementType type)
        Returns the element according to the specified type.
        Parameters:
        source - the matrix to get the element from
        index - the index of the element
        type - the type of element
        Returns:
        the value
      • setElement

        public static String setElement​(us.hebi.matlab.mat.types.Matrix target,
                                        int[] index,
                                        ArrayElementType type,
                                        Object value)
        Sets the element according to the specified type.
        Parameters:
        target - the matrix to set the element in
        index - the index of the element
        type - the type of element
        value - the value of the element, gets automatically parsed if string
        Returns:
        null if successfully set, otherwise error message
      • arrayDimensionsToString

        public static String arrayDimensionsToString​(us.hebi.matlab.mat.types.Array array)
        Generates a string representation of the array dimensions, uses 'x' as separator.
        Parameters:
        array - the array to generate the dimensions for
        Returns:
        the generated string
      • arrayDimensionsToString

        public static String arrayDimensionsToString​(us.hebi.matlab.mat.types.Array array,
                                                     String separator)
        Generates a string representation of the array dimensions.
        Parameters:
        array - the array to generate the dimensions for
        separator - the separator to use for the dimensions
        Returns:
        the generated string