Mercurial > octave
annotate libinterp/dldfcn/__ode15__.cc @ 23584:7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
* ov.h (is_map): Use OCTAVE_DEPRECATED macro around function.
* ov.h (isstruct): New function.
* structdemo.cc, __luinc__.cc, __magick_read__.cc, cellfun.cc, data.cc,
debug.cc, error.cc, graphics.cc, load-save.cc, ls-mat5.cc, mex.cc,
oct-lvalue.h, oct-stream.cc, variables.cc, __eigs__.cc, __ode15__.cc,
ov-base.h, ov-class.cc, ov-class.h, ov-classdef.h, ov-java.h, ov-struct.cc,
ov-struct.h, ov-usr-fcn.cc, ov.h, pt-eval.cc, pt-tm-const.cc:
Replace instances of is_map with isstruct.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 13 Jun 2017 09:20:08 -0700 |
parents | 80c42f4cca13 |
children | 0549061d35b9 |
rev | line source |
---|---|
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1 /* |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
2 |
23221
debe0c7dcefc
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23086
diff
changeset
|
3 Copyright (C) 2016-2017 Francesco Faccio <francesco.faccio@mail.polimi.it> |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
4 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
5 This file is part of Octave. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
6 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or (at |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
10 your option) any later version. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
11 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
15 General Public License for more details. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
16 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
20 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
21 */ |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
22 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
24 # include "config.h" |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
25 #endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
26 |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
27 #include "dColVector.h" |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
28 #include "dMatrix.h" |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
29 #include "dSparse.h" |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
30 |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
23022
diff
changeset
|
31 #include "Cell.h" |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
32 #include "defun-dld.h" |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
33 #include "error.h" |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
23022
diff
changeset
|
34 #include "errwarn.h" |
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
23022
diff
changeset
|
35 #include "oct-map.h" |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
36 #include "ov.h" |
23024
a6a7b054e4ba
Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents:
23022
diff
changeset
|
37 #include "ovl.h" |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
38 #include "parse.h" |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
39 |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
40 #if defined (HAVE_SUNDIALS) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
41 |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
42 # if defined (HAVE_IDA_IDA_H) |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
43 # include <ida/ida.h> |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
44 # include <ida/ida_dense.h> |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
45 # endif |
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
46 |
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
47 # if defined (HAVE_IDA_IDA_KLU_H) |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
48 # include <ida/ida_klu.h> |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
49 # include <sundials/sundials_sparse.h> |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
50 # endif |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
51 |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
52 # if defined (HAVE_NVECTOR_NVECTOR_SERIAL_H) |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
53 # include <nvector/nvector_serial.h> |
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
54 # endif |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
55 |
22915
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
56 static inline realtype * |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
57 nv_data_s (N_Vector& v) |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
58 { |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
59 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
60 // Disable warning from GCC about old-style casts in Sundials macro |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
61 // expansions. Do this in a function so that this diagnostic may still |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
62 // be enabled for the rest of the file. |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
63 #pragma GCC diagnostic push |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
64 #pragma GCC diagnostic ignored "-Wold-style-cast" |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
65 #endif |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
66 |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
67 return NV_DATA_S (v); |
23085
dffa2b8c9482
maint: strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23075
diff
changeset
|
68 |
22915
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
69 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC) |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
70 // Restore prevailing warning state for remainder of the file. |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
71 #pragma GCC diagnostic pop |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
72 #endif |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
73 } |
7766e3ef6c69
* __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents:
22914
diff
changeset
|
74 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
75 namespace octave |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
76 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
77 class IDA |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
78 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
79 public: |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
80 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
81 typedef |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
82 ColumnVector (*DAERHSFuncIDA) (const ColumnVector& x, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
83 const ColumnVector& xdot, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
84 realtype t, octave_function *idaf); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
85 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
86 typedef |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
87 Matrix (*DAEJacFuncDense) (const ColumnVector& x, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
88 const ColumnVector& xdot, realtype t, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
89 realtype cj, octave_function *idaj); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
90 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
91 typedef |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
92 SparseMatrix (*DAEJacFuncSparse) (const ColumnVector& x, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
93 const ColumnVector& xdot, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
94 realtype t, realtype cj, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
95 octave_function *idaj); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
96 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
97 typedef |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
98 Matrix (*DAEJacCellDense) (Matrix *dfdy, Matrix *dfdyp, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
99 realtype cj); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
100 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
101 typedef |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
102 SparseMatrix (*DAEJacCellSparse) (SparseMatrix *dfdy, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
103 SparseMatrix *dfdyp, realtype cj); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
104 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
105 //Default |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
106 IDA (void) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
107 : t0 (0.0), y0 (), yp0 (), havejac (false), havejacfun (false), |
22912
1b5e7f2bd38d
* __ode15__.cc: Avoid NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
22911
diff
changeset
|
108 havejacsparse (false), mem (0), num (), ida_fun (0), |
1b5e7f2bd38d
* __ode15__.cc: Avoid NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
22911
diff
changeset
|
109 ida_jac (0), dfdy (0), dfdyp (0), spdfdy (0), |
1b5e7f2bd38d
* __ode15__.cc: Avoid NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
22911
diff
changeset
|
110 spdfdyp (0), fun (0), jacfun (0), jacspfun (0), |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
111 jacdcell (0), jacspcell (0) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
112 { } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
113 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
114 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
115 IDA (realtype t, ColumnVector y, ColumnVector yp, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
116 octave_function *ida_fcn, DAERHSFuncIDA daefun) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
117 : t0 (t), y0 (y), yp0 (yp), havejac (false), havejacfun (false), |
22912
1b5e7f2bd38d
* __ode15__.cc: Avoid NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
22911
diff
changeset
|
118 havejacsparse (false), mem (0), num (), ida_fun (ida_fcn), |
1b5e7f2bd38d
* __ode15__.cc: Avoid NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
22911
diff
changeset
|
119 ida_jac (0), dfdy (0), dfdyp (0), spdfdy (0), |
1b5e7f2bd38d
* __ode15__.cc: Avoid NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
22911
diff
changeset
|
120 spdfdyp (0), fun (daefun), jacfun (0), jacspfun (0), |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
121 jacdcell (0), jacspcell (0) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
122 { } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
123 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
124 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
125 ~IDA (void) { IDAFree (&mem); } |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
126 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
127 IDA& |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
128 set_jacobian (octave_function *jac, DAEJacFuncDense j) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
129 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
130 jacfun = j; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
131 ida_jac = jac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
132 havejac = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
133 havejacfun = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
134 havejacsparse = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
135 return *this; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
136 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
137 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
138 IDA& |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
139 set_jacobian (octave_function *jac, DAEJacFuncSparse j) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
140 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
141 jacspfun = j; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
142 ida_jac = jac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
143 havejac = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
144 havejacfun = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
145 havejacsparse = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
146 return *this; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
147 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
148 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
149 IDA& |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
150 set_jacobian (Matrix *dy, Matrix *dyp, DAEJacCellDense j) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
151 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
152 jacdcell = j; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
153 dfdy = dy; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
154 dfdyp = dyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
155 havejac = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
156 havejacfun = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
157 havejacsparse = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
158 return *this; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
159 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
160 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
161 IDA& |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
162 set_jacobian (SparseMatrix *dy, SparseMatrix *dyp, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
163 DAEJacCellSparse j) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
164 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
165 jacspcell = j; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
166 spdfdy = dy; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
167 spdfdyp = dyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
168 havejac = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
169 havejacfun = false; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
170 havejacsparse = true; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
171 return *this; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
172 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
173 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
174 void set_userdata (void); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
175 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
176 void initialize (void); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
177 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
178 static ColumnVector NVecToCol (N_Vector& v, long int n); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
179 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
180 static N_Vector ColToNVec (const ColumnVector& data, long int n); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
181 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
182 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
183 set_up (void); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
184 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
185 void |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
186 set_tolerance (ColumnVector& abstol, realtype reltol); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
187 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
188 void |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
189 set_tolerance (realtype abstol, realtype reltol); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
190 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
191 static int |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
192 resfun (realtype t, N_Vector yy, N_Vector yyp, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
193 N_Vector rr, void *user_data); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
194 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
195 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
196 resfun_impl (realtype t, N_Vector& yy, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
197 N_Vector& yyp, N_Vector& rr); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
198 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
199 static int |
22914
b7ffd93b8d06
* __ode15__.cc: Avoid unused parameter warnings.
John W. Eaton <jwe@octave.org>
parents:
22913
diff
changeset
|
200 jacdense (long int Neq, realtype t, realtype cj, N_Vector yy, |
b7ffd93b8d06
* __ode15__.cc: Avoid unused parameter warnings.
John W. Eaton <jwe@octave.org>
parents:
22913
diff
changeset
|
201 N_Vector yyp, N_Vector, DlsMat JJ, void *user_data, |
b7ffd93b8d06
* __ode15__.cc: Avoid unused parameter warnings.
John W. Eaton <jwe@octave.org>
parents:
22913
diff
changeset
|
202 N_Vector, N_Vector, N_Vector) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
203 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
204 IDA *self = static_cast <IDA *> (user_data); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
205 self->jacdense_impl (Neq, t, cj, yy, yyp, JJ); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
206 return 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
207 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
208 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
209 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
210 jacdense_impl (long int Neq, realtype t, realtype cj, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
211 N_Vector& yy, N_Vector& yyp, DlsMat& JJ); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
212 |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
213 # if defined (HAVE_SUNDIALS_IDAKLU) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
214 static int |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
215 jacsparse (realtype t, realtype cj, N_Vector yy, N_Vector yyp, |
22914
b7ffd93b8d06
* __ode15__.cc: Avoid unused parameter warnings.
John W. Eaton <jwe@octave.org>
parents:
22913
diff
changeset
|
216 N_Vector, SlsMat Jac, void *user_data, N_Vector, |
b7ffd93b8d06
* __ode15__.cc: Avoid unused parameter warnings.
John W. Eaton <jwe@octave.org>
parents:
22913
diff
changeset
|
217 N_Vector, N_Vector) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
218 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
219 IDA *self = static_cast <IDA *> (user_data); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
220 self->jacsparse_impl (t, cj, yy, yyp, Jac); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
221 return 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
222 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
223 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
224 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
225 jacsparse_impl (realtype t, realtype cj, N_Vector& yy, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
226 N_Vector& yyp, SlsMat& Jac); |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
227 #endif |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
228 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
229 void set_maxstep (realtype maxstep); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
230 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
231 void set_initialstep (realtype initialstep); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
232 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
233 bool |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
234 interpolate (int& cont, Matrix& output, ColumnVector& tout, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
235 int refine, realtype tend, bool haveoutputfcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
236 bool haveoutputsel, octave_function *output_fcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
237 ColumnVector& outputsel, bool haveeventfunction, |
23432
e35a5c1233d0
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23221
diff
changeset
|
238 octave_function *event_fcn, ColumnVector& te, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
239 Matrix& ye, ColumnVector& ie, ColumnVector& oldval, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
240 ColumnVector& oldisterminal, ColumnVector& olddir, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
241 int& temp, ColumnVector& yold); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
242 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
243 bool |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
244 outputfun (octave_function *output_fcn, bool haveoutputsel, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
245 const ColumnVector& output, realtype tout, realtype tend, |
22918
0b5d9978d7b1
* __ode15__.cc: Pass std::string arg by const reference.
John W. Eaton <jwe@octave.org>
parents:
22917
diff
changeset
|
246 ColumnVector& outputsel, const std::string& flag); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
247 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
248 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
249 bool |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
250 event (octave_function *event_fcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
251 ColumnVector& te, Matrix& ye, ColumnVector& ie, |
22918
0b5d9978d7b1
* __ode15__.cc: Pass std::string arg by const reference.
John W. Eaton <jwe@octave.org>
parents:
22917
diff
changeset
|
252 realtype tsol, const ColumnVector& y, const std::string& flag, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
253 const ColumnVector& yp, ColumnVector& oldval, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
254 ColumnVector& oldisterminal, ColumnVector& olddir, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
255 int cont, int& temp, realtype told, ColumnVector& yold); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
256 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
257 void set_maxorder (int maxorder); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
258 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
259 octave_value_list |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
260 integrate (const int numt, const ColumnVector& tt, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
261 const ColumnVector& y0, const ColumnVector& yp0, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
262 const int refine, bool haverefine, bool haveoutputfcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
263 octave_function *output_fcn, bool haveoutputsel, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
264 ColumnVector& outputsel, bool haveeventfunction, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
265 octave_function *event_fcn); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
266 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
267 void print_stat (void); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
268 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
269 private: |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
270 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
271 realtype t0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
272 ColumnVector y0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
273 ColumnVector yp0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
274 bool havejac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
275 bool havejacfun; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
276 bool havejacsparse; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
277 void *mem; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
278 int num; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
279 octave_function *ida_fun; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
280 octave_function *ida_jac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
281 Matrix *dfdy; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
282 Matrix *dfdyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
283 SparseMatrix *spdfdy; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
284 SparseMatrix *spdfdyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
285 DAERHSFuncIDA fun; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
286 DAEJacFuncDense jacfun; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
287 DAEJacFuncSparse jacspfun; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
288 DAEJacCellDense jacdcell; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
289 DAEJacCellSparse jacspcell; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
290 }; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
291 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
292 int |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
293 IDA::resfun (realtype t, N_Vector yy, N_Vector yyp, N_Vector rr, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
294 void *user_data) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
295 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
296 IDA *self = static_cast <IDA *> (user_data); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
297 self->resfun_impl (t, yy, yyp, rr); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
298 return 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
299 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
300 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
301 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
302 IDA::resfun_impl (realtype t, N_Vector& yy, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
303 N_Vector& yyp, N_Vector& rr) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
304 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
305 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
306 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
307 ColumnVector y = IDA::NVecToCol (yy, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
308 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
309 ColumnVector yp = IDA::NVecToCol (yyp, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
310 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
311 ColumnVector res = (*fun) (y, yp, t, ida_fun); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
312 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
313 realtype *puntrr = nv_data_s (rr); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
314 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
315 for (octave_idx_type i = 0; i < num; i++) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
316 puntrr[i] = res(i); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
317 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
318 END_INTERRUPT_WITH_EXCEPTIONS; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
319 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
320 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
321 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
322 IDA::set_up (void) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
323 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
324 if (havejacsparse) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
325 { |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
326 # if defined (HAVE_SUNDIALS_IDAKLU) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
327 if (IDAKLU (mem, num, num*num, CSC_MAT) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
328 error ("IDAKLU solver not initialized"); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
329 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
330 IDASlsSetSparseJacFn (mem, IDA::jacsparse); |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
331 # else |
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
332 error ("IDAKLU is not available in this version of Octave"); |
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
333 # endif |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
334 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
335 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
336 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
337 if (IDADense (mem, num) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
338 error ("IDADense solver not initialized"); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
339 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
340 if (havejac && IDADlsSetDenseJacFn (mem, IDA::jacdense) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
341 error ("Dense Jacobian not set"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
342 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
343 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
344 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
345 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
346 IDA::jacdense_impl (long int Neq, realtype t, realtype cj, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
347 N_Vector& yy, N_Vector& yyp, DlsMat& JJ) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
348 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
349 { |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
350 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
351 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
352 ColumnVector y = NVecToCol (yy, Neq); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
353 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
354 ColumnVector yp = NVecToCol (yyp, Neq); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
355 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
356 Matrix jac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
357 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
358 if (havejacfun) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
359 jac = (*jacfun) (y, yp, t, cj, ida_jac); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
360 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
361 jac = (*jacdcell) (dfdy, dfdyp, cj); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
362 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
363 std::copy (jac.fortran_vec (), |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
364 jac.fortran_vec () + jac.numel (), |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
365 JJ->data); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
366 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
367 END_INTERRUPT_WITH_EXCEPTIONS; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
368 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
369 |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
370 # if defined (HAVE_SUNDIALS_IDAKLU) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
371 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
372 IDA::jacsparse_impl (realtype t, realtype cj, N_Vector& yy, N_Vector& yyp, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
373 SlsMat& Jac) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
374 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
375 { |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
376 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
377 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
378 ColumnVector y = NVecToCol (yy, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
379 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
380 ColumnVector yp = NVecToCol (yyp, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
381 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
382 SparseMatrix jac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
383 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
384 if (havejacfun) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
385 jac = (*jacspfun) (y, yp, t, cj, ida_jac); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
386 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
387 jac = (*jacspcell) (spdfdy, spdfdyp, cj); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
388 |
22902
284bbb0328f2
Update odei5{i,s} code for Octave 4.3.0+ and Sundials 2.7.0.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22901
diff
changeset
|
389 SparseSetMatToZero (Jac); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
390 int *colptrs = *(Jac->colptrs); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
391 int *rowvals = *(Jac->rowvals); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
392 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
393 for (int i = 0; i < num + 1; i++) |
22903
51c9eded34ee
Fix access method to sundials 2.7.0 sparse matrix structure.
Carlo de Falco <carlo.defalco@polimi.it>
parents:
22902
diff
changeset
|
394 colptrs[i] = jac.cidx(i); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
395 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
396 for (int i = 0; i < jac.nnz (); i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
397 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
398 rowvals[i] = jac.ridx(i); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
399 Jac->data[i] = jac.data(i); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
400 } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
401 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
402 END_INTERRUPT_WITH_EXCEPTIONS; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
403 } |
23022
305cdc1d444b
* __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents:
22919
diff
changeset
|
404 #endif |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
405 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
406 ColumnVector |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
407 IDA::NVecToCol (N_Vector& v, long int n) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
408 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
409 ColumnVector data (n); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
410 realtype *punt = nv_data_s (v); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
411 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
412 for (octave_idx_type i = 0; i < n; i++) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
413 data(i) = punt[i]; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
414 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
415 return data; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
416 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
417 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
418 N_Vector |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
419 IDA::ColToNVec (const ColumnVector& data, long int n) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
420 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
421 N_Vector v = N_VNew_Serial (n); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
422 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
423 realtype *punt = nv_data_s (v); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
424 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
425 for (octave_idx_type i = 0; i < n; i++) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
426 punt[i] = data(i); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
427 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
428 return v; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
429 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
430 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
431 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
432 IDA::set_userdata (void) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
433 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
434 void *userdata = this; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
435 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
436 if (IDASetUserData (mem, userdata) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
437 error ("User data not set"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
438 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
439 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
440 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
441 IDA::initialize (void) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
442 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
443 num = y0.numel (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
444 mem = IDACreate (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
445 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
446 N_Vector yy = ColToNVec (y0, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
447 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
448 N_Vector yyp = ColToNVec (yp0, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
449 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
450 IDA::set_userdata (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
451 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
452 if (IDAInit (mem, IDA::resfun, t0, yy, yyp) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
453 error ("IDA not initialized"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
454 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
455 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
456 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
457 IDA::set_tolerance (ColumnVector& abstol, realtype reltol) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
458 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
459 N_Vector abs_tol = ColToNVec (abstol, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
460 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
461 if (IDASVtolerances (mem, reltol, abs_tol) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
462 error ("IDA: Tolerance not set"); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
463 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
464 N_VDestroy_Serial (abs_tol); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
465 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
466 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
467 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
468 IDA::set_tolerance (realtype abstol, realtype reltol) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
469 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
470 if (IDASStolerances (mem, reltol, abstol) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
471 error ("IDA: Tolerance not set"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
472 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
473 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
474 octave_value_list |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
475 IDA::integrate (const int numt, const ColumnVector& tspan, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
476 const ColumnVector& y, const ColumnVector& yp, |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
477 const int refine, bool haverefine, bool haveoutputfcn, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
478 octave_function *output_fcn, bool haveoutputsel, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
479 ColumnVector& outputsel, bool haveeventfunction, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
480 octave_function *event_fcn) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
481 { |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
482 // Set up output |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
483 ColumnVector tout, yout (num), ypout (num), ysel (outputsel.numel ()); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
484 ColumnVector ie, te, oldval, oldisterminal, olddir; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
485 Matrix output, ye; |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
486 int cont = 0, temp = 0; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
487 bool status = 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
488 std::string string = ""; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
489 ColumnVector yold = y; |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
490 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
491 realtype tsol = tspan(0); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
492 realtype tend = tspan(numt-1); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
493 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
494 N_Vector yyp = ColToNVec (yp, num); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
495 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
496 N_Vector yy = ColToNVec (y, num); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
497 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
498 // Initialize OutputFcn |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
499 if (haveoutputfcn) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
500 status = IDA::outputfun (output_fcn, haveoutputsel, y, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
501 tsol, tend, outputsel, "init"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
502 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
503 // Initialize Events |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
504 if (haveeventfunction) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
505 status = IDA::event (event_fcn, te, ye, ie, tsol, y, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
506 "init", yp, oldval, oldisterminal, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
507 olddir, cont, temp, tsol, yold); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
508 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
509 if (numt > 2) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
510 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
511 // First output value |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
512 tout.resize (numt); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
513 tout(0) = tsol; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
514 output.resize (numt, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
515 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
516 for (octave_idx_type i = 0; i < num; i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
517 output.elem (0, i) = y.elem (i); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
518 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
519 //Main loop |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
520 for (octave_idx_type j = 1; j < numt && status == 0; j++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
521 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
522 // IDANORMAL already interpolates tspan(j) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
523 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
524 if (IDASolve (mem, tspan (j), &tsol, yy, yyp, IDA_NORMAL) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
525 error ("IDASolve failed"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
526 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
527 yout = NVecToCol (yy, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
528 ypout = NVecToCol (yyp, num); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
529 tout(j) = tsol; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
530 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
531 for (octave_idx_type i = 0; i < num; i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
532 output.elem (j, i) = yout.elem (i); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
533 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
534 if (haveoutputfcn) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
535 status = IDA::outputfun (output_fcn, haveoutputsel, yout, tsol, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
536 tend, outputsel, string); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
537 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
538 if (haveeventfunction) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
539 status = IDA::event (event_fcn, te, ye, ie, tout(j), yout, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
540 string, ypout, oldval, oldisterminal, |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
541 olddir, j, temp, tout(j-1), yold); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
542 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
543 // If integration is stopped, return only the reached steps |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
544 if (status == 1) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
545 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
546 output.resize (j + 1, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
547 tout.resize (j + 1); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
548 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
549 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
550 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
551 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
552 else // numel (tspan) == 2 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
553 { |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
554 // First output value |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
555 tout.resize (1); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
556 tout(0) = tsol; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
557 output.resize (1, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
558 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
559 for (octave_idx_type i = 0; i < num; i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
560 output.elem (0, i) = y.elem (i); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
561 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
562 bool posdirection = (tend > tsol); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
563 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
564 //main loop |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
565 while (((posdirection == 1 && tsol < tend) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
566 || (posdirection == 0 && tsol > tend)) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
567 && status == 0) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
568 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
569 if (IDASolve (mem, tend, &tsol, yy, yyp, IDA_ONE_STEP) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
570 error ("IDASolve failed"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
571 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
572 if (haverefine) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
573 status = IDA::interpolate (cont, output, tout, refine, tend, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
574 haveoutputfcn, haveoutputsel, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
575 output_fcn, outputsel, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
576 haveeventfunction, event_fcn, te, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
577 ye, ie, oldval, oldisterminal, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
578 olddir, temp, yold); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
579 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
580 ypout = NVecToCol (yyp, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
581 cont += 1; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
582 output.resize (cont + 1, num); // This may be not efficient |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
583 tout.resize (cont + 1); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
584 tout(cont) = tsol; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
585 yout = NVecToCol (yy, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
586 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
587 for (octave_idx_type i = 0; i < num; i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
588 output.elem (cont, i) = yout.elem (i); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
589 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
590 if (haveoutputfcn && ! haverefine && tout(cont) < tend) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
591 status = IDA::outputfun (output_fcn, haveoutputsel, yout, tsol, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
592 tend, outputsel, string); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
593 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
594 if (haveeventfunction && ! haverefine && tout(cont) < tend) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
595 status = IDA::event (event_fcn, te, ye, ie, tout(cont), yout, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
596 string, ypout, oldval, oldisterminal, |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
597 olddir, cont, temp, tout(cont-1), yold); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
598 } |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
599 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
600 if (status == 0) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
601 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
602 // Interpolate in tend |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
603 N_Vector dky = N_VNew_Serial (num); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
604 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
605 if (IDAGetDky (mem, tend, 0, dky) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
606 error ("IDA failed to interpolate y"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
607 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
608 tout(cont) = tend; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
609 yout = NVecToCol (dky, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
610 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
611 for (octave_idx_type i = 0; i < num; i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
612 output.elem (cont, i) = yout.elem (i); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
613 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
614 // Plot final value |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
615 if (haveoutputfcn) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
616 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
617 status = IDA::outputfun (output_fcn, haveoutputsel, yout, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
618 tend, tend, outputsel, string); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
619 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
620 // Events during last step |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
621 if (haveeventfunction) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
622 status = IDA::event (event_fcn, te, ye, ie, tend, yout, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
623 string, ypout, oldval, oldisterminal, |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
624 olddir, cont, temp, tout(cont-1), |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
625 yold); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
626 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
627 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
628 N_VDestroy_Serial (dky); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
629 } |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
630 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
631 // Cleanup plotter |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
632 status = IDA::outputfun (output_fcn, haveoutputsel, yout, tend, tend, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
633 outputsel, "done"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
634 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
635 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
636 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
637 return ovl (tout, output, te, ye, ie); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
638 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
639 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
640 bool |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
641 IDA::event (octave_function *event_fcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
642 ColumnVector& te, Matrix& ye, ColumnVector& ie, |
22918
0b5d9978d7b1
* __ode15__.cc: Pass std::string arg by const reference.
John W. Eaton <jwe@octave.org>
parents:
22917
diff
changeset
|
643 realtype tsol, const ColumnVector& y, const std::string& flag, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
644 const ColumnVector& yp, ColumnVector& oldval, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
645 ColumnVector& oldisterminal, ColumnVector& olddir, int cont, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
646 int& temp, realtype told, ColumnVector& yold) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
647 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
648 bool status = 0; |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
649 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
650 octave_value_list args = ovl (tsol, y, yp); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
651 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
652 // cont is the number of steps reached by the solver |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
653 // temp is the number of events registered |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
654 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
655 if (flag == "init") |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
656 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23024
diff
changeset
|
657 octave_value_list output = octave::feval (event_fcn, args, 3); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
658 oldval = output(0).vector_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
659 oldisterminal = output(1).vector_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
660 olddir = output(2).vector_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
661 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
662 else if (flag == "") |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
663 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
664 ColumnVector index (0); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23024
diff
changeset
|
665 octave_value_list output = octave::feval (event_fcn, args, 3); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
666 ColumnVector val = output(0).vector_value (); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
667 ColumnVector isterminal = output(1).vector_value (); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
668 ColumnVector dir = output(2).vector_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
669 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
670 // Get the index of the changed values |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
671 for (octave_idx_type i = 0; i < val.numel (); i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
672 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
673 if ((val(i) > 0 && oldval(i) < 0 && dir(i) != -1) // increasing |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
674 || (val(i) < 0 && oldval(i) > 0 && dir(i) != 1)) // decreasing |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
675 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
676 index.resize (index.numel () + 1); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
677 index (index.numel () - 1) = i; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
678 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
679 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
680 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
681 if (cont == 1 && index.numel () > 0) // Events in first step |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
682 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
683 temp = 1; // register only the first event |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
684 te.resize (1); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
685 ye.resize (1, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
686 ie.resize (1); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
687 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
688 // Linear interpolation |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
689 ie(0) = index(0); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
690 te(0) = tsol - val (index(0)) * (tsol - told) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
691 / (val (index(0)) - oldval (index(0))); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
692 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
693 ColumnVector ytemp |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
694 = y - ((tsol - te(0)) * (y - yold) / (tsol - told)); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
695 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
696 for (octave_idx_type i = 0; i < num; i++) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
697 ye.elem (0, i) = ytemp.elem (i); |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
698 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
699 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
700 else if (index.numel () > 0) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
701 // Not first step: register all events and test if stop integration or not |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
702 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
703 te.resize (temp + index.numel ()); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
704 ye.resize (temp + index.numel (), num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
705 ie.resize (temp + index.numel ()); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
706 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
707 for (octave_idx_type i = 0; i < index.numel (); i++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
708 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
709 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
710 if (isterminal (index(i)) == 1) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
711 status = 1; // Stop integration |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
712 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
713 // Linear interpolation |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
714 ie(temp+i) = index(i); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
715 te(temp+i) = tsol - val(index(i)) * (tsol - told) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
716 / (val(index(i)) - oldval(index(i))); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
717 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
718 ColumnVector ytemp |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
719 = y - (tsol - te (temp + i)) * (y - yold) / (tsol - told); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
720 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
721 for (octave_idx_type j = 0; j < num; j++) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
722 ye.elem (temp + i, j) = ytemp.elem (j); |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
723 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
724 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
725 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
726 temp += index.numel (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
727 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
728 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
729 // Update variables |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
730 yold = y; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
731 told = tsol; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
732 olddir = dir; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
733 oldval = val; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
734 oldisterminal = isterminal; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
735 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
736 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
737 return status; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
738 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
739 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
740 bool |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
741 IDA::interpolate (int& cont, Matrix& output, ColumnVector& tout, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
742 int refine, realtype tend, bool haveoutputfcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
743 bool haveoutputsel, octave_function *output_fcn, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
744 ColumnVector& outputsel, bool haveeventfunction, |
23432
e35a5c1233d0
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23221
diff
changeset
|
745 octave_function *event_fcn, ColumnVector& te, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
746 Matrix& ye, ColumnVector& ie, ColumnVector& oldval, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
747 ColumnVector& oldisterminal, ColumnVector& olddir, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
748 int& temp, ColumnVector& yold) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
749 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
750 realtype h = 0, tcur = 0; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
751 bool status = 0; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
752 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
753 N_Vector dky = N_VNew_Serial (num); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
754 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
755 N_Vector dkyp = N_VNew_Serial (num); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
756 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
757 ColumnVector yout (num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
758 ColumnVector ypout (num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
759 std::string string = ""; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
760 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
761 if (IDAGetLastStep (mem, &h) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
762 error ("IDA failed to return last step"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
763 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
764 if (IDAGetCurrentTime (mem, &tcur) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
765 error ("IDA failed to return the current time"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
766 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
767 realtype tin = tcur - h; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
768 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
769 realtype step = h / refine; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
770 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
771 for (octave_idx_type i = 1; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
772 i < refine && tin + step * i < tend && status == 0; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
773 i++) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
774 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
775 if (IDAGetDky (mem, tin + step*i, 0, dky) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
776 error ("IDA failed to interpolate y"); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
777 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
778 if (IDAGetDky (mem, tin + step*i, 1, dkyp) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
779 error ("IDA failed to interpolate yp"); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
780 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
781 cont += 1; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
782 output.resize (cont + 1, num); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
783 tout.resize (cont + 1); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
784 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
785 tout(cont) = tin + step * i; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
786 yout = NVecToCol (dky, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
787 ypout = NVecToCol (dkyp, num); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
788 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
789 for (octave_idx_type j = 0; j < num; j++) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
790 output.elem (cont, j) = yout.elem (j); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
791 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
792 if (haveoutputfcn) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
793 status = IDA::outputfun (output_fcn, haveoutputsel, yout, |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
794 tout(cont), tend, outputsel, ""); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
795 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
796 if (haveeventfunction) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
797 status = IDA::event (event_fcn, te, ye, ie, tout(cont), |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
798 yout, string, ypout, oldval, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
799 oldisterminal, olddir, cont, temp, |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
800 tout(cont-1), yold); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
801 } |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
802 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
803 N_VDestroy_Serial (dky); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
804 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
805 return status; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
806 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
807 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
808 bool |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
809 IDA::outputfun (octave_function *output_fcn, bool haveoutputsel, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
810 const ColumnVector& yout, realtype tsol, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
811 realtype tend, ColumnVector& outputsel, |
22918
0b5d9978d7b1
* __ode15__.cc: Pass std::string arg by const reference.
John W. Eaton <jwe@octave.org>
parents:
22917
diff
changeset
|
812 const std::string& flag) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
813 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
814 bool status = 0; |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
815 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
816 octave_value_list output; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
817 output(2) = flag; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
818 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
819 ColumnVector ysel (outputsel.numel ()); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
820 if (haveoutputsel) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
821 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
822 for (octave_idx_type i = 0; i < outputsel.numel (); i++) |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
823 ysel(i) = yout(outputsel(i)); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
824 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
825 output(1) = ysel; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
826 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
827 else |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
828 output(1) = yout; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
829 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
830 if (flag == "init") |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
831 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
832 ColumnVector toutput(2); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
833 toutput(0) = tsol; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
834 toutput(1) = tend; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
835 output(0) = toutput; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
836 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23024
diff
changeset
|
837 octave::feval (output_fcn, output, 0); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
838 } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
839 else if (flag == "") |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
840 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
841 output(0) = tsol; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23024
diff
changeset
|
842 octave_value_list val = octave::feval (output_fcn, output, 1); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
843 status = val(0).bool_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
844 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
845 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
846 { // Cleanup plotter |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
847 output(0) = tend; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23024
diff
changeset
|
848 octave::feval (output_fcn, output, 0); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
849 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
850 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
851 return status; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
852 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
853 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
854 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
855 IDA::set_maxstep (realtype maxstep) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
856 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
857 if (IDASetMaxStep (mem, maxstep) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
858 error ("IDA: Max Step not set"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
859 } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
860 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
861 void |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
862 IDA::set_initialstep (realtype initialstep) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
863 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
864 if (IDASetInitStep (mem, initialstep) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
865 error ("IDA: Initial Step not set"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
866 } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
867 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
868 void |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
869 IDA::set_maxorder (int maxorder) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
870 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
871 if (IDASetMaxOrd (mem, maxorder) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
872 error ("IDA: Max Order not set"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
873 } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
874 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
875 void |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
876 IDA::print_stat (void) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
877 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
878 long int nsteps = 0, netfails = 0, nrevals = 0; |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
879 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
880 if (IDAGetNumSteps (mem, &nsteps) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
881 error ("IDA failed to return the number of internal steps"); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
882 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
883 if (IDAGetNumErrTestFails (mem, &netfails) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
884 error ("IDA failed to return the number of internal errors"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
885 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
886 if (IDAGetNumResEvals (mem, &nrevals) != 0) |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
887 error ("IDA failed to return the number of residual evaluations"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
888 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
889 std::cout << nsteps << " successful steps\n"; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
890 std::cout << netfails << " failed attempts\n"; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
891 std::cout << nrevals << " function evaluations\n"; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
892 // std::cout << " partial derivatives\n"; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
893 // std::cout << " LU decompositions\n"; |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
894 // std::cout << " solutions of linear systems\n"; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
895 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
896 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
897 ColumnVector |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
898 ida_user_function (const ColumnVector& x, const ColumnVector& xdot, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
899 double t, octave_function *ida_fc) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
900 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
901 octave_value_list tmp; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
902 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
903 try |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
904 { |
23480
0670624ea91b
* __ode15__.cc: Avoid deprecated function warnings.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23473
diff
changeset
|
905 tmp = octave::feval (ida_fc, ovl (t, x, xdot), 1); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
906 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
907 catch (octave::execution_exception& e) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
908 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
909 err_user_supplied_eval (e, "__ode15__"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
910 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
911 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
912 return tmp(0).vector_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
913 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
914 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
915 Matrix |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
916 ida_dense_jac (const ColumnVector& x, const ColumnVector& xdot, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
917 double t, double cj, octave_function *ida_jc) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
918 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
919 octave_value_list tmp; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
920 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
921 try |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
922 { |
23480
0670624ea91b
* __ode15__.cc: Avoid deprecated function warnings.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23473
diff
changeset
|
923 tmp = octave::feval (ida_jc, ovl (t, x, xdot), 2); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
924 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
925 catch (octave::execution_exception& e) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
926 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
927 err_user_supplied_eval (e, "__ode15__"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
928 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
929 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
930 return tmp(0).matrix_value () + cj * tmp(1).matrix_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
931 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
932 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
933 SparseMatrix |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
934 ida_sparse_jac (const ColumnVector& x, const ColumnVector& xdot, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
935 double t, double cj, octave_function *ida_jc) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
936 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
937 octave_value_list tmp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
938 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
939 try |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
940 { |
23480
0670624ea91b
* __ode15__.cc: Avoid deprecated function warnings.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23473
diff
changeset
|
941 tmp = octave::feval (ida_jc, ovl (t, x, xdot), 2); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
942 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
943 catch (octave::execution_exception& e) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
944 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
945 err_user_supplied_eval (e, "__ode15__"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
946 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
947 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
948 return tmp(0).sparse_matrix_value () + cj * tmp(1).sparse_matrix_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
949 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
950 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
951 Matrix |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
952 ida_dense_cell_jac (Matrix *dfdy, Matrix *dfdyp, double cj) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
953 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
954 return (*dfdy) + cj * (*dfdyp); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
955 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
956 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
957 SparseMatrix |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
958 ida_sparse_cell_jac (SparseMatrix *spdfdy, SparseMatrix *spdfdyp, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
959 double cj) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
960 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
961 return (*spdfdy) + cj * (*spdfdyp); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
962 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
963 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
964 octave_value_list |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
965 do_ode15 (octave_function *ida_fcn, |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
966 const ColumnVector& tspan, |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
967 const int numt, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
968 const realtype t0, |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
969 const ColumnVector& y0, |
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
970 const ColumnVector& yp0, |
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
971 const octave_scalar_map& options) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
972 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
973 octave_value_list retval; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
974 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
975 // Create object |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
976 IDA dae (t0, y0, yp0, ida_fcn, ida_user_function); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
977 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
978 // Set Jacobian |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
979 bool havejac = options.getfield ("havejac").bool_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
980 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
981 bool havejacsparse = options.getfield ("havejacsparse").bool_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
982 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
983 bool havejacfun = options.getfield ("havejacfun").bool_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
984 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
985 Matrix ida_dfdy, ida_dfdyp, *dfdy, *dfdyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
986 SparseMatrix ida_spdfdy, ida_spdfdyp, *spdfdy, *spdfdyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
987 octave_function *ida_jac; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
988 Cell jaccell; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
989 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
990 if (havejac) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
991 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
992 if (havejacfun) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
993 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
994 ida_jac = options.getfield ("Jacobian").function_value (); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
995 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
996 if (havejacsparse) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
997 dae.set_jacobian (ida_jac, ida_sparse_jac); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
998 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
999 dae.set_jacobian (ida_jac, ida_dense_jac); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1000 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1001 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1002 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1003 jaccell = options.getfield ("Jacobian").cell_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1004 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1005 if (havejacsparse) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1006 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1007 ida_spdfdy = jaccell(0).sparse_matrix_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1008 ida_spdfdyp = jaccell(1).sparse_matrix_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1009 spdfdy = &ida_spdfdy; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1010 spdfdyp = &ida_spdfdyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1011 dae.set_jacobian (spdfdy, spdfdyp, ida_sparse_cell_jac); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1012 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1013 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1014 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1015 ida_dfdy = jaccell(0).matrix_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1016 ida_dfdyp = jaccell(1).matrix_value (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1017 dfdy = &ida_dfdy; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1018 dfdyp = &ida_dfdyp; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1019 dae.set_jacobian (dfdy, dfdyp, ida_dense_cell_jac); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1020 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1021 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1022 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1023 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1024 // Initialize IDA |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1025 dae.initialize (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1026 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1027 // Set tolerances |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1028 realtype rel_tol = options.getfield("RelTol").double_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1029 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1030 bool haveabstolvec = options.getfield ("haveabstolvec").bool_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1031 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1032 if (haveabstolvec) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1033 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1034 ColumnVector abs_tol = options.getfield("AbsTol").vector_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1035 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1036 dae.set_tolerance (abs_tol, rel_tol); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1037 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1038 else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1039 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1040 realtype abs_tol = options.getfield("AbsTol").double_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1041 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1042 dae.set_tolerance (abs_tol, rel_tol); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1043 } |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1044 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1045 //Set max step |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1046 realtype maxstep = options.getfield("MaxStep").double_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1047 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1048 dae.set_maxstep (maxstep); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1049 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1050 //Set initial step |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23565
diff
changeset
|
1051 if (! options.getfield("InitialStep").isempty ()) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1052 { |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1053 realtype initialstep = options.getfield("InitialStep").double_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1054 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1055 dae.set_initialstep (initialstep); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1056 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1057 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1058 //Set max order FIXME: it doesn't work |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1059 int maxorder = options.getfield("MaxOrder").int_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1060 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1061 dae.set_maxorder (maxorder); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1062 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1063 //Set Refine |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1064 const int refine = options.getfield("Refine").int_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1065 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1066 bool haverefine = (refine > 1); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1067 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
1068 octave_function *output_fcn = nullptr; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1069 ColumnVector outputsel; |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1070 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1071 // OutputFcn |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1072 bool haveoutputfunction |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1073 = options.getfield("haveoutputfunction").bool_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1074 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1075 if (haveoutputfunction) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1076 output_fcn = options.getfield("OutputFcn").function_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1077 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1078 // OutputSel |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1079 bool haveoutputsel = options.getfield("haveoutputselection").bool_value (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1080 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1081 if (haveoutputsel) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1082 outputsel = options.getfield("OutputSel").vector_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1083 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
1084 octave_function *event_fcn = nullptr; |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1085 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1086 // Events |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1087 bool haveeventfunction |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1088 = options.getfield("haveeventfunction").bool_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1089 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1090 if (haveeventfunction) |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1091 event_fcn = options.getfield("Events").function_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1092 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1093 // Set up linear solver |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1094 dae.set_up (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1095 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1096 // Integrate |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1097 retval = dae.integrate (numt, tspan, y0, yp0, refine, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1098 haverefine, haveoutputfunction, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1099 output_fcn, haveoutputsel, outputsel, |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1100 haveeventfunction, event_fcn); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1101 |
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1102 // Statistics |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1103 bool havestats = options.getfield("havestats").bool_value (); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1104 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1105 if (havestats) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1106 dae.print_stat (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1107 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1108 return retval; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1109 } |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1110 } |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1111 #endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1112 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1113 |
22913
69342e4f0dcf
* __ode15__.cc: Don't check nargout.
John W. Eaton <jwe@octave.org>
parents:
22912
diff
changeset
|
1114 DEFUN_DLD (__ode15__, args, , |
69342e4f0dcf
* __ode15__.cc: Don't check nargout.
John W. Eaton <jwe@octave.org>
parents:
22912
diff
changeset
|
1115 doc: /* -*- texinfo -*- |
23565
3a730821e4a2
doc: Peridoc grammarcheck of documentation.
Rik <rik@octave.org>
parents:
23480
diff
changeset
|
1116 @deftypefn {} {@var{t}, @var{y} =} __ode15__ (@var{fun}, @var{tspan}, @var{y0}, @var{yp0}, @var{options}) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1117 Undocumented internal function. |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1118 @end deftypefn */) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1119 { |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1120 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1121 #if defined (HAVE_SUNDIALS) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1122 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1123 // Check number of parameters |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1124 int nargin = args.length (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1125 |
22913
69342e4f0dcf
* __ode15__.cc: Don't check nargout.
John W. Eaton <jwe@octave.org>
parents:
22912
diff
changeset
|
1126 if (nargin != 5) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1127 print_usage (); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1128 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1129 // Check odefun |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
1130 octave_function *ida_fcn = nullptr; |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1131 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1132 octave_value f_arg = args(0); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1133 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1134 if (! f_arg.is_function_handle ()) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1135 error ("__ode15__: odefun must be a function handle"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1136 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1137 ida_fcn = f_arg.function_value (); |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1138 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1139 // Check input tspan |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1140 ColumnVector tspan |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1141 = args(1).xvector_value ("__ode15__: TRANGE must be a vector of numbers"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1142 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1143 int numt = tspan.numel (); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1144 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1145 realtype t0 = tspan (0); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1146 |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1147 if (numt < 2) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1148 error ("__ode15__: TRANGE must contain at least 2 elements"); |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1149 else if (! tspan.is_sorted () || tspan(0) == tspan(numt - 1)) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1150 error ("__ode15__: TRANGE must be strictly monotonic"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1151 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1152 // input y0 and yp0 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1153 ColumnVector y0 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1154 = args(2).xvector_value ("__ode15__: initial state y0 must be a vector"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1155 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1156 ColumnVector yp0 |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1157 = args(3).xvector_value ("__ode15__: initial state yp0 must be a vector"); |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1158 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1159 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1160 if (y0.numel () != yp0.numel ()) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1161 error ("__ode15__: initial state y0 and yp0 must have the same length"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1162 else if (y0.numel () < 1) |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1163 error ("__ode15__: initial state yp0 must be a vector or a scalar"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1164 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1165 |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1166 if (! args(4).isstruct ()) |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1167 error ("__ode15__: OPTS argument must be a structure"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1168 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1169 octave_scalar_map options |
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1170 = args(4).xscalar_map_value ("__ode15__: OPTS argument must be a scalar structure"); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1171 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1172 |
22917
c1ac4ac3ebbc
* __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
22915
diff
changeset
|
1173 return octave::do_ode15 (ida_fcn, tspan, numt, t0, y0, yp0, options); |
22910
23847979b91e
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
22903
diff
changeset
|
1174 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1175 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1176 #else |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1177 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1178 octave_unused_parameter (args); |
22911
82551783527f
* __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
1179 |
22901
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1180 err_disabled_feature ("__ode15__", "sundials_ida, sundials_nvecserial"); |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1181 |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1182 #endif |
4c56f3ffec04
Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff
changeset
|
1183 } |