Parent Directory | Revision Log

Revision **1129** -
(**show annotations**)
(**download**)
(**as text**)

*Sat Jan 13 11:40:59 2007 UTC*
(14 years ago)
by *johnpye*

File MIME type: text/x-chdr

File size: 1979 byte(s)

File MIME type: text/x-chdr

File size: 1979 byte(s)

Added integrator_write_matrix routine to allow integrator matrices to be written out. Modified integrator in PyGTK to output this matrix to a file in /tmp in the case where Integrator::solve fails. Fixed a bug in densematrix_write_mmio. The current implementation of integrator_write_matrix might not be quite right yet... needs some more thought.

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 | *//** |

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 | #ifndef ASC_DENSEMTX_H |

48 | #define ASC_DENSEMTX_H |

49 | |

50 | #include <stdio.h> |

51 | |

52 | typedef struct DenseMatrixStruct{ |

53 | double **data; |

54 | unsigned nrows; |

55 | unsigned ncols; |

56 | } DenseMatrix; |

57 | |

58 | #define DENSEMATRIX_NROWS(M) ((M).nrows) |

59 | #define DENSEMATRIX_NCOLS(M) ((M).ncols) |

60 | #define DENSEMATRIX_ELEM(M,I,J) ((M).data[I][I]) |

61 | #define DENSEMATRIX_DATA(M) ((M).data) |

62 | #define DENSEMATRIX_EMPTY (DenseMatrix){NULL,0,0} |

63 | |

64 | DenseMatrix densematrix_create_empty(); |

65 | DenseMatrix densematrix_create(unsigned nrows, unsigned ncols); |

66 | void densematrix_destroy(DenseMatrix matrix); |

67 | void densematrix_write_mmio(DenseMatrix matrix, FILE *fp); |

68 | |

69 | #endif |

john.pye@anu.edu.au | ViewVC Help |

Powered by ViewVC 1.1.22 |