matout

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MATLABcomplexBit uint32 = 0x00000700
	MATLABglobalBit         = 0x00000400
	MATLABlogicalBit        = 0x00002000
)

bits for ArrayFlags. complexBit indicates whether the array containts complex numbers or not. globalBit indicates whether the array is defined as the global variable or not. logicalBit indicates whether the array containts logical values or not?

Variables

This section is empty.

Functions

This section is empty.

Types

type MATLABArray

type MATLABArray struct {
	// contains filtered or unexported fields
}

The structure for array in MATLAB, which consists of header and data. []intXX, []uintXX, []floatXX are available for data.

func CreateMATLABArray

func CreateMATLABArray(data interface{}) *MATLABArray

The function to create MATLAB array

func CreateMATLABArrayFlags

func CreateMATLABArrayFlags(x uint32, t MATLABArrayType, complex bool, global bool, logical bool) *MATLABArray

func (*MATLABArray) ToBytes

func (d *MATLABArray) ToBytes(buf *MATLABBuffer) *MATLABBuffer

type MATLABArrayType

type MATLABArrayType uint32
const (
	MATLABArrayTypeUnknown MATLABArrayType = iota
)

type MATLABBuffer

type MATLABBuffer struct {
	// contains filtered or unexported fields
}

The structure of Buffer stream. `buf` is a pointer of bytes.Buffer. `endian` is to indicate LittleEndian or BigEndian. Note: BigEndian does not work until now.

func NewMATLABBuffer

func NewMATLABBuffer(buf MATLABWriter, endian binary.ByteOrder) *MATLABBuffer

The function to create MATLABBuffer. `size` is the capacity of buffer.

func (*MATLABBuffer) Padding

func (b *MATLABBuffer) Padding(numBytes int) *MATLABBuffer

The method to write zero to the buffer. numBytes is the number of bytes.

func (*MATLABBuffer) Write

func (b *MATLABBuffer) Write(data interface{}) *MATLABBuffer

The method to write data to the buffer. The data can be intXX, uintXX, floatXX and their slices, where XX is the number of bits.

func (*MATLABBuffer) WriteByte

func (b *MATLABBuffer) WriteByte(data byte) *MATLABBuffer

The method to write a byte data.

func (*MATLABBuffer) WriteString

func (b *MATLABBuffer) WriteString(s string) *MATLABBuffer

The method to write a string to the buffer

type MATLABByteInterface

type MATLABByteInterface interface {
	ToBytes(buf *MATLABBuffer) *MATLABBuffer // the method to write the buffer
	// contains filtered or unexported methods
}

The interface for data which can be written to the buffer. This is used in MATLABMatFile to represent data elements.

type MATLABDataElementHeader

type MATLABDataElementHeader struct {
	// contains filtered or unexported fields
}

MATLABDataElementHeader is a struct for the header of data element. dataType represents the format of data such as uint8, int16, etc. numOfDataByte is a length of data size. The size of header should be 8 bytes in usual. But if the data length is less than 4 bytes, the size of header should be 4 by compressing datatype and numofdatabyte to uint16. At that time, the flag `smallsize` becomes true.

func (*MATLABDataElementHeader) ToBytes

type MATLABDataType

type MATLABDataType uint32
const (
	MATLABDataTypeUnknown MATLABDataType = iota
)

type MATLABHeader

type MATLABHeader struct {
	// contains filtered or unexported fields
}

MATLABHeader is a struct for the header of a matfile. The level is a version of matfile. In many cases, the level is "5.0". The platform is the name of OS. By using "runtime" package, it can be given by runtime.GOOS. The created the date when it creates, which is usually `time.Now()` as "time" package. The version is to be set as 0x0100. The endiaanIndicator is a string to indicate the endianness. If the endianness is the little endian, it becomes "IM". If it is the big endian, the indicator is "MI".

func (*MATLABHeader) ToBytes

func (h *MATLABHeader) ToBytes(buf *MATLABBuffer) *MATLABBuffer

get a byte buffer for the header

type MATLABMatFile

type MATLABMatFile struct {
	// contains filtered or unexported fields
}

The structure of Matfile, which consists of header and elements. The elements are a list of data elements such as matrix and sparse matrix.

func CreateMATLABMatFile

func CreateMATLABMatFile(littleEndian bool) *MATLABMatFile

The function to create MatFile. `endian` is

func (*MATLABMatFile) AddElement

func (m *MATLABMatFile) AddElement(e MATLABByteInterface)

The method to add data element.

func (*MATLABMatFile) ToBytes

func (m *MATLABMatFile) ToBytes(buf *MATLABBuffer) *MATLABBuffer

The method to write the buffer

type MATLABMatrix

type MATLABMatrix struct {
	// contains filtered or unexported fields
}

The structure for MATLAB matrix which consists of header, arrayFlags, dimensionArray, arrayName and realValue. `complexValue` is needed to be implemented in future.

func CreateMATLABMatrix

func CreateMATLABMatrix(dims interface{}, name string, pr interface{}) *MATLABMatrix

func (*MATLABMatrix) ToBytes

func (d *MATLABMatrix) ToBytes(buf *MATLABBuffer) *MATLABBuffer

type MATLABPadding

type MATLABPadding struct {
	// contains filtered or unexported fields
}

The struct to represent zero padding. This is added to the last of each data element so that the end of data element becomes the multiple of 8.

func (*MATLABPadding) ToBytes

func (mb *MATLABPadding) ToBytes(b *MATLABBuffer) *MATLABBuffer

type MATLABSparseMatrix

type MATLABSparseMatrix struct {
	// contains filtered or unexported fields
}

The structure for MATLAB sparse matrix. The format is CSC (compressed sparse column) with 0 origin. In the context of CSC, rowIndex indicates rowind. columnIndex indicates colptr. Although the origin of array index in Matlab is 1, the matfile should be the zero origin.

func CreateMATLABSparseMatrix

func CreateMATLABSparseMatrix(dims interface{}, name string, nnz int,
	ir interface{}, jc interface{}, pr interface{}) *MATLABSparseMatrix

The function to write

func (*MATLABSparseMatrix) ToBytes

func (d *MATLABSparseMatrix) ToBytes(buf *MATLABBuffer) *MATLABBuffer

type MATLABString

type MATLABString struct {
	// contains filtered or unexported fields
}

The structure for a string in MATLAB.

func CreateMATLABDataString

func CreateMATLABDataString(data string) *MATLABString

The function to create MATLAB string

func (*MATLABString) ToBytes

func (d *MATLABString) ToBytes(buf *MATLABBuffer) *MATLABBuffer

type MATLABWriter

type MATLABWriter interface {
	io.Writer
	WriteByte(x byte) error
	WriteString(x string) (int, error)
}

The interface for Writer which is used in MATLABBuffer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL