Class MatlabReader
  
  Reads the contents of a MAT file.
Assembly: Microsoft.ML.Probabilistic.dll
  Syntax
  
    public class MatlabReader : IDisposable
   
  
  
  Constructors
  
  
  MatlabReader(Stream)
  Create a MatlabReader that reads from the given stream.
Declaration
  
    protected MatlabReader(Stream reader)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Stream | reader | The stream to read from | 
    
  
  
  MatlabReader(String)
  Create a MatlabReader that reads from the given file name.
Declaration
  
    protected MatlabReader(string fileName)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | String | fileName | The MAT file name to read from | 
    
  
  Methods
  
  
  Dispose()
  Release the stream used by this MatlabReader
Declaration
  
  
  GetType(mxClass)
  
  
  Declaration
  
    protected Type GetType(mxClass dataClass)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | mxClass | dataClass |  | 
    
  
  Returns
  
  
  Matlab5DataElement(out String)
  Read the next data element from the stream
Declaration
  
    protected object Matlab5DataElement(out string name)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | String | name | On exit, the variable name | 
    
  
  Returns
  
    
      
        | Type | Description | 
    
    
      
        | Object | The data value, as a .NET object | 
    
  
  
  
  Read a MAT file header from the stream
Declaration
  
    protected string Matlab5Header()
   
  Returns
  
    
      
        | Type | Description | 
    
    
      
        | String | The header as a string | 
    
  
  
  Parse(MatType, out String)
  Read a specific data type from the stream
Declaration
  
    protected object Parse(MatType dataType, out string name)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | MatType | dataType | The type number as documented by the MAT format | 
      
        | String | name | On exit, the variable name | 
    
  
  Returns
  
    
      
        | Type | Description | 
    
    
      
        | Object | The data value, as a .NET object | 
    
  
  
  ParseString(Byte[], Int32, Int32)
  Convert an array of bytes into a string
Declaration
  
    protected static string ParseString(byte[] bytes, int start, int length)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Byte[] | bytes | The bytes | 
      
        | Int32 | start | The position of the first character in the string | 
      
        | Int32 | length | An upper bound on the length of the string | 
    
  
  Returns
  
  
  Read(String)
  Read all variables from a file and store them in a dictionary
Declaration
  
    public static Dictionary<string, object> Read(string fileName)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | String | fileName | The name of a MAT file | 
    
  
  Returns
  
  
  ReadAll()
  Read all variables from the current stream and store them in a dictionary
Declaration
  
    protected Dictionary<string, object> ReadAll()
   
  Returns
  
  
  ReadArray(mxClass, Int32[])
  
  
  Declaration
  
    protected Array ReadArray(mxClass dataClass, int[] sizes)
   
  Parameters
  
  Returns
  
  
  ReadBoolArray(Int32)
  
  
  Declaration
  
    protected object ReadBoolArray(int count)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | count |  | 
    
  
  Returns
  
  
  ReadCellArray(Int32[])
  
  
  Declaration
  
    protected Array ReadCellArray(int[] sizes)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32[] | sizes |  | 
    
  
  Returns
  
  
  ReadCsv(String)
  Read a csv file (with a header row) as a set of columns
Declaration
  
    public static Dictionary<string, List<string>> ReadCsv(string path)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | String | path |  | 
    
  
  Returns
  
  
  
  
  ReadDouble()
  Read a double-precision float from the stream
Declaration
  
    protected double ReadDouble()
   
  Returns
  
  
  ReadElement(MatType)
  
  
  Declaration
  
    protected object ReadElement(MatType elementClass)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | MatType | elementClass |  | 
    
  
  Returns
  
  
  ReadInt()
  Read a 32-bit integer from the stream
Declaration
  
  Returns
  
  
  ReadInt16()
  Read a 16-bit integer from the stream
Declaration
  
    protected short ReadInt16()
   
  Returns
  
  
  ReadInt64()
  Read a 64-bit integer from the stream
Declaration
  
    protected long ReadInt64()
   
  Returns
  
  
  ReadIntArray(Int32)
  
  
  Declaration
  
    protected object ReadIntArray(int count)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | count |  | 
    
  
  Returns
  
  
  ReadLongArray(Int32)
  
  
  Declaration
  
    protected object ReadLongArray(int count)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | count |  | 
    
  
  Returns
  
  
  ReadMatrix(mxClass, Int32, Int32)
  
  
  Declaration
  
    protected Matrix ReadMatrix(mxClass dataClass, int rows, int cols)
   
  Parameters
  
  Returns
  
  
  ReadMatrix(Double[,], String)
  
  
  Declaration
  
    public static double[, ] ReadMatrix(double[, ] matrix, string filename)
   
  Parameters
  
  Returns
  
  
  ReadMatrix(Double[,], String, Char)
  
  
  Declaration
  
    public static double[, ] ReadMatrix(double[, ] matrix, string filename, char separator)
   
  Parameters
  
  Returns
  
  
  ReadPadding(Int32, Boolean)
  
  
  Declaration
  
    protected void ReadPadding(int numBytesRead, bool isSmallFormat)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | numBytesRead |  | 
      
        | Boolean | isSmallFormat |  | 
    
  
  
  ReadSingle()
  Read a single-precision float from the stream
Declaration
  
    protected float ReadSingle()
   
  Returns
  
  
  ReadString()
  
  
  Declaration
  
    protected string ReadString()
   
  Returns
  
  
  ReadString(Int32)
  Read a string of known length from the stream
Declaration
  
    protected string ReadString(int length)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | length | The number of bytes in the string | 
    
  
  Returns
  
  
  ReadStruct()
  
  
  Declaration
  
    protected Dictionary<string, object> ReadStruct()
   
  Returns
  
  
  ReadTypeAndSize(out MatType, out Int32)
  
  
  Declaration
  
    protected bool ReadTypeAndSize(out MatType type, out int numBytes)
   
  Parameters
  
  Returns
  
  
  ReadUInt()
  Read an unsigned 32-bit integer from the stream
Declaration
  
    protected uint ReadUInt()
   
  Returns
  
  
  ReadUInt16()
  Read an unsigned 16-bit integer from the stream
Declaration
  
    protected ushort ReadUInt16()
   
  Returns
  
  
  ReadUInt64()
  Read an unsigned 64-bit integer from the stream
Declaration
  
    protected ulong ReadUInt64()
   
  Returns
  
  
  ReadUIntArray(Int32)
  
  
  Declaration
  
    protected object ReadUIntArray(int count)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | count |  | 
    
  
  Returns
  
  
  ReadULongArray(Int32)
  
  
  Declaration
  
    protected object ReadULongArray(int count)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Int32 | count |  | 
    
  
  Returns
  
  
  
  
  
  Declaration
  
    protected static byte[] RemoveRfc1950Header(byte[] bytes)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | Byte[] | bytes |  | 
    
  
  Returns
  
    
      
        | Type | Description | 
    
    
      
        | Byte[] | A smaller array of bytes | 
    
  
  
  
  
  SizeOf(MatType)
  Get the size in bytes of a MatType
Declaration
  
    public static int SizeOf(MatType type)
   
  Parameters
  
  Returns
  
    
      
        | Type | Description | 
    
    
      
        | Int32 | Number of bytes | 
    
  
  Implements