public class MatlabIoKernel extends Object implements ArrayIoKernel
ArrayIoKernel
that reads and writes MATLAB MAT-files.Modifier and Type | Class and Description |
---|---|
protected static class |
MatlabIoKernel.DataElement<T>
A MATLAB data element.
|
protected static class |
MatlabIoKernel.DoubleArrayDataElement
A MATLAB data element that is an array of
double s. |
protected static class |
MatlabIoKernel.IntArrayDataElement
A MATLAB data element that is an array of
int s. |
protected static class |
MatlabIoKernel.MatrixDataElement
A MATLAB matrix data element.
|
Modifier and Type | Field and Description |
---|---|
protected static ThreadLocal<Integer> |
complexArrayCountLocal
A
ComplexArray counter local to the current thread. |
protected static ThreadLocal<Integer> |
integerArrayCountLocal
An
IntegerArray counter local to the current thread. |
protected static ThreadLocal<Integer> |
realArrayCountLocal
A
RealArray counter local to the current thread. |
Constructor and Description |
---|
MatlabIoKernel()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
getBytes(ComplexArray complexArray,
String name)
Converts the given
ComplexArray into byte s. |
static byte[] |
getBytes(IntegerArray array,
String name)
Converts the given
IntegerArray into byte s. |
static byte[] |
getBytes(RealArray array,
String name)
Converts the given
RealArray into byte s. |
<T extends Array<T,?>> |
getBytes(T array)
Converts an
Array into byte s. |
protected static int |
getDataElementSize(MatlabIo.DataType type,
int nElts)
Gets the data element size, given the
MatlabIo.DataType and the number of elements. |
static byte[] |
getHeaderBytes(String text)
Gets the binary representation of the MAT-file header.
|
<T extends Array<T,E>,E> |
getMatBytes(T... arrays)
Converts the given
Array s into MAT-file format. |
<T extends Array<T,?>> |
parse(byte[] data)
Parses an
Array from byte s. |
Array<?,?>[] |
parseMat(byte[] data)
Parses a series of
Array s from MAT-file format. |
protected static void |
writeDataElementBody(ByteBuffer bb,
byte[] arr)
Writes the data element body.
|
protected static void |
writeDataElementBody(ByteBuffer bb,
double[] arr)
Writes the data element body.
|
protected static void |
writeDataElementBody(ByteBuffer bb,
int[] arr)
Writes the data element body.
|
protected static void |
writeDataElementHeader(ByteBuffer bb,
MatlabIo.DataType type,
int nElts)
Writes the data element header, given the
MatlabIo.DataType and the number of elements. |
protected static final ThreadLocal<Integer> realArrayCountLocal
RealArray
counter local to the current thread.protected static final ThreadLocal<Integer> complexArrayCountLocal
ComplexArray
counter local to the current thread.protected static final ThreadLocal<Integer> integerArrayCountLocal
IntegerArray
counter local to the current thread.public <T extends Array<T,?>> byte[] getBytes(T array)
ArrayIoKernel
Array
into byte
s.getBytes
in interface ArrayIoKernel
T
- the Array
type.array
- the Array
.byte
s.public <T extends Array<T,?>> T parse(byte[] data)
ArrayIoKernel
Array
from byte
s.parse
in interface ArrayIoKernel
T
- the inferred Array
type.data
- the byte
s.Array
.public static final byte[] getHeaderBytes(String text)
public static final byte[] getBytes(RealArray array, String name)
RealArray
into byte
s.public static final byte[] getBytes(ComplexArray complexArray, String name)
ComplexArray
into byte
s.public static final byte[] getBytes(IntegerArray array, String name)
IntegerArray
into byte
s.public <T extends Array<T,E>,E> byte[] getMatBytes(T... arrays)
Array
s into MAT-file format.protected static final void writeDataElementHeader(ByteBuffer bb, MatlabIo.DataType type, int nElts)
MatlabIo.DataType
and the number of elements.protected static final void writeDataElementBody(ByteBuffer bb, byte[] arr)
protected static final void writeDataElementBody(ByteBuffer bb, int[] arr)
protected static final void writeDataElementBody(ByteBuffer bb, double[] arr)
protected static final int getDataElementSize(MatlabIo.DataType type, int nElts)
MatlabIo.DataType
and the number of elements.