/[ascend]/trunk/ascend/linear/densemtx.h
ViewVC logotype

Contents of /trunk/ascend/linear/densemtx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2064 - (show annotations) (download) (as text)
Mon Jul 6 12:03:36 2009 UTC (11 years ago) by jpye
File MIME type: text/x-chdr
File size: 2268 byte(s)
Trying to solve some bugs with sensitivity external method.
1 /* ASCEND modelling environment
2 Copyright (C) 2007 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//** @file
19 Dense matrix module, as used by the LSODE Integrator in ASCEND.
20
21 @example
22 Usage of the DenseMatrix object:
23
24 @code
25 DenseMatrix M;
26 M = densmatrix_create(2,2);
27 DENSEMATRIX_ELEM(M,0,0) = 1;
28 DENSEMATRIX_ELEM(M,0,1) = 2;
29 DENSEMATRIX_ELEM(M,1,0) = 3;
30 DENSEMATRIX_ELEM(M,1,1) = 4;
31 densematrix_write_mmio(M,stdout);
32 densematrix_destroy(M);
33 @endcode
34
35 Represents the matrix
36
37 @code
38 [ 1, 2;
39 3, 4 ]
40 @code
41 @endexample
42 *//*
43 by John Pye, Jan 2007. Pulled out the routines from lsode.c and added
44 a file export function so that these matrices can be viewed using outside
45 tools.
46
47 Also using these routines in the external methods 'finitediff' and 'sensitivity'.
48 */
49 #ifndef ASC_DENSEMTX_H
50 #define ASC_DENSEMTX_H
51
52 #include <stdio.h>
53
54 #include <ascend/utilities/config.h>
55 #include <ascend/utilities/ascConfig.h>
56
57 /** @addtogroup linear Linear
58 @{
59 */
60
61 typedef struct DenseMatrixStruct{
62 double **data;
63 unsigned nrows;
64 unsigned ncols;
65 } DenseMatrix;
66
67 #define DENSEMATRIX_NROWS(M) ((M).nrows)
68 #define DENSEMATRIX_NCOLS(M) ((M).ncols)
69 #define DENSEMATRIX_ELEM(M,I,J) ((M).data[I][J])
70 #define DENSEMATRIX_DATA(M) ((M).data)
71 #define DENSEMATRIX_EMPTY (DenseMatrix){NULL,0,0}
72
73 ASC_DLLSPEC DenseMatrix densematrix_create_empty();
74 ASC_DLLSPEC DenseMatrix densematrix_create(unsigned nrows, unsigned ncols);
75 ASC_DLLSPEC void densematrix_destroy(DenseMatrix matrix);
76
77 #ifdef ASC_WITH_MMIO
78 ASC_DLLSPEC void densematrix_write_mmio(DenseMatrix matrix, FILE *fp);
79 #endif
80
81 /* @} */
82
83 #endif

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