comparison libinterp/dldfcn/__ode15__.cc @ 30896:c9788d7f6e65

maint: Use "fcn" as preferred abbreviation for "function" in libinterp/. * __eigs__.cc, bsxfun.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, error.cc, graphics.cc, graphics.in.h, gzfstream.h, ls-hdf5.cc, lsode.cc, max.cc, oct-opengl.h, quad.cc, strfns.cc, utils.cc, utils.h, variables.cc, __ode15__.cc, gzip.cc, cdef-manager.cc, ov-fcn-handle.cc, ov-java.cc, ov-usr-fcn.cc, bp-table.cc, bp-table.h, lex.h, lex.ll, oct-parse.yy, pt-eval.cc: Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author Rik <rik@octave.org>
date Tue, 05 Apr 2022 08:33:58 -0700
parents 83f9f8bda883
children 23520a50d74d
comparison
equal deleted inserted replaced
30895:360d330cc30e 30896:c9788d7f6e65
167 SparseMatrix (*DAEJacCellSparse) (SparseMatrix *dfdy, 167 SparseMatrix (*DAEJacCellSparse) (SparseMatrix *dfdy,
168 SparseMatrix *dfdyp, realtype cj); 168 SparseMatrix *dfdyp, realtype cj);
169 169
170 //Default 170 //Default
171 IDA (void) 171 IDA (void)
172 : m_t0 (0.0), m_y0 (), m_yp0 (), m_havejac (false), m_havejacfun (false), 172 : m_t0 (0.0), m_y0 (), m_yp0 (), m_havejac (false), m_havejacfcn (false),
173 m_havejacsparse (false), m_mem (nullptr), m_num (), m_ida_fun (), 173 m_havejacsparse (false), m_mem (nullptr), m_num (), m_ida_fcn (),
174 m_ida_jac (), m_dfdy (nullptr), m_dfdyp (nullptr), m_spdfdy (nullptr), 174 m_ida_jac (), m_dfdy (nullptr), m_dfdyp (nullptr), m_spdfdy (nullptr),
175 m_spdfdyp (nullptr), m_fun (nullptr), m_jacfun (nullptr), 175 m_spdfdyp (nullptr), m_fcn (nullptr), m_jacfcn (nullptr),
176 m_jacspfun (nullptr), m_jacdcell (nullptr), m_jacspcell (nullptr), 176 m_jacspfcn (nullptr), m_jacdcell (nullptr), m_jacspcell (nullptr),
177 m_sunJacMatrix (nullptr), m_sunLinearSolver (nullptr) 177 m_sunJacMatrix (nullptr), m_sunLinearSolver (nullptr)
178 { } 178 { }
179 179
180 180
181 IDA (realtype t, ColumnVector y, ColumnVector yp, 181 IDA (realtype t, ColumnVector y, ColumnVector yp,
182 const octave_value& ida_fcn, DAERHSFuncIDA daefun) 182 const octave_value& ida_fcn, DAERHSFuncIDA daefun)
183 : m_t0 (t), m_y0 (y), m_yp0 (yp), m_havejac (false), m_havejacfun (false), 183 : m_t0 (t), m_y0 (y), m_yp0 (yp), m_havejac (false), m_havejacfcn (false),
184 m_havejacsparse (false), m_mem (nullptr), m_num (), m_ida_fun (ida_fcn), 184 m_havejacsparse (false), m_mem (nullptr), m_num (), m_ida_fcn (ida_fcn),
185 m_ida_jac (), m_dfdy (nullptr), m_dfdyp (nullptr), m_spdfdy (nullptr), 185 m_ida_jac (), m_dfdy (nullptr), m_dfdyp (nullptr), m_spdfdy (nullptr),
186 m_spdfdyp (nullptr), m_fun (daefun), m_jacfun (nullptr), 186 m_spdfdyp (nullptr), m_fcn (daefun), m_jacfcn (nullptr),
187 m_jacspfun (nullptr), m_jacdcell (nullptr), m_jacspcell (nullptr), 187 m_jacspfcn (nullptr), m_jacdcell (nullptr), m_jacspcell (nullptr),
188 m_sunJacMatrix (nullptr), m_sunLinearSolver (nullptr) 188 m_sunJacMatrix (nullptr), m_sunLinearSolver (nullptr)
189 { } 189 { }
190 190
191 191
192 ~IDA (void) 192 ~IDA (void)
200 } 200 }
201 201
202 IDA& 202 IDA&
203 set_jacobian (const octave_value& jac, DAEJacFuncDense j) 203 set_jacobian (const octave_value& jac, DAEJacFuncDense j)
204 { 204 {
205 m_jacfun = j; 205 m_jacfcn = j;
206 m_ida_jac = jac; 206 m_ida_jac = jac;
207 m_havejac = true; 207 m_havejac = true;
208 m_havejacfun = true; 208 m_havejacfcn = true;
209 m_havejacsparse = false; 209 m_havejacsparse = false;
210 210
211 return *this; 211 return *this;
212 } 212 }
213 213
214 IDA& 214 IDA&
215 set_jacobian (const octave_value& jac, DAEJacFuncSparse j) 215 set_jacobian (const octave_value& jac, DAEJacFuncSparse j)
216 { 216 {
217 m_jacspfun = j; 217 m_jacspfcn = j;
218 m_ida_jac = jac; 218 m_ida_jac = jac;
219 m_havejac = true; 219 m_havejac = true;
220 m_havejacfun = true; 220 m_havejacfcn = true;
221 m_havejacsparse = true; 221 m_havejacsparse = true;
222 222
223 return *this; 223 return *this;
224 } 224 }
225 225
228 { 228 {
229 m_jacdcell = j; 229 m_jacdcell = j;
230 m_dfdy = dy; 230 m_dfdy = dy;
231 m_dfdyp = dyp; 231 m_dfdyp = dyp;
232 m_havejac = true; 232 m_havejac = true;
233 m_havejacfun = false; 233 m_havejacfcn = false;
234 m_havejacsparse = false; 234 m_havejacsparse = false;
235 235
236 return *this; 236 return *this;
237 } 237 }
238 238
242 { 242 {
243 m_jacspcell = j; 243 m_jacspcell = j;
244 m_spdfdy = dy; 244 m_spdfdy = dy;
245 m_spdfdyp = dyp; 245 m_spdfdyp = dyp;
246 m_havejac = true; 246 m_havejac = true;
247 m_havejacfun = false; 247 m_havejacfcn = false;
248 m_havejacsparse = true; 248 m_havejacsparse = true;
249 249
250 return *this; 250 return *this;
251 } 251 }
252 252
356 356
357 realtype m_t0; 357 realtype m_t0;
358 ColumnVector m_y0; 358 ColumnVector m_y0;
359 ColumnVector m_yp0; 359 ColumnVector m_yp0;
360 bool m_havejac; 360 bool m_havejac;
361 bool m_havejacfun; 361 bool m_havejacfcn;
362 bool m_havejacsparse; 362 bool m_havejacsparse;
363 void *m_mem; 363 void *m_mem;
364 octave_f77_int_type m_num; 364 octave_f77_int_type m_num;
365 octave_value m_ida_fun; 365 octave_value m_ida_fcn;
366 octave_value m_ida_jac; 366 octave_value m_ida_jac;
367 Matrix *m_dfdy; 367 Matrix *m_dfdy;
368 Matrix *m_dfdyp; 368 Matrix *m_dfdyp;
369 SparseMatrix *m_spdfdy; 369 SparseMatrix *m_spdfdy;
370 SparseMatrix *m_spdfdyp; 370 SparseMatrix *m_spdfdyp;
371 DAERHSFuncIDA m_fun; 371 DAERHSFuncIDA m_fcn;
372 DAEJacFuncDense m_jacfun; 372 DAEJacFuncDense m_jacfcn;
373 DAEJacFuncSparse m_jacspfun; 373 DAEJacFuncSparse m_jacspfcn;
374 DAEJacCellDense m_jacdcell; 374 DAEJacCellDense m_jacdcell;
375 DAEJacCellSparse m_jacspcell; 375 DAEJacCellSparse m_jacspcell;
376 # if defined (HAVE_SUNDIALS_SUNCONTEXT) 376 # if defined (HAVE_SUNDIALS_SUNCONTEXT)
377 SUNContext m_sunContext; 377 SUNContext m_sunContext;
378 # endif 378 # endif
395 { 395 {
396 ColumnVector y = IDA::NVecToCol (yy, m_num); 396 ColumnVector y = IDA::NVecToCol (yy, m_num);
397 397
398 ColumnVector yp = IDA::NVecToCol (yyp, m_num); 398 ColumnVector yp = IDA::NVecToCol (yyp, m_num);
399 399
400 ColumnVector res = (*m_fun) (y, yp, t, m_ida_fun); 400 ColumnVector res = (*m_fcn) (y, yp, t, m_ida_fcn);
401 401
402 realtype *puntrr = nv_data_s (rr); 402 realtype *puntrr = nv_data_s (rr);
403 403
404 for (octave_idx_type i = 0; i < m_num; i++) 404 for (octave_idx_type i = 0; i < m_num; i++)
405 puntrr[i] = res(i); 405 puntrr[i] = res(i);
485 485
486 ColumnVector yp = NVecToCol (yyp, Neq); 486 ColumnVector yp = NVecToCol (yyp, Neq);
487 487
488 Matrix jac; 488 Matrix jac;
489 489
490 if (m_havejacfun) 490 if (m_havejacfcn)
491 jac = (*m_jacfun) (y, yp, t, cj, m_ida_jac); 491 jac = (*m_jacfcn) (y, yp, t, cj, m_ida_jac);
492 else 492 else
493 jac = (*m_jacdcell) (m_dfdy, m_dfdyp, cj); 493 jac = (*m_jacdcell) (m_dfdy, m_dfdyp, cj);
494 494
495 octave_f77_int_type num_jac = to_f77_int (jac.numel ()); 495 octave_f77_int_type num_jac = to_f77_int (jac.numel ());
496 std::copy (jac.fortran_vec (), 496 std::copy (jac.fortran_vec (),
508 508
509 ColumnVector yp = NVecToCol (yyp, m_num); 509 ColumnVector yp = NVecToCol (yyp, m_num);
510 510
511 SparseMatrix jac; 511 SparseMatrix jac;
512 512
513 if (m_havejacfun) 513 if (m_havejacfcn)
514 jac = (*m_jacspfun) (y, yp, t, cj, m_ida_jac); 514 jac = (*m_jacspfcn) (y, yp, t, cj, m_ida_jac);
515 else 515 else
516 jac = (*m_jacspcell) (m_spdfdy, m_spdfdyp, cj); 516 jac = (*m_jacspcell) (m_spdfdy, m_spdfdyp, cj);
517 517
518 # if defined (HAVE_SUNSPARSEMATRIX_REALLOCATE) 518 # if defined (HAVE_SUNSPARSEMATRIX_REALLOCATE)
519 octave_f77_int_type nnz = to_f77_int (jac.nnz ()); 519 octave_f77_int_type nnz = to_f77_int (jac.nnz ());
1147 // Set Jacobian 1147 // Set Jacobian
1148 bool havejac = options.getfield ("havejac").bool_value (); 1148 bool havejac = options.getfield ("havejac").bool_value ();
1149 1149
1150 bool havejacsparse = options.getfield ("havejacsparse").bool_value (); 1150 bool havejacsparse = options.getfield ("havejacsparse").bool_value ();
1151 1151
1152 bool havejacfun = options.getfield ("havejacfun").bool_value (); 1152 bool havejacfcn = options.getfield ("havejacfcn").bool_value ();
1153 1153
1154 Matrix ida_dfdy, ida_dfdyp; 1154 Matrix ida_dfdy, ida_dfdyp;
1155 SparseMatrix ida_spdfdy, ida_spdfdyp; 1155 SparseMatrix ida_spdfdy, ida_spdfdyp;
1156 1156
1157 if (havejac) 1157 if (havejac)
1158 { 1158 {
1159 if (havejacfun) 1159 if (havejacfcn)
1160 { 1160 {
1161 octave_value ida_jac = options.getfield ("Jacobian"); 1161 octave_value ida_jac = options.getfield ("Jacobian");
1162 1162
1163 if (havejacsparse) 1163 if (havejacsparse)
1164 dae.set_jacobian (ida_jac, ida_sparse_jac); 1164 dae.set_jacobian (ida_jac, ida_sparse_jac);
1276 1276
1277 #endif 1277 #endif
1278 1278
1279 DEFUN_DLD (__ode15__, args, , 1279 DEFUN_DLD (__ode15__, args, ,
1280 doc: /* -*- texinfo -*- 1280 doc: /* -*- texinfo -*-
1281 @deftypefn {} {@var{t}, @var{y} =} __ode15__ (@var{fun}, @var{tspan}, @var{y0}, @var{yp0}, @var{options}, @var{num_event_args}) 1281 @deftypefn {} {@var{t}, @var{y} =} __ode15__ (@var{fcn}, @var{tspan}, @var{y0}, @var{yp0}, @var{ode_opt}, @var{num_event_args})
1282 Undocumented internal function. 1282 Undocumented internal function.
1283 @end deftypefn */) 1283 @end deftypefn */)
1284 { 1284 {
1285 1285
1286 #if defined (HAVE_SUNDIALS) 1286 #if defined (HAVE_SUNDIALS)
1287 1287
1288 // Check number of parameters 1288 // Check number of parameters
1289 if (args.length () != 6) 1289 if (args.length () != 6)
1290 print_usage (); 1290 print_usage ();
1291 1291
1292 // Check odefun 1292 // Check ODE function
1293 octave_value ida_fcn = args(0); 1293 octave_value ida_fcn = args(0);
1294 1294
1295 if (! ida_fcn.is_function_handle ()) 1295 if (! ida_fcn.is_function_handle ())
1296 error ("__ode15__: odefun must be a function handle"); 1296 error ("__ode15__: FCN must be a function handle");
1297 1297
1298 // Check input tspan 1298 // Check input tspan
1299 ColumnVector tspan 1299 ColumnVector tspan
1300 = args(1).xvector_value ("__ode15__: TRANGE must be a vector of numbers"); 1300 = args(1).xvector_value ("__ode15__: TRANGE must be a vector of numbers");
1301 1301
1302 octave_idx_type numt = tspan.numel (); 1302 octave_idx_type numt = tspan.numel ();
1303 1303
1304 realtype t0 = tspan (0); 1304 realtype t0 = tspan(0);
1305 1305
1306 if (numt < 2) 1306 if (numt < 2)
1307 error ("__ode15__: TRANGE must contain at least 2 elements"); 1307 error ("__ode15__: TRANGE must contain at least 2 elements");
1308 else if (tspan.issorted () == UNSORTED || tspan(0) == tspan(numt - 1)) 1308 else if (tspan.issorted () == UNSORTED || tspan(0) == tspan(numt - 1))
1309 error ("__ode15__: TRANGE must be strictly monotonic"); 1309 error ("__ode15__: TRANGE must be strictly monotonic");
1310 1310
1311 // input y0 and yp0 1311 // input y0 and yp0
1312 ColumnVector y0 1312 ColumnVector y0
1313 = args(2).xvector_value ("__ode15__: initial state y0 must be a vector"); 1313 = args(2).xvector_value ("__ode15__: initial state Y0 must be a vector");
1314 1314
1315 ColumnVector yp0 1315 ColumnVector yp0
1316 = args(3).xvector_value ("__ode15__: initial state yp0 must be a vector"); 1316 = args(3).xvector_value ("__ode15__: initial state YP0 must be a vector");
1317 1317
1318 1318
1319 if (y0.numel () != yp0.numel ()) 1319 if (y0.numel () != yp0.numel ())
1320 error ("__ode15__: initial state y0 and yp0 must have the same length"); 1320 error ("__ode15__: initial state Y0 and YP0 must have the same length");
1321 else if (y0.numel () < 1) 1321 else if (y0.numel () < 1)
1322 error ("__ode15__: initial state yp0 must be a vector or a scalar"); 1322 error ("__ode15__: initial state YP0 must be a vector or a scalar");
1323 1323
1324 1324
1325 if (! args(4).isstruct ()) 1325 if (! args(4).isstruct ())
1326 error ("__ode15__: OPTS argument must be a structure"); 1326 error ("__ode15__: ODE_OPT argument must be a structure");
1327 1327
1328 octave_scalar_map options 1328 octave_scalar_map options
1329 = args(4).xscalar_map_value ("__ode15__: OPTS argument must be a scalar structure"); 1329 = args(4).xscalar_map_value ("__ode15__: ODE_OPT argument must be a scalar structure");
1330 1330
1331 // Provided number of arguments in the ode callback function 1331 // Provided number of arguments in the ode callback function
1332 octave_idx_type num_event_args 1332 octave_idx_type num_event_args
1333 = args(5).xidx_type_value ("__ode15__: NUM_EVENT_ARGS must be an integer"); 1333 = args(5).xidx_type_value ("__ode15__: NUM_EVENT_ARGS must be an integer");
1334 1334