1 |
/** @file |
2 |
Object-orient wrapper for the ASCEND 'mtx' data structure and |
3 |
related methods. Primary for use in debugging models and/or exporting |
4 |
matrices to other programs. |
5 |
|
6 |
Accessing mtx_matrix_t objects through this interface should add only a |
7 |
single dereference; this is to be a very lightweight wrapper only. |
8 |
|
9 |
Note that mtx_matrix_t objects contain a great deal more information than |
10 |
most Matrix data structures. They include space to store block decomposition |
11 |
and row/column permutation information that help with efficient solving |
12 |
of matrix problems like A*x=b. |
13 |
|
14 |
When a matrix is exported (such as writeMatrixMarket) this information will |
15 |
mostly be lost in the resulting file. |
16 |
|
17 |
Some interesting possibilities exist in exporting to numpy/numarray formats |
18 |
as these do include some support for permutations and so on. |
19 |
|
20 |
@NOTE we don't use iostream for input/output here as (a) it's not compatible |
21 |
with the underlying C routines and (b) we want to wrap the FILE* objects |
22 |
and allow access to them using Python's file methods, eg: |
23 |
http://www.swig.org/Doc1.1/HTML/Python.htm |
24 |
(search down to " Converting a Python file object to a FILE *") |
25 |
@ENDNOTE |
26 |
*/ |
27 |
#ifndef ASCXX_MATRIX_H |
28 |
#define ASCXX_MATRIX_H |
29 |
|
30 |
extern "C"{ |
31 |
#include <ascend/linear/mtx.h> |
32 |
} |
33 |
|
34 |
#include <cstdio> |
35 |
#include <string> |
36 |
#include <vector> |
37 |
|
38 |
class Matrix{ |
39 |
protected: |
40 |
mtx_matrix_t M; /* mtx_matrix_t is a typedef for 'struct mtx_header*' */ |
41 |
public: |
42 |
|
43 |
Matrix(); |
44 |
Matrix(const Matrix &M); |
45 |
|
46 |
Matrix(mtx_matrix_t M); |
47 |
|
48 |
int write(FILE *fp, const std::string &format) const; |
49 |
std::vector<unsigned> size() const; |
50 |
}; |
51 |
|
52 |
#endif |