Mtx

From ASCEND

Jump to: navigation, search

mtx is the sparse matrix library used by ASCEND. The routines provide a lot of functionality for tracking block decompositions and reorderings of matrices, but not much in the way of general end-user routines of the type provided by MATLAB and SciPy.

See also linsol and linsolqr.

Contents

[edit] Example code

The following would probably produce a 10 x 10 identity matrix:

mtx_matrix_t M;
M = mtx_create();
mtx_set_order(M,10);
mtx_clear(M);
mtx_coord_t c;
for(int i=0;i<10;++i){
    mtx_set_value(M,mtx_coord(c,i,i),1.0);
}

[edit] Operations on matrices

  • rank using linsolqr
  • solution of A x = b using linsolqr
  • block partitioning
  • evaluation of A x
  • permuting rows and columns

mtx currently does not provide arithmetic operations on matrices, although some sub-operations are provided, for example the product of a row and a sparse vector.

Some C++ code that implements sparse matrix operations in scipy is available at

http://projects.scipy.org/scipy/scipy/browser/trunk/Lib/sparse/sparsetools/sparsetools.h

[edit] In-memory matrix translation

mtx matrices can be converted in-memory to the CSparse format using the routines in mtx_csparse.h header file.

The CSparse library permits matrix arithmetic (missing in mtx) and LU and QR decomposition, and can convert from triplet to/from compressed column formats. It is by the author of UMFPACK, which is the linear solver in MATLAB.

http://www.cise.ufl.edu/research/sparse/CSparse/

[edit] File input/output

mtx provides the ability to read and write matrices from a number of file formats, allowing the extra functionality of other tools to be used when there is functionality missing in the library.

The most recent export format added has been MatrixMarket via the mtx_write_region_mmio(M) function.

Personal tools