/[ascend]/trunk/pygtk/matrix.cpp
ViewVC logotype

Contents of /trunk/pygtk/matrix.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1380 - (show annotations) (download) (as text)
Fri Apr 6 04:07:32 2007 UTC (12 years, 10 months ago) by jpye
File MIME type: text/x-c++src
File size: 1382 byte(s)
Fixed build problem on MinGW GCC 3.4.2
Fixed problem with font in IPython console on Windows
Some attempts to fix problems with FILE* support in Python bindings
gfortran is now the preferred FORTRAN compiler.
Comment out failing FILE* tests for the moment.
1 extern "C"{
2 #include <utilities/config.h>
3 #include <utilities/ascPanic.h>
4 }
5
6 #include <stdexcept>
7 #include <sstream>
8
9 #include "matrix.h"
10
11 using namespace std;
12
13 Matrix::Matrix() : M(NULL){
14 // nothing else
15 }
16
17 Matrix::Matrix(const Matrix &old) : M(old.M){
18 asc_assert(M!=NULL);
19 }
20
21 Matrix::Matrix(mtx_matrix_t M) : M(M){
22 asc_assert(M!=NULL);
23 }
24
25 /**
26 Write out a matrix to a file, in a format by the user
27
28 @param format format in which to write output ("mtx","debug", others as
29 implemented)
30
31 Return 0 on success, 1 on error
32 */
33 int
34 Matrix::write(FILE *fp, const string &format) const{
35
36 CONSOLE_DEBUG("HERE IN MATRIX::WRITE");
37
38 CONSOLE_DEBUG("Writing matrix in format '%s'",format.c_str());
39
40 if(M==NULL)throw runtime_error("Matrix is NULL");
41 if(fp==NULL)throw runtime_error("File is NULL");
42
43 if(format=="matlab"){
44 mtx_write_region_matlab(fp, M, mtx_ENTIRE_MATRIX);
45 #ifdef ASC_WITH_MMIO
46 }else if(format=="mtx"||format=="mmio"||format=="matrixmarket"){
47 return mtx_write_region_mmio(fp, M, mtx_ENTIRE_MATRIX);
48 #endif
49 }else if(format=="debug"){
50 mtx__debug_output(fp, M);
51 }else{
52 throw runtime_error("Unrecognised export format requested");
53 }
54
55 return 0;
56 }
57
58 /**
59 Return the size of the mtx (the entire matrix)
60 */
61 vector<unsigned>
62 Matrix::size() const{
63 asc_assert(M!=NULL);
64 vector<unsigned> v;
65 v.push_back(mtx_order(M));
66 v.push_back(mtx_order(M));
67 return v;
68 }
69
70
71
72
73

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22