annotate libinterp/dldfcn/__ode15__.cc @ 31605:e88a07dec498 stable

maint: Use macros to begin/end C++ namespaces. * oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE, OCTAVE_END_NAMESPACE) that can be used to start/end a namespace. * mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc, __dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc, auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc, display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h, mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc, pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:23:45 -0800
parents 23520a50d74d
children aac27ad79be6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30547
diff changeset
3 // Copyright (C) 2016-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
25
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
27 # include "config.h"
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
28 #endif
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
29
22911
82551783527f * __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
30 #include "dColVector.h"
82551783527f * __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
31 #include "dMatrix.h"
82551783527f * __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
32 #include "dSparse.h"
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
33 #include "f77-fcn.h"
28849
8b0675c2cfe0 Add functions to check for integer overflow on multiplication (bug #59094).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28741
diff changeset
34 #include "lo-utils.h"
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
35
23024
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 23022
diff changeset
36 #include "Cell.h"
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
37 #include "defun-dld.h"
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
38 #include "error.h"
23024
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 23022
diff changeset
39 #include "errwarn.h"
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 23022
diff changeset
40 #include "oct-map.h"
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
41 #include "ov.h"
23024
a6a7b054e4ba Rationalize #includes in libinterp/dldfcn directory.
Rik <rik@octave.org>
parents: 23022
diff changeset
42 #include "ovl.h"
26000
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
43 #include "pager.h"
22911
82551783527f * __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
44 #include "parse.h"
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
45
22911
82551783527f * __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
46 #if defined (HAVE_SUNDIALS)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
47
26898
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
48 # if defined (HAVE_NVECTOR_NVECTOR_SERIAL_H)
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
49 # include <nvector/nvector_serial.h>
25098
5dce8aa80652 configure: disable SUNDIALS if the IDADENSE API is not found (bug #52475)
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
50 # endif
5dce8aa80652 configure: disable SUNDIALS if the IDADENSE API is not found (bug #52475)
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
51
26898
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
52 # if defined (HAVE_IDA_IDA_H)
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
53 # include <ida/ida.h>
26903
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
54 # elif defined (HAVE_IDA_H)
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
55 # include <ida.h>
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
56 # endif
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
57 # if defined (HAVE_IDA_IDA_DIRECT_H)
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
58 # include <ida/ida_direct.h>
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
59 # elif defined (HAVE_IDA_DIRECT_H)
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
60 # include <ida_direct.h>
26894
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
61 # endif
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
62
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
63 # if defined (HAVE_SUNLINSOL_SUNLINSOL_DENSE_H)
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
64 # include <sunlinsol/sunlinsol_dense.h>
23022
305cdc1d444b * __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents: 22919
diff changeset
65 # endif
305cdc1d444b * __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents: 22919
diff changeset
66
26894
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
67 # if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H)
26895
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
68 # if defined (HAVE_KLU_H)
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
69 # include <klu.h>
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
70 # endif
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
71 # if defined (HAVE_KLU_KLU_H)
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
72 # include <klu/klu.h>
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
73 # endif
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
74 # if defined (HAVE_SUITESPARSE_KLU_H)
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
75 # include <suitesparse/klu.h>
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
76 # endif
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
77 # if defined (HAVE_UFPARSE_KLU_H)
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
78 # include <ufsparse/klu.h>
a1acd11bad19 Directly include klu.h in __ode15__.cc (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26894
diff changeset
79 # endif
26894
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
80 # include <sunlinsol/sunlinsol_klu.h>
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
81 # endif
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
82
29969
7a4f16bff8fd use fewer OCTAVE_NAMESPACE_BEGIN/END blocks where possible
John W. Eaton <jwe@octave.org>
parents: 29966
diff changeset
83 #endif
7a4f16bff8fd use fewer OCTAVE_NAMESPACE_BEGIN/END blocks where possible
John W. Eaton <jwe@octave.org>
parents: 29966
diff changeset
84
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31603
diff changeset
85 OCTAVE_BEGIN_NAMESPACE(octave)
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
86
29969
7a4f16bff8fd use fewer OCTAVE_NAMESPACE_BEGIN/END blocks where possible
John W. Eaton <jwe@octave.org>
parents: 29966
diff changeset
87 #if defined (HAVE_SUNDIALS)
7a4f16bff8fd use fewer OCTAVE_NAMESPACE_BEGIN/END blocks where possible
John W. Eaton <jwe@octave.org>
parents: 29966
diff changeset
88
26903
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
89 # if ! defined (HAVE_IDASETJACFN) && defined (HAVE_IDADLSSETJACFN)
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
90 static inline int
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
91 IDASetJacFn (void *ida_mem, IDADlsJacFn jac)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
92 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
93 return IDADlsSetJacFn (ida_mem, jac);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
94 }
26903
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
95 # endif
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
96
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
97 # if ! defined (HAVE_IDASETLINEARSOLVER) && defined (HAVE_IDADLSSETLINEARSOLVER)
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
98 static inline int
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
99 IDASetLinearSolver (void *ida_mem, SUNLinearSolver LS, SUNMatrix A)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
100 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
101 return IDADlsSetLinearSolver (ida_mem, LS, A);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
102 }
26903
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
103 # endif
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
104
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
105 # if ! defined (HAVE_SUNLINSOL_DENSE) && defined (HAVE_SUNDENSELINEARSOLVER)
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
106 static inline SUNLinearSolver
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
107 SUNLinSol_Dense (N_Vector y, SUNMatrix A)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
108 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
109 return SUNDenseLinearSolver (y, A);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
110 }
26903
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
111 # endif
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
112
26909
5042a568771a don't disable all of sundials if including sunlinsol_klu.h fails (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26907
diff changeset
113 # if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
5042a568771a don't disable all of sundials if including sunlinsol_klu.h fails (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26907
diff changeset
114 # if ! defined (HAVE_SUNLINSOL_KLU) && defined (HAVE_SUNKLU)
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
115 static inline SUNLinearSolver
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
116 SUNLinSol_KLU (N_Vector y, SUNMatrix A)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
117 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
118 return SUNKLU (y, A);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
119 }
26909
5042a568771a don't disable all of sundials if including sunlinsol_klu.h fails (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26907
diff changeset
120 # endif
26903
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
121 # endif
73b141d5a888 improve configure checks for sundials (bug #55911)
John W. Eaton <jwe@octave.org>
parents: 26898
diff changeset
122
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
123 static inline realtype *
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
124 nv_data_s (N_Vector& v)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
125 {
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
126 # if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
127 // Disable warning from GCC about old-style casts in Sundials
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
128 // macro expansions. Do this in a function so that this
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
129 // diagnostic may still be enabled for the rest of the file.
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
130 # pragma GCC diagnostic push
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
131 # pragma GCC diagnostic ignored "-Wold-style-cast"
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
132 # endif
22915
7766e3ef6c69 * __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents: 22914
diff changeset
133
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
134 return NV_DATA_S (v);
23085
dffa2b8c9482 maint: strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 23075
diff changeset
135
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
136 # if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
137 // Restore prevailing warning state for remainder of the file.
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
138 # pragma GCC diagnostic pop
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
139 # endif
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26909
diff changeset
140 }
22915
7766e3ef6c69 * __ode15__.cc: Avoid old-style cast warnings.
John W. Eaton <jwe@octave.org>
parents: 22914
diff changeset
141
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
142 class IDA
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
143 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
144 public:
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
145
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
146 typedef
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
147 ColumnVector (*DAERHSFuncIDA) (const ColumnVector& x,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
148 const ColumnVector& xdot,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
149 realtype t, const octave_value& idaf);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
150
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
151 typedef
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
152 Matrix (*DAEJacFuncDense) (const ColumnVector& x,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
153 const ColumnVector& xdot, realtype t,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
154 realtype cj, const octave_value& idaj);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
155
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
156 typedef
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
157 SparseMatrix (*DAEJacFuncSparse) (const ColumnVector& x,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
158 const ColumnVector& xdot,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
159 realtype t, realtype cj,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
160 const octave_value& idaj);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
161
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
162 typedef
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
163 Matrix (*DAEJacCellDense) (Matrix *dfdy, Matrix *dfdyp,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
164 realtype cj);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
165
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
166 typedef
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
167 SparseMatrix (*DAEJacCellSparse) (SparseMatrix *dfdy,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
168 SparseMatrix *dfdyp, realtype cj);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
169
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
170 //Default
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
171 IDA (void)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
172 : m_t0 (0.0), m_y0 (), m_yp0 (), m_havejac (false), m_havejacfcn (false),
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
173 m_havejacsparse (false), m_mem (nullptr), m_num (), m_ida_fcn (),
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
174 m_ida_jac (), m_dfdy (nullptr), m_dfdyp (nullptr), m_spdfdy (nullptr),
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
175 m_spdfdyp (nullptr), m_fcn (nullptr), m_jacfcn (nullptr),
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
176 m_jacspfcn (nullptr), m_jacdcell (nullptr), m_jacspcell (nullptr),
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
177 m_sunJacMatrix (nullptr), m_sunLinearSolver (nullptr)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
178 { }
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
179
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
180
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
181 IDA (realtype t, ColumnVector y, ColumnVector yp,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
182 const octave_value& ida_fcn, DAERHSFuncIDA daefun)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
183 : m_t0 (t), m_y0 (y), m_yp0 (yp), m_havejac (false), m_havejacfcn (false),
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
184 m_havejacsparse (false), m_mem (nullptr), m_num (), m_ida_fcn (ida_fcn),
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
185 m_ida_jac (), m_dfdy (nullptr), m_dfdyp (nullptr), m_spdfdy (nullptr),
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
186 m_spdfdyp (nullptr), m_fcn (daefun), m_jacfcn (nullptr),
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
187 m_jacspfcn (nullptr), m_jacdcell (nullptr), m_jacspcell (nullptr),
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
188 m_sunJacMatrix (nullptr), m_sunLinearSolver (nullptr)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
189 { }
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
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
192 ~IDA (void)
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
193 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
194 IDAFree (&m_mem);
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
195 SUNLinSolFree (m_sunLinearSolver);
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
196 SUNMatDestroy (m_sunJacMatrix);
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
197 # if defined (HAVE_SUNDIALS_SUNCONTEXT)
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
198 SUNContext_Free (&m_sunContext);
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
199 # endif
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
200 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
201
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
202 IDA&
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
203 set_jacobian (const octave_value& jac, DAEJacFuncDense j)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
204 {
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
205 m_jacfcn = j;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
206 m_ida_jac = jac;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
207 m_havejac = true;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
208 m_havejacfcn = true;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
209 m_havejacsparse = false;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
210
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
211 return *this;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
212 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
213
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
214 IDA&
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
215 set_jacobian (const octave_value& jac, DAEJacFuncSparse j)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
216 {
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
217 m_jacspfcn = j;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
218 m_ida_jac = jac;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
219 m_havejac = true;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
220 m_havejacfcn = true;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
221 m_havejacsparse = true;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
222
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
223 return *this;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
224 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
225
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
226 IDA&
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
227 set_jacobian (Matrix *dy, Matrix *dyp, DAEJacCellDense j)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
228 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
229 m_jacdcell = j;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
230 m_dfdy = dy;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
231 m_dfdyp = dyp;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
232 m_havejac = true;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
233 m_havejacfcn = false;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
234 m_havejacsparse = false;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
235
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
236 return *this;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
237 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
238
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
239 IDA&
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
240 set_jacobian (SparseMatrix *dy, SparseMatrix *dyp,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
241 DAEJacCellSparse j)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
242 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
243 m_jacspcell = j;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
244 m_spdfdy = dy;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
245 m_spdfdyp = dyp;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
246 m_havejac = true;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
247 m_havejacfcn = false;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
248 m_havejacsparse = true;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
249
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
250 return *this;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
251 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
252
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
253 void set_userdata (void);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
254
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
255 void initialize (void);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
256
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
257 static ColumnVector NVecToCol (N_Vector& v, octave_f77_int_type n);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
258
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
259 # if defined (HAVE_SUNDIALS_SUNCONTEXT)
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
260 N_Vector ColToNVec (const ColumnVector& data, octave_f77_int_type n);
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
261 # else
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
262 static N_Vector ColToNVec (const ColumnVector& data, octave_f77_int_type n);
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
263 # endif
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
264
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
265 void
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
266 set_up (const ColumnVector& y);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
267
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
268 void
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
269 set_tolerance (ColumnVector& abstol, realtype reltol);
22901
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 void
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
272 set_tolerance (realtype abstol, realtype reltol);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
273
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
274 static int
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
275 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
276 N_Vector rr, void *user_data);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
277
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
278 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
279 resfun_impl (realtype t, N_Vector& yy,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
280 N_Vector& yyp, N_Vector& rr);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
281 static int
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
282 jacdense (realtype t, realtype cj, N_Vector yy, N_Vector yyp,
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
283 N_Vector, SUNMatrix JJ, void *user_data, N_Vector,
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
284 N_Vector, N_Vector)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
285 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
286 IDA *self = static_cast <IDA *> (user_data);
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
287 self->jacdense_impl (t, cj, yy, yyp, JJ);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
288 return 0;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
289 }
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 void
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
292 jacdense_impl (realtype t, realtype cj,
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
293 N_Vector& yy, N_Vector& yyp, SUNMatrix& JJ);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
294
26894
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
295 # if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
296 static int
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
297 jacsparse (realtype t, realtype cj, N_Vector yy, N_Vector yyp,
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
298 N_Vector, SUNMatrix Jac, void *user_data, N_Vector,
22914
b7ffd93b8d06 * __ode15__.cc: Avoid unused parameter warnings.
John W. Eaton <jwe@octave.org>
parents: 22913
diff changeset
299 N_Vector, N_Vector)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
300 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
301 IDA *self = static_cast <IDA *> (user_data);
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
302 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
303 return 0;
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
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
306 void
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
307 jacsparse_impl (realtype t, realtype cj,
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
308 N_Vector& yy, N_Vector& yyp, SUNMatrix& Jac);
26898
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
309 # endif
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 void set_maxstep (realtype maxstep);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
312
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
313 void set_initialstep (realtype initialstep);
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 bool
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
316 interpolate (octave_idx_type& cont, Matrix& output, ColumnVector& tout,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
317 int refine, realtype tend, bool haveoutputfcn,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
318 bool haveoutputsel, const octave_value& output_fcn,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
319 ColumnVector& outputsel, bool haveeventfunction,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
320 const octave_value& event_fcn, ColumnVector& te,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
321 Matrix& ye, ColumnVector& ie, ColumnVector& oldval,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
322 ColumnVector& oldisterminal, ColumnVector& olddir,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
323 octave_idx_type& temp, ColumnVector& yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
324 const octave_idx_type num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
325
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
326 bool
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
327 outputfun (const octave_value& output_fcn, bool haveoutputsel,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
328 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
329 ColumnVector& outputsel, const std::string& flag);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
330
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
331
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
332 bool
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
333 event (const octave_value& event_fcn,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
334 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
335 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
336 const ColumnVector& yp, ColumnVector& oldval,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
337 ColumnVector& oldisterminal, ColumnVector& olddir,
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
338 octave_idx_type cont, octave_idx_type& temp, realtype told,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
339 ColumnVector& yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
340 const octave_idx_type num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
341
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
342 void set_maxorder (int maxorder);
22901
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 octave_value_list
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
345 integrate (const octave_idx_type numt, const ColumnVector& tt,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
346 const ColumnVector& y0, const ColumnVector& yp0,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
347 const int refine, bool haverefine, bool haveoutputfcn,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
348 const octave_value& output_fcn, bool haveoutputsel,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
349 ColumnVector& outputsel, bool haveeventfunction,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
350 const octave_value& event_fcn,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
351 const octave_idx_type num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
352
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
353 void print_stat (void);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
354
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
355 private:
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
356
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
357 realtype m_t0;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
358 ColumnVector m_y0;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
359 ColumnVector m_yp0;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
360 bool m_havejac;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
361 bool m_havejacfcn;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
362 bool m_havejacsparse;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
363 void *m_mem;
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
364 octave_f77_int_type m_num;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
365 octave_value m_ida_fcn;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
366 octave_value m_ida_jac;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
367 Matrix *m_dfdy;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
368 Matrix *m_dfdyp;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
369 SparseMatrix *m_spdfdy;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
370 SparseMatrix *m_spdfdyp;
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
371 DAERHSFuncIDA m_fcn;
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
372 DAEJacFuncDense m_jacfcn;
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
373 DAEJacFuncSparse m_jacspfcn;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
374 DAEJacCellDense m_jacdcell;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
375 DAEJacCellSparse m_jacspcell;
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
376 # if defined (HAVE_SUNDIALS_SUNCONTEXT)
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
377 SUNContext m_sunContext;
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
378 # endif
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
379 SUNMatrix m_sunJacMatrix;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
380 SUNLinearSolver m_sunLinearSolver;
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
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
383 int
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
384 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
385 void *user_data)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
386 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
387 IDA *self = static_cast <IDA *> (user_data);
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
388 self->resfun_impl (t, yy, yyp, rr);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
389 return 0;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
390 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
391
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
392 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
393 IDA::resfun_impl (realtype t, N_Vector& yy,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
394 N_Vector& yyp, N_Vector& rr)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
395 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
396 ColumnVector y = IDA::NVecToCol (yy, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
397
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
398 ColumnVector yp = IDA::NVecToCol (yyp, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
399
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
400 ColumnVector res = (*m_fcn) (y, yp, t, m_ida_fcn);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
401
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
402 realtype *puntrr = nv_data_s (rr);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
403
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
404 for (octave_idx_type i = 0; i < m_num; i++)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
405 puntrr[i] = res(i);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
406 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
407
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
408 # if defined (HAVE_SUNDIALS_SUNCONTEXT)
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
409 # define OCTAVE_SUNCONTEXT , m_sunContext
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
410 # else
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
411 # define OCTAVE_SUNCONTEXT
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
412 # endif
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
413
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
414 void
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
415 IDA::set_up (const ColumnVector& y)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
416 {
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
417 N_Vector yy = ColToNVec (y, m_num);
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
418
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
419 if (m_havejacsparse)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
420 {
26898
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
421 # if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
422 # if defined (HAVE_SUNSPARSEMATRIX_REALLOCATE)
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
423 // Initially allocate memory for 0 entries. We will reallocate when we
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
424 // get the Jacobian matrix from the user and know the actual number of
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
425 // entries.
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
426 m_sunJacMatrix = SUNSparseMatrix (m_num, m_num, 0, CSC_MAT
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
427 OCTAVE_SUNCONTEXT);
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
428 # else
29445
b5f3ae7610cf Use gnulib macros that account for the output type in integer overflow checks.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
429 octave_f77_int_type max_elems;
b5f3ae7610cf Use gnulib macros that account for the output type in integer overflow checks.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
430 if (math::int_multiply_overflow (m_num, m_num, &max_elems))
28849
8b0675c2cfe0 Add functions to check for integer overflow on multiplication (bug #59094).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28741
diff changeset
431 error ("Unable to allocate memory for sparse Jacobian");
8b0675c2cfe0 Add functions to check for integer overflow on multiplication (bug #59094).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28741
diff changeset
432
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
433 m_sunJacMatrix = SUNSparseMatrix (m_num, m_num, max_elems, CSC_MAT
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
434 OCTAVE_SUNCONTEXT);
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
435 # endif
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
436 if (! m_sunJacMatrix)
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
437 error ("Unable to create sparse Jacobian for Sundials");
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
438
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
439 m_sunLinearSolver = SUNLinSol_KLU (yy, m_sunJacMatrix
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
440 OCTAVE_SUNCONTEXT);
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
441 if (! m_sunLinearSolver)
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
442 error ("Unable to create KLU sparse solver");
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
443
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
444 if (IDASetLinearSolver (m_mem, m_sunLinearSolver, m_sunJacMatrix))
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
445 error ("Unable to set sparse linear solver");
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
446
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
447 IDASetJacFn (m_mem, IDA::jacsparse);
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
448
23022
305cdc1d444b * __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents: 22919
diff changeset
449 # else
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
450 error ("SUNDIALS SUNLINSOL KLU was unavailable or disabled when "
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
451 "Octave was built");
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
452
23022
305cdc1d444b * __ode15__.cc: Disable sparse jacobian handling if IDAKLU is missing.
John W. Eaton <jwe@octave.org>
parents: 22919
diff changeset
453 # endif
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
454
22901
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 else
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
457 {
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
458
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
459 m_sunJacMatrix = SUNDenseMatrix (m_num, m_num OCTAVE_SUNCONTEXT);
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
460 if (! m_sunJacMatrix)
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
461 error ("Unable to create dense Jacobian for Sundials");
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
462
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
463 m_sunLinearSolver = SUNLinSol_Dense (yy, m_sunJacMatrix
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
464 OCTAVE_SUNCONTEXT);
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
465 if (! m_sunLinearSolver)
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
466 error ("Unable to create dense linear solver");
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
467
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
468 if (IDASetLinearSolver (m_mem, m_sunLinearSolver, m_sunJacMatrix))
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
469 error ("Unable to set dense linear solver");
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
470
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
471 if (m_havejac && IDASetJacFn (m_mem, IDA::jacdense) != 0)
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
472 error ("Unable to set dense Jacobian function");
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
473
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
474 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
475 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
476
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
477 void
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
478 IDA::jacdense_impl (realtype t, realtype cj,
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
479 N_Vector& yy, N_Vector& yyp, SUNMatrix& JJ)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
480
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
481 {
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
482 octave_f77_int_type Neq = NV_LENGTH_S (yy);
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
483
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
484 ColumnVector y = NVecToCol (yy, Neq);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
485
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
486 ColumnVector yp = NVecToCol (yyp, Neq);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
487
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
488 Matrix jac;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
489
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
490 if (m_havejacfcn)
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
491 jac = (*m_jacfcn) (y, yp, t, cj, m_ida_jac);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
492 else
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
493 jac = (*m_jacdcell) (m_dfdy, m_dfdyp, cj);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
494
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
495 octave_f77_int_type num_jac = to_f77_int (jac.numel ());
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
496 std::copy (jac.fortran_vec (),
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
497 jac.fortran_vec () + num_jac,
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
498 SUNDenseMatrix_Data (JJ));
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
499 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
500
26894
ee6300e77c92 Update detection of sundials in the build system (bug #52475).
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26893
diff changeset
501 # if defined (HAVE_SUNDIALS_SUNLINSOL_KLU)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
502 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
503 IDA::jacsparse_impl (realtype t, realtype cj, N_Vector& yy, N_Vector& yyp,
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
504 SUNMatrix& Jac)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
505
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
506 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
507 ColumnVector y = NVecToCol (yy, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
508
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
509 ColumnVector yp = NVecToCol (yyp, m_num);
22901
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 SparseMatrix jac;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
512
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
513 if (m_havejacfcn)
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
514 jac = (*m_jacspfcn) (y, yp, t, cj, m_ida_jac);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
515 else
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
516 jac = (*m_jacspcell) (m_spdfdy, m_spdfdyp, cj);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
517
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
518 # if defined (HAVE_SUNSPARSEMATRIX_REALLOCATE)
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
519 octave_f77_int_type nnz = to_f77_int (jac.nnz ());
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
520 if (nnz > SUNSparseMatrix_NNZ (Jac))
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
521 {
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
522 // Allocate memory for sparse Jacobian defined in user function.
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
523 // This will always be required at least once since we set the number
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
524 // of non-zero elements to zero initially.
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
525 if (SUNSparseMatrix_Reallocate (Jac, nnz))
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
526 error ("Unable to allocate sufficient memory for IDA sparse matrix");
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
527 }
28741
2cd4a32cbc4b maint: Change "#if" indentation for consistency in __ode15__.cc.
Rik <rik@octave.org>
parents: 28739
diff changeset
528 # endif
28739
3eb2fab71028 Allocate memory for Jacobian in __ode15__ more efficiently (bug #55905).
Bill Greene <w.h.greene@gmail.com>
parents: 28716
diff changeset
529
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
530 SUNMatZero_Sparse (Jac);
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
531 // We have to use "sunindextype *" here but still need to check that
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
532 // conversion of each element to "octave_f77_int_type" is save.
26897
ba0c9e84f6a8 allow building with sundials library that uses 32-bit sunindextype (bug #52475)
John W. Eaton <jwe@octave.org>
parents: 26895
diff changeset
533 sunindextype *colptrs = SUNSparseMatrix_IndexPointers (Jac);
ba0c9e84f6a8 allow building with sundials library that uses 32-bit sunindextype (bug #52475)
John W. Eaton <jwe@octave.org>
parents: 26895
diff changeset
534 sunindextype *rowvals = SUNSparseMatrix_IndexValues (Jac);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
535
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
536 for (octave_f77_int_type i = 0; i < m_num + 1; i++)
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
537 colptrs[i] = to_f77_int (jac.cidx (i));
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
538
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
539 double *d = SUNSparseMatrix_Data (Jac);
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
540 for (octave_f77_int_type i = 0; i < to_f77_int (jac.nnz ()); i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
541 {
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
542 rowvals[i] = to_f77_int (jac.ridx (i));
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
543 d[i] = jac.data (i);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
544 }
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
545 }
26898
d94876e7a0aa Remove calls to deprecated sundials functions.
Carlo de Falco <carlo.defalco@polimi.it>
parents: 26897
diff changeset
546 # endif
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
547
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
548 ColumnVector
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
549 IDA::NVecToCol (N_Vector& v, octave_f77_int_type n)
22901
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 ColumnVector data (n);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
552 realtype *punt = nv_data_s (v);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
553
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
554 for (octave_f77_int_type i = 0; i < n; i++)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
555 data(i) = punt[i];
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
556
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
557 return data;
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
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
560 N_Vector
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
561 IDA::ColToNVec (const ColumnVector& data, octave_f77_int_type n)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
562 {
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
563 N_Vector v = N_VNew_Serial (n OCTAVE_SUNCONTEXT);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
564
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
565 realtype *punt = nv_data_s (v);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
566
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
567 for (octave_f77_int_type i = 0; i < n; i++)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
568 punt[i] = data(i);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
569
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
570 return v;
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
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
573 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
574 IDA::set_userdata (void)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
575 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
576 void *userdata = this;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
577
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
578 if (IDASetUserData (m_mem, userdata) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
579 error ("User data not set");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
580 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
581
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
582 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
583 IDA::initialize (void)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
584 {
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
585 m_num = to_f77_int (m_y0.numel ());
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
586 # if defined (HAVE_SUNDIALS_SUNCONTEXT)
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
587 if (SUNContext_Create (nullptr, &m_sunContext) < 0)
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
588 error ("__ode15__: unable to create context for SUNDIALS");
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
589 m_mem = IDACreate (m_sunContext);
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
590 # else
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
591 m_mem = IDACreate ();
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
592 # endif
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
593
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
594 N_Vector yy = ColToNVec (m_y0, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
595
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
596 N_Vector yyp = ColToNVec (m_yp0, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
597
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
598 IDA::set_userdata ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
599
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
600 if (IDAInit (m_mem, IDA::resfun, m_t0, yy, yyp) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
601 error ("IDA not initialized");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
602 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
603
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
604 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
605 IDA::set_tolerance (ColumnVector& abstol, realtype reltol)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
606 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
607 N_Vector abs_tol = ColToNVec (abstol, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
608
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
609 if (IDASVtolerances (m_mem, reltol, abs_tol) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
610 error ("IDA: Tolerance not set");
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
611
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
612 N_VDestroy_Serial (abs_tol);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
613 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
614
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
615 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
616 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
617 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
618 if (IDASStolerances (m_mem, reltol, abstol) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
619 error ("IDA: Tolerance not set");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
620 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
621
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
622 octave_value_list
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
623 IDA::integrate (const octave_idx_type numt, const ColumnVector& tspan,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
624 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
625 const int refine, bool haverefine, bool haveoutputfcn,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
626 const octave_value& output_fcn, bool haveoutputsel,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
627 ColumnVector& outputsel, bool haveeventfunction,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
628 const octave_value& event_fcn,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
629 const octave_idx_type num_event_args)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
630 {
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
631 // Set up output
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
632 ColumnVector tout, yout (m_num), ypout (m_num), ysel (outputsel.numel ());
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
633 ColumnVector ie, te, oldval, oldisterminal, olddir;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
634 Matrix output, ye;
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
635 octave_idx_type cont = 0, temp = 0;
31603
23520a50d74d maint: Review C++ files for style and coding conventions.
Rik <rik@octave.org>
parents: 30896
diff changeset
636 bool status = false;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
637 std::string string = "";
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
638 ColumnVector yold = y;
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
639
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
640 realtype tsol = tspan(0);
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
641 realtype tend = tspan(numt-1);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
642
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
643 N_Vector yyp = ColToNVec (yp, m_num);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
644
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
645 N_Vector yy = ColToNVec (y, m_num);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
646
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
647 // Initialize OutputFcn
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
648 if (haveoutputfcn)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
649 status = IDA::outputfun (output_fcn, haveoutputsel, y,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
650 tsol, tend, outputsel, "init");
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 // Initialize Events
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
653 if (haveeventfunction)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
654 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
655 "init", yp, oldval, oldisterminal,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
656 olddir, cont, temp, tsol, yold, num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
657
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
658 if (numt > 2)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
659 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
660 // First output value
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
661 tout.resize (numt);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
662 tout(0) = tsol;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
663 output.resize (numt, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
664
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
665 for (octave_idx_type i = 0; i < m_num; i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
666 output.elem (0, i) = y.elem (i);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
667
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
668 //Main loop
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
669 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
670 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
671 // IDANORMAL already interpolates tspan(j)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
672
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
673 if (IDASolve (m_mem, tspan (j), &tsol, yy, yyp, IDA_NORMAL) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
674 error ("IDASolve failed");
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
675
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
676 yout = NVecToCol (yy, m_num);
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
677 ypout = NVecToCol (yyp, m_num);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
678 tout(j) = tsol;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
679
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
680 for (octave_idx_type i = 0; i < m_num; i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
681 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
682
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
683 if (haveoutputfcn)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
684 status = IDA::outputfun (output_fcn, haveoutputsel, yout, tsol,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
685 tend, outputsel, string);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
686
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
687 if (haveeventfunction)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
688 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
689 string, ypout, oldval, oldisterminal,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
690 olddir, j, temp, tout(j-1), yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
691 num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
692
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
693 // 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
694 if (status == 1)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
695 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
696 output.resize (j + 1, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
697 tout.resize (j + 1);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
698 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
699
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
700 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
701 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
702 else // numel (tspan) == 2
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
703 {
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
704 // First output value
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
705 tout.resize (1);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
706 tout(0) = tsol;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
707 output.resize (1, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
708
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
709 for (octave_idx_type i = 0; i < m_num; i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
710 output.elem (0, i) = y.elem (i);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
711
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
712 bool posdirection = (tend > tsol);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
713
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
714 //main loop
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
715 while (((posdirection == 1 && tsol < tend)
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
716 || (posdirection == 0 && tsol > tend))
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
717 && status == 0)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
718 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
719 if (IDASolve (m_mem, tend, &tsol, yy, yyp, IDA_ONE_STEP) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
720 error ("IDASolve failed");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
721
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
722 if (haverefine)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
723 status = IDA::interpolate (cont, output, tout, refine, tend,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
724 haveoutputfcn, haveoutputsel,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
725 output_fcn, outputsel,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
726 haveeventfunction, event_fcn, te,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
727 ye, ie, oldval, oldisterminal,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
728 olddir, temp, yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
729 num_event_args);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
730
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
731 ypout = NVecToCol (yyp, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
732 cont += 1;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
733 output.resize (cont + 1, m_num); // This may be not efficient
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
734 tout.resize (cont + 1);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
735 tout(cont) = tsol;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
736 yout = NVecToCol (yy, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
737
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
738 for (octave_idx_type i = 0; i < m_num; i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
739 output.elem (cont, i) = yout.elem (i);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
740
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
741 if (haveoutputfcn && ! haverefine && tout(cont) < tend)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
742 status = IDA::outputfun (output_fcn, haveoutputsel, yout, tsol,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
743 tend, outputsel, string);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
744
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
745 if (haveeventfunction && ! haverefine && tout(cont) < tend)
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
746 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
747 string, ypout, oldval, oldisterminal,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
748 olddir, cont, temp, tout(cont-1), yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
749 num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
750 }
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
751
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
752 if (status == 0)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
753 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
754 // Interpolate in tend
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
755 N_Vector dky = N_VNew_Serial (m_num OCTAVE_SUNCONTEXT);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
756
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
757 if (IDAGetDky (m_mem, tend, 0, dky) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
758 error ("IDA failed to interpolate y");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
759
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
760 tout(cont) = tend;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
761 yout = NVecToCol (dky, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
762
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
763 for (octave_idx_type i = 0; i < m_num; i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
764 output.elem (cont, i) = yout.elem (i);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
765
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
766 // Plot final value
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
767 if (haveoutputfcn)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
768 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
769 status = IDA::outputfun (output_fcn, haveoutputsel, yout,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
770 tend, tend, outputsel, string);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
771
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
772 // Events during last step
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
773 if (haveeventfunction)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
774 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
775 string, ypout, oldval, oldisterminal,
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
776 olddir, cont, temp, tout(cont-1),
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
777 yold, num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
778 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
779
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
780 N_VDestroy_Serial (dky);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
781 }
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
782
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
783 // Cleanup plotter
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
784 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
785 outputsel, "done");
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
786
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
787 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
788
29039
1aa69571a313 Use 1-based indexing for "ie" variable in ode15i/s (bug #59063).
Rik <rik@octave.org>
parents: 28952
diff changeset
789 // Index of Events (ie) variable must use 1-based indexing
1aa69571a313 Use 1-based indexing for "ie" variable in ode15i/s (bug #59063).
Rik <rik@octave.org>
parents: 28952
diff changeset
790 return ovl (tout, output, te, ye, ie + 1.0);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
791 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
792
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
793 bool
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
794 IDA::event (const octave_value& event_fcn,
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
795 ColumnVector& te, Matrix& ye, ColumnVector& ie, realtype tsol,
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
796 const ColumnVector& y, const std::string& flag,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
797 const ColumnVector& yp, ColumnVector& oldval,
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
798 ColumnVector& oldisterminal, ColumnVector& olddir,
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
799 octave_idx_type cont, octave_idx_type& temp, realtype told,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
800 ColumnVector& yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
801 const octave_idx_type num_event_args)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
802 {
31603
23520a50d74d maint: Review C++ files for style and coding conventions.
Rik <rik@octave.org>
parents: 30896
diff changeset
803 bool status = false;
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
804
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
805 octave_value_list args;
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
806 if (num_event_args == 2)
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
807 args = ovl (tsol, y);
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
808 else
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
809 args = ovl (tsol, y, yp);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
810
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
811 // 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
812 // temp is the number of events registered
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 if (flag == "init")
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
815 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
816 octave_value_list output = feval (event_fcn, args, 3);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
817 oldval = output(0).vector_value ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
818 oldisterminal = output(1).vector_value ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
819 olddir = output(2).vector_value ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
820 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
821 else if (flag == "")
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
822 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
823 ColumnVector index (0);
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
824 octave_value_list output = feval (event_fcn, args, 3);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
825 ColumnVector val = output(0).vector_value ();
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
826 ColumnVector isterminal = output(1).vector_value ();
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
827 ColumnVector dir = output(2).vector_value ();
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
828
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
829 // Get the index of the changed values
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
830 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
831 {
29060
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
832 // Check for sign change and whether a rising / falling edge
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
833 // either passes through zero or detaches from zero (bug #59063)
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
834 if ((dir(i) != -1
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
835 && ((val(i) >= 0 && oldval(i) < 0)
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
836 || (val(i) > 0 && oldval(i) <= 0))) // increasing
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
837 || (dir(i) != 1
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
838 && ((val(i) <= 0 && oldval(i) > 0)
b1b09b88585a ode15: Detect time events when time is a multiple of the output step size (bug #59063).
Markus Meisinger <chloros2@gmx.de>
parents: 29039
diff changeset
839 || (val(i) < 0 && oldval(i) >= 0)))) // decreasing
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
840 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
841 index.resize (index.numel () + 1);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
842 index (index.numel () - 1) = i;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
843 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
844 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
845
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
846 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
847 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
848 temp = 1; // register only the first event
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
849 te.resize (1);
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
850 ye.resize (1, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
851 ie.resize (1);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
852
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
853 // Linear interpolation
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
854 ie(0) = index(0);
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
855 te(0) = tsol - val (index(0)) * (tsol - told)
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
856 / (val (index(0)) - oldval (index(0)));
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
857
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
858 ColumnVector ytemp
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
859 = 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
860
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
861 for (octave_idx_type i = 0; i < m_num; i++)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
862 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
863
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
864 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
865 else if (index.numel () > 0)
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29969
diff changeset
866 // Not first step: register all events and test
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29969
diff changeset
867 // if stop integration or not
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
868 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
869 te.resize (temp + index.numel ());
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
870 ye.resize (temp + index.numel (), m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
871 ie.resize (temp + index.numel ());
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
872
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
873 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
874 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
875
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
876 if (isterminal (index(i)) == 1)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
877 status = 1; // Stop integration
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
878
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
879 // Linear interpolation
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
880 ie(temp+i) = index(i);
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
881 te(temp+i) = tsol - val(index(i)) * (tsol - told)
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
882 / (val(index(i)) - oldval(index(i)));
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
883
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
884 ColumnVector ytemp
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
885 = 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
886
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
887 for (octave_idx_type j = 0; j < m_num; j++)
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
888 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
889
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
890 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
891
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
892 temp += index.numel ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
893 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
894
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
895 // Update variables
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
896 yold = y;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
897 told = tsol;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
898 olddir = dir;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
899 oldval = val;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
900 oldisterminal = isterminal;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
901 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
902
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
903 return status;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
904 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
905
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
906 bool
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
907 IDA::interpolate (octave_idx_type& cont, Matrix& output, ColumnVector& tout,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
908 int refine, realtype tend, bool haveoutputfcn,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
909 bool haveoutputsel, const octave_value& output_fcn,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
910 ColumnVector& outputsel, bool haveeventfunction,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
911 const octave_value& event_fcn, ColumnVector& te,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
912 Matrix& ye, ColumnVector& ie, ColumnVector& oldval,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
913 ColumnVector& oldisterminal, ColumnVector& olddir,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
914 octave_idx_type& temp, ColumnVector& yold,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
915 const octave_idx_type num_event_args)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
916 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
917 realtype h = 0, tcur = 0;
31603
23520a50d74d maint: Review C++ files for style and coding conventions.
Rik <rik@octave.org>
parents: 30896
diff changeset
918 bool status = false;
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
919
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
920 N_Vector dky = N_VNew_Serial (m_num OCTAVE_SUNCONTEXT);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
921
30547
b876de975edf __ode15__: Adapt for changed API of SUNDIALS version 6 (bug #61701).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29969
diff changeset
922 N_Vector dkyp = N_VNew_Serial (m_num OCTAVE_SUNCONTEXT);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
923
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
924 ColumnVector yout (m_num);
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
925 ColumnVector ypout (m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
926 std::string string = "";
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
927
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
928 if (IDAGetLastStep (m_mem, &h) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
929 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
930
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
931 if (IDAGetCurrentTime (m_mem, &tcur) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
932 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
933
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
934 realtype tin = tcur - h;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
935
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
936 realtype step = h / refine;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
937
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
938 for (octave_idx_type i = 1;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
939 i < refine && tin + step * i < tend && status == 0;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
940 i++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
941 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
942 if (IDAGetDky (m_mem, tin + step*i, 0, dky) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
943 error ("IDA failed to interpolate y");
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
944
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
945 if (IDAGetDky (m_mem, tin + step*i, 1, dkyp) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
946 error ("IDA failed to interpolate yp");
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
947
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
948 cont += 1;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
949 output.resize (cont + 1, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
950 tout.resize (cont + 1);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
951
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
952 tout(cont) = tin + step * i;
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
953 yout = NVecToCol (dky, m_num);
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
954 ypout = NVecToCol (dkyp, m_num);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
955
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
956 for (octave_idx_type j = 0; j < m_num; j++)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
957 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
958
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
959 if (haveoutputfcn)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
960 status = IDA::outputfun (output_fcn, haveoutputsel, yout,
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
961 tout(cont), tend, outputsel, "");
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 if (haveeventfunction)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
964 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
965 yout, string, ypout, oldval,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
966 oldisterminal, olddir, cont, temp,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
967 tout(cont-1), yold, num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
968 }
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
969
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
970 N_VDestroy_Serial (dky);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
971
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
972 return status;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
973 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
974
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
975 bool
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
976 IDA::outputfun (const octave_value& output_fcn, bool haveoutputsel,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
977 const ColumnVector& yout, realtype tsol,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
978 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
979 const std::string& flag)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
980 {
31603
23520a50d74d maint: Review C++ files for style and coding conventions.
Rik <rik@octave.org>
parents: 30896
diff changeset
981 bool status = false;
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
982
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
983 octave_value_list output;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
984 output(2) = flag;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
985
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
986 ColumnVector ysel (outputsel.numel ());
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
987 if (haveoutputsel)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
988 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
989 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
990 ysel(i) = yout(outputsel(i));
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
991
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
992 output(1) = ysel;
22901
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 else
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
995 output(1) = yout;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
996
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
997 if (flag == "init")
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
998 {
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
999 ColumnVector toutput (2);
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1000 toutput(0) = tsol;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1001 toutput(1) = tend;
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1002 output(0) = toutput;
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1003
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
1004 feval (output_fcn, output, 0);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1005 }
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1006 else if (flag == "")
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1007 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1008 output(0) = tsol;
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
1009 octave_value_list val = feval (output_fcn, output, 1);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1010 status = val(0).bool_value ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1011 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1012 else
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25098
diff changeset
1013 {
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25098
diff changeset
1014 // Cleanup plotter
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1015 output(0) = tend;
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
1016 feval (output_fcn, output, 0);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1017 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1018
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1019 return status;
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 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1023 IDA::set_maxstep (realtype maxstep)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1024 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1025 if (IDASetMaxStep (m_mem, maxstep) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1026 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
1027 }
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1028
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1029 void
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1030 IDA::set_initialstep (realtype initialstep)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1031 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1032 if (IDASetInitStep (m_mem, initialstep) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1033 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
1034 }
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1035
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1036 void
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1037 IDA::set_maxorder (int maxorder)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1038 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1039 if (IDASetMaxOrd (m_mem, maxorder) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1040 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
1041 }
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1042
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1043 void
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1044 IDA::print_stat (void)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1045 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1046 long int nsteps = 0, netfails = 0, nrevals = 0;
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1047
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1048 if (IDAGetNumSteps (m_mem, &nsteps) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1049 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
1050
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1051 if (IDAGetNumErrTestFails (m_mem, &netfails) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1052 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
1053
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1054 if (IDAGetNumResEvals (m_mem, &nrevals) != 0)
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1055 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
1056
26000
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1057 octave_stdout << nsteps << " successful steps\n";
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1058 octave_stdout << netfails << " failed attempts\n";
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1059 octave_stdout << nrevals << " function evaluations\n";
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1060 // octave_stdout << " partial derivatives\n";
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1061 // octave_stdout << " LU decompositions\n";
97e63ba8a34c * __ode15__.cc (IDA::print_stat): Use octave_stdout instead of std::cout.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1062 // octave_stdout << " solutions of linear systems\n";
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1063 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1064
29966
7d9be634ac91 declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents: 29964
diff changeset
1065 static ColumnVector
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1066 ida_user_function (const ColumnVector& x, const ColumnVector& xdot,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1067 double t, const octave_value& ida_fc)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1068 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1069 octave_value_list tmp;
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1070
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1071 try
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1072 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
1073 tmp = 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
1074 }
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 29060
diff changeset
1075 catch (execution_exception& ee)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1076 {
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 29060
diff changeset
1077 err_user_supplied_eval (ee, "__ode15__");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1078 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1079
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1080 return tmp(0).vector_value ();
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1081 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1082
29966
7d9be634ac91 declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents: 29964
diff changeset
1083 static Matrix
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1084 ida_dense_jac (const ColumnVector& x, const ColumnVector& xdot,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1085 double t, double cj, const octave_value& ida_jc)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1086 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1087 octave_value_list tmp;
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1088
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1089 try
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1090 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
1091 tmp = 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
1092 }
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 29060
diff changeset
1093 catch (execution_exception& ee)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1094 {
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 29060
diff changeset
1095 err_user_supplied_eval (ee, "__ode15__");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1096 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1097
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1098 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
1099 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1100
29966
7d9be634ac91 declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents: 29964
diff changeset
1101 static SparseMatrix
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1102 ida_sparse_jac (const ColumnVector& x, const ColumnVector& xdot,
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1103 double t, double cj, const octave_value& ida_jc)
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 octave_value_list tmp;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1106
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1107 try
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1108 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23588
diff changeset
1109 tmp = 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
1110 }
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 29060
diff changeset
1111 catch (execution_exception& ee)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1112 {
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 29060
diff changeset
1113 err_user_supplied_eval (ee, "__ode15__");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1114 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1115
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1116 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
1117 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1118
29966
7d9be634ac91 declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents: 29964
diff changeset
1119 static Matrix
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1120 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
1121 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1122 return (*dfdy) + cj * (*dfdyp);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1123 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1124
29966
7d9be634ac91 declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents: 29964
diff changeset
1125 static SparseMatrix
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1126 ida_sparse_cell_jac (SparseMatrix *spdfdy, SparseMatrix *spdfdyp,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1127 double cj)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1128 {
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1129 return (*spdfdy) + cj * (*spdfdyp);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1130 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1131
29966
7d9be634ac91 declare extra functions in .oct file sources as static
John W. Eaton <jwe@octave.org>
parents: 29964
diff changeset
1132 static octave_value_list
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1133 do_ode15 (const octave_value& ida_fcn,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23432
diff changeset
1134 const ColumnVector& tspan,
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
1135 const octave_idx_type numt,
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1136 const realtype t0,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23432
diff changeset
1137 const ColumnVector& y0,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23432
diff changeset
1138 const ColumnVector& yp0,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1139 const octave_scalar_map& options,
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1140 const octave_idx_type num_event_args)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1141 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1142 octave_value_list retval;
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1143
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1144 // Create object
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1145 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
1146
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1147 // Set Jacobian
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1148 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
1149
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1150 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
1151
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1152 bool havejacfcn = options.getfield ("havejacfcn").bool_value ();
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1153
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1154 Matrix ida_dfdy, ida_dfdyp;
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1155 SparseMatrix ida_spdfdy, ida_spdfdyp;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1156
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1157 if (havejac)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1158 {
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1159 if (havejacfcn)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1160 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1161 octave_value ida_jac = options.getfield ("Jacobian");
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1162
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1163 if (havejacsparse)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1164 dae.set_jacobian (ida_jac, ida_sparse_jac);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1165 else
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1166 dae.set_jacobian (ida_jac, ida_dense_jac);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1167 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1168 else
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1169 {
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1170 Cell jaccell = options.getfield ("Jacobian").cell_value ();
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1171
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1172 if (havejacsparse)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1173 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1174 ida_spdfdy = jaccell(0).sparse_matrix_value ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1175 ida_spdfdyp = jaccell(1).sparse_matrix_value ();
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1176
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1177 dae.set_jacobian (&ida_spdfdy, &ida_spdfdyp,
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1178 ida_sparse_cell_jac);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1179 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1180 else
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 ida_dfdy = jaccell(0).matrix_value ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1183 ida_dfdyp = jaccell(1).matrix_value ();
27182
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1184
0beeb6817376 __ode15__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 27108
diff changeset
1185 dae.set_jacobian (&ida_dfdy, &ida_dfdyp, ida_dense_cell_jac);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1186 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1187 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1188 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1189
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1190 // Initialize IDA
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1191 dae.initialize ();
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1192
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1193 // Set tolerances
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1194 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
1195
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1196 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
1197
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1198 if (haveabstolvec)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1199 {
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1200 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
1201
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1202 dae.set_tolerance (abs_tol, rel_tol);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1203 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1204 else
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1205 {
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1206 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
1207
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1208 dae.set_tolerance (abs_tol, rel_tol);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1209 }
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1210
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1211 //Set max step
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1212 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
1213
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1214 dae.set_maxstep (maxstep);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1215
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1216 //Set initial step
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1217 if (! options.getfield ("InitialStep").isempty ())
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1218 {
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1219 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
1220
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1221 dae.set_initialstep (initialstep);
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1222 }
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1223
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1224 //Set max order FIXME: it doesn't work
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1225 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
1226
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1227 dae.set_maxorder (maxorder);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1228
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1229 //Set Refine
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1230 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
1231
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1232 bool haverefine = (refine > 1);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1233
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1234 octave_value output_fcn;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1235 ColumnVector outputsel;
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1236
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1237 // OutputFcn
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1238 bool haveoutputfunction
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1239 = options.getfield ("haveoutputfunction").bool_value ();
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1240
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1241 if (haveoutputfunction)
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1242 output_fcn = options.getfield ("OutputFcn");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1243
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1244 // OutputSel
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1245 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
1246
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1247 if (haveoutputsel)
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1248 outputsel = options.getfield ("OutputSel").vector_value ();
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1249
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1250 octave_value event_fcn;
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1251
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1252 // Events
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1253 bool haveeventfunction
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1254 = options.getfield ("haveeventfunction").bool_value ();
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1255
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1256 if (haveeventfunction)
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1257 event_fcn = options.getfield ("Events");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1258
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1259 // Set up linear solver
26893
25284d620919 Update DAE/IDE solvers to work with SUNDIALS 3 (bug #52475).
Bill Greene <w.h.greene@gmail.com>
parents: 26392
diff changeset
1260 dae.set_up (y0);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1261
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1262 // Integrate
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1263 retval = dae.integrate (numt, tspan, y0, yp0, refine,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1264 haverefine, haveoutputfunction,
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1265 output_fcn, haveoutputsel, outputsel,
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1266 haveeventfunction, event_fcn, num_event_args);
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1267
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1268 // Statistics
28694
d91935bd879c maint: Use Octave coding conventions in __ode15__.cc.
Rik <rik@octave.org>
parents: 27932
diff changeset
1269 bool havestats = options.getfield ("havestats").bool_value ();
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1270
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1271 if (havestats)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1272 dae.print_stat ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1273
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1274 return retval;
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1275 }
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
1276
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1277 #endif
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1278
22913
69342e4f0dcf * __ode15__.cc: Don't check nargout.
John W. Eaton <jwe@octave.org>
parents: 22912
diff changeset
1279 DEFUN_DLD (__ode15__, args, ,
69342e4f0dcf * __ode15__.cc: Don't check nargout.
John W. Eaton <jwe@octave.org>
parents: 22912
diff changeset
1280 doc: /* -*- texinfo -*-
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1281 @deftypefn {} {@var{t}, @var{y} =} __ode15__ (@var{fcn}, @var{tspan}, @var{y0}, @var{yp0}, @var{ode_opt}, @var{num_event_args})
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1282 Undocumented internal function.
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1283 @end deftypefn */)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1284 {
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1285
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1286 #if defined (HAVE_SUNDIALS)
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1287
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1288 // Check number of parameters
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1289 if (args.length () != 6)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1290 print_usage ();
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1291
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1292 // Check ODE function
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1293 octave_value ida_fcn = args(0);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1294
26907
1d3730539776 use octave_value instead of pointer to octave_function in __ode15__
John W. Eaton <jwe@octave.org>
parents: 26905
diff changeset
1295 if (! ida_fcn.is_function_handle ())
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1296 error ("__ode15__: FCN must be a function handle");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1297
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1298 // Check input tspan
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1299 ColumnVector tspan
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1300 = 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
1301
28716
9beec32ba3d6 Overhaul usage of integer types in __ode15__.cc (bug #58795).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28709
diff changeset
1302 octave_idx_type numt = tspan.numel ();
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1303
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1304 realtype t0 = tspan(0);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1305
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1306 if (numt < 2)
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1307 error ("__ode15__: TRANGE must contain at least 2 elements");
26392
9ec0a1e5d4d3 __ode15__.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
1308 else if (tspan.issorted () == UNSORTED || tspan(0) == tspan(numt - 1))
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1309 error ("__ode15__: TRANGE must be strictly monotonic");
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1310
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1311 // input y0 and yp0
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1312 ColumnVector y0
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1313 = 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
1314
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1315 ColumnVector yp0
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1316 = 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
1317
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1318
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1319 if (y0.numel () != yp0.numel ())
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1320 error ("__ode15__: initial state Y0 and YP0 must have the same length");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1321 else if (y0.numel () < 1)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1322 error ("__ode15__: initial state YP0 must be a vector or a scalar");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1323
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1324
23584
7ed6b258db91 maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents: 23577
diff changeset
1325 if (! args(4).isstruct ())
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1326 error ("__ode15__: ODE_OPT argument must be a structure");
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1327
22917
c1ac4ac3ebbc * __ode15__.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 22915
diff changeset
1328 octave_scalar_map options
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
1329 = args(4).xscalar_map_value ("__ode15__: ODE_OPT 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
1330
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1331 // Provided number of arguments in the ode callback function
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1332 octave_idx_type num_event_args
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1333 = args(5).xidx_type_value ("__ode15__: NUM_EVENT_ARGS must be an integer");
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1334
29296
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1335 if (num_event_args != 2 && num_event_args != 3)
7bf91e98bfc6 __ode15__(): Consider the correct number of input arguments in the event callback (bug #59477).
Markus Meisinger <chloros2@gmx.de>
parents: 29163
diff changeset
1336 error ("__ode15__: number of input arguments in event callback must be 2 or 3");
22910
23847979b91e maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22903
diff changeset
1337
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1338 return do_ode15 (ida_fcn, tspan, numt, t0, y0, yp0, options, num_event_args);
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1339
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1340 #else
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1341
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1342 octave_unused_parameter (args);
22911
82551783527f * __ode15__.cc: Fix compilation if Sundials is missing.
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
1343
22901
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1344 err_disabled_feature ("__ode15__", "sundials_ida, sundials_nvecserial");
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1345
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1346 #endif
4c56f3ffec04 Add functions ode15i and ode15s
Francesco Faccio <francesco.faccio@mail.polimi.it>
parents:
diff changeset
1347 }
26905
91e5d37aaba0 __ode15__.cc: mark internal function as tested for BIST purposes
Mike Miller <mtmiller@octave.org>
parents: 26903
diff changeset
1348
91e5d37aaba0 __ode15__.cc: mark internal function as tested for BIST purposes
Mike Miller <mtmiller@octave.org>
parents: 26903
diff changeset
1349 /*
91e5d37aaba0 __ode15__.cc: mark internal function as tested for BIST purposes
Mike Miller <mtmiller@octave.org>
parents: 26903
diff changeset
1350 ## No test needed for internal helper function.
91e5d37aaba0 __ode15__.cc: mark internal function as tested for BIST purposes
Mike Miller <mtmiller@octave.org>
parents: 26903
diff changeset
1351 %!assert (1)
91e5d37aaba0 __ode15__.cc: mark internal function as tested for BIST purposes
Mike Miller <mtmiller@octave.org>
parents: 26903
diff changeset
1352 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29445
diff changeset
1353
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31603
diff changeset
1354 OCTAVE_END_NAMESPACE(octave)