Write

The method analyzes the matrix contents, determines its structural type (symmetric, Hermitian, triangular, banded, and so on), and writes the contents of the matrix to the open file in accordance with the selected storage method.

long matrix::Write(
   int                file_handle,     // file handle opened to write
   ENUM_BLAS_STORAGE  storage_method   // how to write
   );

Parameters

file_handle

[in]  File descriptor returned by FileOpen().

storage_method

[in] ENUM_BLAS_STORAGE enumeration value which determines the method for writing.

Return Value

Returns the number of bytes written to the file. Or -1 in case of error.

Note

Writing is performed from the current file position. The file must be opened as binary for writing (FILE_BIN|FILE_WRITE flags). First, the MqlMatrixInfo structure is written, followed by the matrix contents according to the selected storage method. The matrix must have a nonzero size.

If the BLASSTORAGE_GENERAL method is selected, the matrix is stored as is.

If the BLASSTORAGE_COMPACT method is selected, the matrix is stored as compactly as possible. For example, if the matrix is identified as general band (GB), the size (kl+ku+1)*cols is calculated. If this size is smaller than rows*cols, the matrix is written as general band; otherwise, it is written as general (GE).

If the BLASSTORAGE_BAND method is selected and kl>=0 and ku>=0, the matrix is written as band: general band (GB), symmetric band (SB), Hermitian band (HB), or triangular band (TB).

ENUM_BLAS_STORAGE

Enumeration defining the matrix storage method.

ID

Description

BLASSTORAGE_GENERAL

Store as is

BLASSTORAGE_COMPACT      

Compact store

BLASSTORAGE_BAND

Band store