File: ODEIV.pm.2.5

package info (click to toggle)
libmath-gsl-perl 0.45-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 192,156 kB
  • sloc: ansic: 895,524; perl: 24,682; makefile: 12
file content (698 lines) | stat: -rw-r--r-- 28,038 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.2.0
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

package Math::GSL::ODEIV;
use base qw(Exporter);
use base qw(DynaLoader);
package Math::GSL::ODEIVc;
bootstrap Math::GSL::ODEIV;
package Math::GSL::ODEIV;
@EXPORT = qw();

# ---------- BASE METHODS -------------

package Math::GSL::ODEIV;

sub TIEHASH {
    my ($classname,$obj) = @_;
    return bless $obj, $classname;
}

sub CLEAR { }

sub FIRSTKEY { }

sub NEXTKEY { }

sub FETCH {
    my ($self,$field) = @_;
    my $member_func = "swig_${field}_get";
    $self->$member_func();
}

sub STORE {
    my ($self,$field,$newval) = @_;
    my $member_func = "swig_${field}_set";
    $self->$member_func($newval);
}

sub this {
    my $ptr = shift;
    return tied(%$ptr);
}


# ------- FUNCTION WRAPPERS --------

package Math::GSL::ODEIV;

*gsl_error = *Math::GSL::ODEIVc::gsl_error;
*gsl_stream_printf = *Math::GSL::ODEIVc::gsl_stream_printf;
*gsl_strerror = *Math::GSL::ODEIVc::gsl_strerror;
*gsl_set_error_handler = *Math::GSL::ODEIVc::gsl_set_error_handler;
*gsl_set_error_handler_off = *Math::GSL::ODEIVc::gsl_set_error_handler_off;
*gsl_set_stream_handler = *Math::GSL::ODEIVc::gsl_set_stream_handler;
*gsl_set_stream = *Math::GSL::ODEIVc::gsl_set_stream;
*gsl_odeiv_step_alloc = *Math::GSL::ODEIVc::gsl_odeiv_step_alloc;
*gsl_odeiv_step_reset = *Math::GSL::ODEIVc::gsl_odeiv_step_reset;
*gsl_odeiv_step_free = *Math::GSL::ODEIVc::gsl_odeiv_step_free;
*gsl_odeiv_step_name = *Math::GSL::ODEIVc::gsl_odeiv_step_name;
*gsl_odeiv_step_order = *Math::GSL::ODEIVc::gsl_odeiv_step_order;
*gsl_odeiv_step_apply = *Math::GSL::ODEIVc::gsl_odeiv_step_apply;
*gsl_odeiv_control_alloc = *Math::GSL::ODEIVc::gsl_odeiv_control_alloc;
*gsl_odeiv_control_init = *Math::GSL::ODEIVc::gsl_odeiv_control_init;
*gsl_odeiv_control_free = *Math::GSL::ODEIVc::gsl_odeiv_control_free;
*gsl_odeiv_control_hadjust = *Math::GSL::ODEIVc::gsl_odeiv_control_hadjust;
*gsl_odeiv_control_name = *Math::GSL::ODEIVc::gsl_odeiv_control_name;
*gsl_odeiv_control_standard_new = *Math::GSL::ODEIVc::gsl_odeiv_control_standard_new;
*gsl_odeiv_control_y_new = *Math::GSL::ODEIVc::gsl_odeiv_control_y_new;
*gsl_odeiv_control_yp_new = *Math::GSL::ODEIVc::gsl_odeiv_control_yp_new;
*gsl_odeiv_control_scaled_new = *Math::GSL::ODEIVc::gsl_odeiv_control_scaled_new;
*gsl_odeiv_evolve_alloc = *Math::GSL::ODEIVc::gsl_odeiv_evolve_alloc;
*gsl_odeiv_evolve_reset = *Math::GSL::ODEIVc::gsl_odeiv_evolve_reset;
*gsl_odeiv_evolve_free = *Math::GSL::ODEIVc::gsl_odeiv_evolve_free;
*gsl_odeiv_evolve_apply = *Math::GSL::ODEIVc::gsl_odeiv_evolve_apply;

############# Class : Math::GSL::ODEIV::gsl_odeiv_system ##############

package Math::GSL::ODEIV::gsl_odeiv_system;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::ODEIV );
%OWNER = ();
%ITERATORS = ();
*swig_function_get = *Math::GSL::ODEIVc::gsl_odeiv_system_function_get;
*swig_function_set = *Math::GSL::ODEIVc::gsl_odeiv_system_function_set;
*swig_jacobian_get = *Math::GSL::ODEIVc::gsl_odeiv_system_jacobian_get;
*swig_jacobian_set = *Math::GSL::ODEIVc::gsl_odeiv_system_jacobian_set;
*swig_dimension_get = *Math::GSL::ODEIVc::gsl_odeiv_system_dimension_get;
*swig_dimension_set = *Math::GSL::ODEIVc::gsl_odeiv_system_dimension_set;
*swig_params_get = *Math::GSL::ODEIVc::gsl_odeiv_system_params_get;
*swig_params_set = *Math::GSL::ODEIVc::gsl_odeiv_system_params_set;
sub new {
    my $pkg = shift;
    my $self = Math::GSL::ODEIVc::new_gsl_odeiv_system(@_);
    bless $self, $pkg if defined($self);
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        Math::GSL::ODEIVc::delete_gsl_odeiv_system($self);
        delete $OWNER{$self};
    }
}

sub DISOWN {
    my $self = shift;
    my $ptr = tied(%$self);
    delete $OWNER{$ptr};
}

sub ACQUIRE {
    my $self = shift;
    my $ptr = tied(%$self);
    $OWNER{$ptr} = 1;
}


############# Class : Math::GSL::ODEIV::gsl_odeiv_step_type ##############

package Math::GSL::ODEIV::gsl_odeiv_step_type;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::ODEIV );
%OWNER = ();
%ITERATORS = ();
*swig_name_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_name_get;
*swig_name_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_name_set;
*swig_can_use_dydt_in_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_can_use_dydt_in_get;
*swig_can_use_dydt_in_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_can_use_dydt_in_set;
*swig_gives_exact_dydt_out_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_gives_exact_dydt_out_get;
*swig_gives_exact_dydt_out_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_gives_exact_dydt_out_set;
*swig_alloc_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_alloc_get;
*swig_alloc_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_alloc_set;
*swig_apply_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_apply_get;
*swig_apply_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_apply_set;
*swig_reset_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_reset_get;
*swig_reset_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_reset_set;
*swig_order_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_order_get;
*swig_order_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_order_set;
*swig_free_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_free_get;
*swig_free_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_free_set;
sub new {
    my $pkg = shift;
    my $self = Math::GSL::ODEIVc::new_gsl_odeiv_step_type(@_);
    bless $self, $pkg if defined($self);
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        Math::GSL::ODEIVc::delete_gsl_odeiv_step_type($self);
        delete $OWNER{$self};
    }
}

sub DISOWN {
    my $self = shift;
    my $ptr = tied(%$self);
    delete $OWNER{$ptr};
}

sub ACQUIRE {
    my $self = shift;
    my $ptr = tied(%$self);
    $OWNER{$ptr} = 1;
}


############# Class : Math::GSL::ODEIV::gsl_odeiv_step ##############

package Math::GSL::ODEIV::gsl_odeiv_step;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::ODEIV );
%OWNER = ();
%ITERATORS = ();
*swig_type_get = *Math::GSL::ODEIVc::gsl_odeiv_step_type_get;
*swig_type_set = *Math::GSL::ODEIVc::gsl_odeiv_step_type_set;
*swig_dimension_get = *Math::GSL::ODEIVc::gsl_odeiv_step_dimension_get;
*swig_dimension_set = *Math::GSL::ODEIVc::gsl_odeiv_step_dimension_set;
*swig_state_get = *Math::GSL::ODEIVc::gsl_odeiv_step_state_get;
*swig_state_set = *Math::GSL::ODEIVc::gsl_odeiv_step_state_set;
sub new {
    my $pkg = shift;
    my $self = Math::GSL::ODEIVc::new_gsl_odeiv_step(@_);
    bless $self, $pkg if defined($self);
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        Math::GSL::ODEIVc::delete_gsl_odeiv_step($self);
        delete $OWNER{$self};
    }
}

sub DISOWN {
    my $self = shift;
    my $ptr = tied(%$self);
    delete $OWNER{$ptr};
}

sub ACQUIRE {
    my $self = shift;
    my $ptr = tied(%$self);
    $OWNER{$ptr} = 1;
}


############# Class : Math::GSL::ODEIV::gsl_odeiv_control_type ##############

package Math::GSL::ODEIV::gsl_odeiv_control_type;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::ODEIV );
%OWNER = ();
%ITERATORS = ();
*swig_name_get = *Math::GSL::ODEIVc::gsl_odeiv_control_type_name_get;
*swig_name_set = *Math::GSL::ODEIVc::gsl_odeiv_control_type_name_set;
*swig_alloc_get = *Math::GSL::ODEIVc::gsl_odeiv_control_type_alloc_get;
*swig_alloc_set = *Math::GSL::ODEIVc::gsl_odeiv_control_type_alloc_set;
*swig_init_get = *Math::GSL::ODEIVc::gsl_odeiv_control_type_init_get;
*swig_init_set = *Math::GSL::ODEIVc::gsl_odeiv_control_type_init_set;
*swig_hadjust_get = *Math::GSL::ODEIVc::gsl_odeiv_control_type_hadjust_get;
*swig_hadjust_set = *Math::GSL::ODEIVc::gsl_odeiv_control_type_hadjust_set;
*swig_free_get = *Math::GSL::ODEIVc::gsl_odeiv_control_type_free_get;
*swig_free_set = *Math::GSL::ODEIVc::gsl_odeiv_control_type_free_set;
sub new {
    my $pkg = shift;
    my $self = Math::GSL::ODEIVc::new_gsl_odeiv_control_type(@_);
    bless $self, $pkg if defined($self);
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        Math::GSL::ODEIVc::delete_gsl_odeiv_control_type($self);
        delete $OWNER{$self};
    }
}

sub DISOWN {
    my $self = shift;
    my $ptr = tied(%$self);
    delete $OWNER{$ptr};
}

sub ACQUIRE {
    my $self = shift;
    my $ptr = tied(%$self);
    $OWNER{$ptr} = 1;
}


############# Class : Math::GSL::ODEIV::gsl_odeiv_control ##############

package Math::GSL::ODEIV::gsl_odeiv_control;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::ODEIV );
%OWNER = ();
%ITERATORS = ();
*swig_type_get = *Math::GSL::ODEIVc::gsl_odeiv_control_type_get;
*swig_type_set = *Math::GSL::ODEIVc::gsl_odeiv_control_type_set;
*swig_state_get = *Math::GSL::ODEIVc::gsl_odeiv_control_state_get;
*swig_state_set = *Math::GSL::ODEIVc::gsl_odeiv_control_state_set;
sub new {
    my $pkg = shift;
    my $self = Math::GSL::ODEIVc::new_gsl_odeiv_control(@_);
    bless $self, $pkg if defined($self);
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        Math::GSL::ODEIVc::delete_gsl_odeiv_control($self);
        delete $OWNER{$self};
    }
}

sub DISOWN {
    my $self = shift;
    my $ptr = tied(%$self);
    delete $OWNER{$ptr};
}

sub ACQUIRE {
    my $self = shift;
    my $ptr = tied(%$self);
    $OWNER{$ptr} = 1;
}


############# Class : Math::GSL::ODEIV::gsl_odeiv_evolve ##############

package Math::GSL::ODEIV::gsl_odeiv_evolve;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::ODEIV );
%OWNER = ();
%ITERATORS = ();
*swig_dimension_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_dimension_get;
*swig_dimension_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_dimension_set;
*swig_y0_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_y0_get;
*swig_y0_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_y0_set;
*swig_yerr_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_yerr_get;
*swig_yerr_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_yerr_set;
*swig_dydt_in_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_dydt_in_get;
*swig_dydt_in_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_dydt_in_set;
*swig_dydt_out_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_dydt_out_get;
*swig_dydt_out_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_dydt_out_set;
*swig_last_step_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_last_step_get;
*swig_last_step_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_last_step_set;
*swig_count_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_count_get;
*swig_count_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_count_set;
*swig_failed_steps_get = *Math::GSL::ODEIVc::gsl_odeiv_evolve_failed_steps_get;
*swig_failed_steps_set = *Math::GSL::ODEIVc::gsl_odeiv_evolve_failed_steps_set;
sub new {
    my $pkg = shift;
    my $self = Math::GSL::ODEIVc::new_gsl_odeiv_evolve(@_);
    bless $self, $pkg if defined($self);
}

sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        Math::GSL::ODEIVc::delete_gsl_odeiv_evolve($self);
        delete $OWNER{$self};
    }
}

sub DISOWN {
    my $self = shift;
    my $ptr = tied(%$self);
    delete $OWNER{$ptr};
}

sub ACQUIRE {
    my $self = shift;
    my $ptr = tied(%$self);
    $OWNER{$ptr} = 1;
}


# ------- VARIABLE STUBS --------

package Math::GSL::ODEIV;

*GSL_VERSION = *Math::GSL::ODEIVc::GSL_VERSION;
*GSL_MAJOR_VERSION = *Math::GSL::ODEIVc::GSL_MAJOR_VERSION;
*GSL_MINOR_VERSION = *Math::GSL::ODEIVc::GSL_MINOR_VERSION;
*GSL_POSZERO = *Math::GSL::ODEIVc::GSL_POSZERO;
*GSL_NEGZERO = *Math::GSL::ODEIVc::GSL_NEGZERO;
*GSL_SUCCESS = *Math::GSL::ODEIVc::GSL_SUCCESS;
*GSL_FAILURE = *Math::GSL::ODEIVc::GSL_FAILURE;
*GSL_CONTINUE = *Math::GSL::ODEIVc::GSL_CONTINUE;
*GSL_EDOM = *Math::GSL::ODEIVc::GSL_EDOM;
*GSL_ERANGE = *Math::GSL::ODEIVc::GSL_ERANGE;
*GSL_EFAULT = *Math::GSL::ODEIVc::GSL_EFAULT;
*GSL_EINVAL = *Math::GSL::ODEIVc::GSL_EINVAL;
*GSL_EFAILED = *Math::GSL::ODEIVc::GSL_EFAILED;
*GSL_EFACTOR = *Math::GSL::ODEIVc::GSL_EFACTOR;
*GSL_ESANITY = *Math::GSL::ODEIVc::GSL_ESANITY;
*GSL_ENOMEM = *Math::GSL::ODEIVc::GSL_ENOMEM;
*GSL_EBADFUNC = *Math::GSL::ODEIVc::GSL_EBADFUNC;
*GSL_ERUNAWAY = *Math::GSL::ODEIVc::GSL_ERUNAWAY;
*GSL_EMAXITER = *Math::GSL::ODEIVc::GSL_EMAXITER;
*GSL_EZERODIV = *Math::GSL::ODEIVc::GSL_EZERODIV;
*GSL_EBADTOL = *Math::GSL::ODEIVc::GSL_EBADTOL;
*GSL_ETOL = *Math::GSL::ODEIVc::GSL_ETOL;
*GSL_EUNDRFLW = *Math::GSL::ODEIVc::GSL_EUNDRFLW;
*GSL_EOVRFLW = *Math::GSL::ODEIVc::GSL_EOVRFLW;
*GSL_ELOSS = *Math::GSL::ODEIVc::GSL_ELOSS;
*GSL_EROUND = *Math::GSL::ODEIVc::GSL_EROUND;
*GSL_EBADLEN = *Math::GSL::ODEIVc::GSL_EBADLEN;
*GSL_ENOTSQR = *Math::GSL::ODEIVc::GSL_ENOTSQR;
*GSL_ESING = *Math::GSL::ODEIVc::GSL_ESING;
*GSL_EDIVERGE = *Math::GSL::ODEIVc::GSL_EDIVERGE;
*GSL_EUNSUP = *Math::GSL::ODEIVc::GSL_EUNSUP;
*GSL_EUNIMPL = *Math::GSL::ODEIVc::GSL_EUNIMPL;
*GSL_ECACHE = *Math::GSL::ODEIVc::GSL_ECACHE;
*GSL_ETABLE = *Math::GSL::ODEIVc::GSL_ETABLE;
*GSL_ENOPROG = *Math::GSL::ODEIVc::GSL_ENOPROG;
*GSL_ENOPROGJ = *Math::GSL::ODEIVc::GSL_ENOPROGJ;
*GSL_ETOLF = *Math::GSL::ODEIVc::GSL_ETOLF;
*GSL_ETOLX = *Math::GSL::ODEIVc::GSL_ETOLX;
*GSL_ETOLG = *Math::GSL::ODEIVc::GSL_ETOLG;
*GSL_EOF = *Math::GSL::ODEIVc::GSL_EOF;

my %__gsl_odeiv_step_rk2_hash;
tie %__gsl_odeiv_step_rk2_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rk2;
$gsl_odeiv_step_rk2= \%__gsl_odeiv_step_rk2_hash;
bless $gsl_odeiv_step_rk2, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rk4_hash;
tie %__gsl_odeiv_step_rk4_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rk4;
$gsl_odeiv_step_rk4= \%__gsl_odeiv_step_rk4_hash;
bless $gsl_odeiv_step_rk4, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rkf45_hash;
tie %__gsl_odeiv_step_rkf45_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rkf45;
$gsl_odeiv_step_rkf45= \%__gsl_odeiv_step_rkf45_hash;
bless $gsl_odeiv_step_rkf45, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rkck_hash;
tie %__gsl_odeiv_step_rkck_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rkck;
$gsl_odeiv_step_rkck= \%__gsl_odeiv_step_rkck_hash;
bless $gsl_odeiv_step_rkck, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rk8pd_hash;
tie %__gsl_odeiv_step_rk8pd_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rk8pd;
$gsl_odeiv_step_rk8pd= \%__gsl_odeiv_step_rk8pd_hash;
bless $gsl_odeiv_step_rk8pd, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rk2imp_hash;
tie %__gsl_odeiv_step_rk2imp_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rk2imp;
$gsl_odeiv_step_rk2imp= \%__gsl_odeiv_step_rk2imp_hash;
bless $gsl_odeiv_step_rk2imp, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rk2simp_hash;
tie %__gsl_odeiv_step_rk2simp_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rk2simp;
$gsl_odeiv_step_rk2simp= \%__gsl_odeiv_step_rk2simp_hash;
bless $gsl_odeiv_step_rk2simp, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_rk4imp_hash;
tie %__gsl_odeiv_step_rk4imp_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_rk4imp;
$gsl_odeiv_step_rk4imp= \%__gsl_odeiv_step_rk4imp_hash;
bless $gsl_odeiv_step_rk4imp, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_bsimp_hash;
tie %__gsl_odeiv_step_bsimp_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_bsimp;
$gsl_odeiv_step_bsimp= \%__gsl_odeiv_step_bsimp_hash;
bless $gsl_odeiv_step_bsimp, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_gear1_hash;
tie %__gsl_odeiv_step_gear1_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_gear1;
$gsl_odeiv_step_gear1= \%__gsl_odeiv_step_gear1_hash;
bless $gsl_odeiv_step_gear1, Math::GSL::ODEIV::gsl_odeiv_step_type;

my %__gsl_odeiv_step_gear2_hash;
tie %__gsl_odeiv_step_gear2_hash,"Math::GSL::ODEIV::gsl_odeiv_step_type", $Math::GSL::ODEIVc::gsl_odeiv_step_gear2;
$gsl_odeiv_step_gear2= \%__gsl_odeiv_step_gear2_hash;
bless $gsl_odeiv_step_gear2, Math::GSL::ODEIV::gsl_odeiv_step_type;
*GSL_ODEIV_HADJ_INC = *Math::GSL::ODEIVc::GSL_ODEIV_HADJ_INC;
*GSL_ODEIV_HADJ_NIL = *Math::GSL::ODEIVc::GSL_ODEIV_HADJ_NIL;
*GSL_ODEIV_HADJ_DEC = *Math::GSL::ODEIVc::GSL_ODEIV_HADJ_DEC;

    package Math::GSL::ODEIV::gsl_odeiv_system;

    sub new {
        my ($class, $func, $jac, $dim, $params ) = @_;

        my $check_ref = sub {
            if ( (ref $_[0]) ne $_[1] ) {
                die sprintf 'Usage: %s:new( $func, $jac, $dim, $params ). '
                . 'Argument %s is not %s reference',
                __PACKAGE__, $_[2], $_[3];
            }
        };
        my $check_subref = sub {
            $check_ref->($_[0], "CODE", $_[1], "code");
        };
        my $check_hashref = sub {
            $check_ref->($_[0], "HASH", $_[1], "hash");
        };
        $check_subref->($func, '$func');
        $check_subref->($jac, '$jac');
        $check_hashref->($params, '$params');
        return bless { func => $func, jac => $jac, dim => $dim, params => $params },
            $class;
    }

package Math::GSL::ODEIV;

@EXPORT_OK = qw/
               gsl_odeiv_step_alloc
               gsl_odeiv_step_reset
               gsl_odeiv_step_free
               gsl_odeiv_step_name
               gsl_odeiv_step_order
               gsl_odeiv_step_apply
               gsl_odeiv_control_alloc
               gsl_odeiv_control_init
               gsl_odeiv_control_free
               gsl_odeiv_control_hadjust
               gsl_odeiv_control_name
               gsl_odeiv_control_standard_new
               gsl_odeiv_control_y_new
               gsl_odeiv_control_yp_new
               gsl_odeiv_control_scaled_new
               gsl_odeiv_evolve_alloc
               gsl_odeiv_evolve_apply
               gsl_odeiv_evolve_reset
               gsl_odeiv_evolve_free
               $gsl_odeiv_step_rk2
               $gsl_odeiv_step_rk4
               $gsl_odeiv_step_rkf45
               $gsl_odeiv_step_rkck
               $gsl_odeiv_step_rk8pd
               $gsl_odeiv_step_rk2imp
               $gsl_odeiv_step_rk2simp
               $gsl_odeiv_step_rk4imp
               $gsl_odeiv_step_bsimp
               $gsl_odeiv_step_gear1
               $gsl_odeiv_step_gear2
               $GSL_ODEIV_HADJ_INC
               $GSL_ODEIV_HADJ_NIL
               $GSL_ODEIV_HADJ_DEC
               $gsl_odeiv_control_standard
	/;
%EXPORT_TAGS = ( all => [ @EXPORT_OK ] );

__END__

=encoding utf8

=head1 NAME

Math::GSL::ODEIV - functions for solving ordinary differential equation (ODE) initial value problems

=head1 SYNOPSIS

 use Math::GSL::ODEIV qw /:all/;

=head1 DESCRIPTION

Here is a list of all the functions in this module :

=over

=item * C<gsl_odeiv_step_alloc($T, $dim)> - This function returns a pointer to a newly allocated instance of a stepping function of type $T for a system of $dim dimensions.$T must be one of the step type constant above.

=item * C<gsl_odeiv_step_reset($s)> - This function resets the stepping function $s. It should be used whenever the next use of s will not be a continuation of a previous step.

=item * C<gsl_odeiv_step_free($s)> - This function frees all the memory associated with the stepping function $s.

=item * C<gsl_odeiv_step_name($s)> - This function returns a pointer to the name of the stepping function.

=item * C<gsl_odeiv_step_order($s)> - This function returns the order of the stepping function on the previous step. This order can vary if the stepping function itself is adaptive.

=item * C<gsl_odeiv_step_apply >

=item * C<gsl_odeiv_control_alloc($T)> - This function returns a pointer to a newly allocated instance of a control function of type $T. This function is only needed for defining new types of control functions. For most purposes the standard control functions described above should be sufficient. $T is a gsl_odeiv_control_type.

=item * C<gsl_odeiv_control_init($c, $eps_abs, $eps_rel, $a_y, $a_dydt) > - This function initializes the control function c with the parameters eps_abs (absolute error), eps_rel (relative error), a_y (scaling factor for y) and a_dydt (scaling factor for derivatives).

=item * C<gsl_odeiv_control_free >

=item * C<gsl_odeiv_control_hadjust >

=item * C<gsl_odeiv_control_name >

=item * C<gsl_odeiv_control_standard_new($eps_abs, $eps_rel, $a_y, $a_dydt)> - The standard control object is a four parameter heuristic based on absolute and relative errors $eps_abs and $eps_rel, and scaling factors $a_y and $a_dydt for the system state y(t) and derivatives y'(t) respectively. The step-size adjustment procedure for this method begins by computing the desired error level D_i for each component, D_i = eps_abs + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) and comparing it with the observed error E_i = |yerr_i|. If the observed error E exceeds the desired error level D by more than 10% for any component then the method reduces the step-size by an appropriate factor, h_new = h_old * S * (E/D)^(-1/q) where q is the consistency order of the method (e.g. q=4 for 4(5) embedded RK), and S is a safety factor of 0.9. The ratio E/D is taken to be the maximum of the ratios E_i/D_i. If the observed error E is less than 50% of the desired error level D for the maximum ratio E_i/D_i then the algorithm takes the opportunity to increase the step-size to bring the error in line with the desired level, h_new = h_old * S * (E/D)^(-1/(q+1)) This encompasses all the standard error scaling methods. To avoid uncontrolled changes in the stepsize, the overall scaling factor is limited to the range 1/5 to 5.

=item * C<gsl_odeiv_control_y_new($eps_abs, $eps_rel)> - This function creates a new control object which will keep the local error on each step within an absolute error of $eps_abs and relative error of $eps_rel with respect to the solution y_i(t). This is equivalent to the standard control object with a_y=1 and a_dydt=0.

=item * C<gsl_odeiv_control_yp_new($eps_abs, $eps_rel)> - This function creates a new control object which will keep the local error on each step within an absolute error of $eps_abs and relative error of $eps_rel with respect to the derivatives of the solution y'_i(t). This is equivalent to the standard control object with a_y=0 and a_dydt=1.

=item * C<gsl_odeiv_control_scaled_new($eps_abs, $eps_rel, $a_y, $a_dydt, $scale_abs, $dim) > - This function creates a new control object which uses the same algorithm as gsl_odeiv_control_standard_new but with an absolute error which is scaled for each component by the array reference $scale_abs. The formula for D_i for this control object is, D_i = eps_abs * s_i + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) where s_i is the i-th component of the array scale_abs. The same error control heuristic is used by the Matlab ode suite.

=item * C<gsl_odeiv_evolve_alloc($dim)> - This function returns a pointer to a newly allocated instance of an evolution function for a system of $dim dimensions.

=item * C<gsl_odeiv_evolve_apply($e, $c, $step, $dydt, \$t, $t1, \$h, $y)> - This function advances the system ($e, $dydt) from time $t and position $y using the stepping function $step. The new time and position are stored in $t and $y on output. The initial step-size is taken as $h, but this will be modified using the control function $c to achieve the appropriate error bound if necessary. The routine may make several calls to step in order to determine the optimum step-size. If the step-size has been changed the value of $h will be modified on output. The maximum time $t1 is guaranteed not to be exceeded by the time-step. On the final time-step the value of $t will be set to $t1 exactly.

=item * C<gsl_odeiv_evolve_reset($e)> - This function resets the evolution function $e. It should be used whenever the next use of $e will not be a continuation of a previous step.

=item * C<gsl_odeiv_evolve_free($e)> - This function frees all the memory associated with the evolution function $e.

=back

This module also includes the following constants :

=over

=item * C<$GSL_ODEIV_HADJ_INC>

=item * C<$GSL_ODEIV_HADJ_NIL>

=item * C<$GSL_ODEIV_HADJ_DEC>

=back

=head2 Step Type

=over

=item * C<$gsl_odeiv_step_rk2> - Embedded Runge-Kutta (2, 3) method.

=item * C<$gsl_odeiv_step_rk4> - 4th order (classical) Runge-Kutta. The error estimate is obtained by halving the step-size. For more efficient estimate of the error, use the Runge-Kutta-Fehlberg method described below.

=item * C<$gsl_odeiv_step_rkf45> - Embedded Runge-Kutta-Fehlberg (4, 5) method. This method is a good general-purpose integrator.

=item * C<$gsl_odeiv_step_rkck> - Embedded Runge-Kutta Cash-Karp (4, 5) method.

=item * C<$gsl_odeiv_step_rk8pd> - Embedded Runge-Kutta Prince-Dormand (8,9) method.

=item * C<$gsl_odeiv_step_rk2imp> - Implicit 2nd order Runge-Kutta at Gaussian points.

=item * C<$gsl_odeiv_step_rk2simp>

=item * C<$gsl_odeiv_step_rk4imp> - Implicit 4th order Runge-Kutta at Gaussian points.

=item * C<$gsl_odeiv_step_bsimp> - Implicit Bulirsch-Stoer method of Bader and Deuflhard. This algorithm requires the Jacobian.

=item * C<$gsl_odeiv_step_gear1> - M=1 implicit Gear method.

=item * C<$gsl_odeiv_step_gear2> - M=2 implicit Gear method.

=back

For more information on the functions, we refer you to the GSL official
documentation: L<http://www.gnu.org/software/gsl/manual/html_node/>

=head1 EXAMPLE

The example is taken from L<https://www.math.utah.edu/software/gsl/gsl-ref_367.html>.

 use strict;
 use warnings;
 use Math::GSL::Errno qw($GSL_SUCCESS);
 use Math::GSL::ODEIV qw/ :all /;
 use Math::GSL::Matrix qw/:all/;
 use Math::GSL::IEEEUtils qw/ :all /;
 
 sub func {
     my ($t, $y, $dydt, $params) = @_;
     my $mu = $params->{mu};
     $dydt->[0] = $y->[1];
     $dydt->[1] = -$y->[0] - $mu*$y->[1]*(($y->[0])**2 - 1);
     return $GSL_SUCCESS;
 }
 
 sub jac {
     my ($t, $y, $dfdy, $dfdt, $params) = @_;

     my $mu = $params->{mu};
     my $m = gsl_matrix_view_array($dfdy, 2, 2);
     gsl_matrix_set( $m, 0, 0, 0.0 );
     gsl_matrix_set( $m, 0, 1, 1.0 );
     gsl_matrix_set( $m, 1, 0, (-2.0 * $mu * $y->[0] * $y->[1]) - 1.0 );
     gsl_matrix_set( $m, 1, 1, -$mu * (($y->[0])**2 - 1.0) );
     $dfdt->[0] = 0.0;
     $dfdt->[1] = 0.0;
     return $GSL_SUCCESS;
 }
 
 my $T = $gsl_odeiv_step_rk8pd;
 my $s = gsl_odeiv_step_alloc($T, 2);
 my $c = gsl_odeiv_control_y_new(1e-6, 0.0);
 my $e = gsl_odeiv_evolve_alloc(2);
 my $params = { mu => 10 };
 my $sys = Math::GSL::ODEIV::gsl_odeiv_system->new(\&func, \&jac, 2, $params );
 my $t = 0.0;
 my $t1 = 100.0;
 my $h = 1e-6;
 my $y = [ 1.0, 0.0 ];
 gsl_ieee_env_setup;
 while ($t < $t1) {
     my $status = gsl_odeiv_evolve_apply ($e, $c, $s, $sys, \$t, $t1, \$h, $y);
     last if $status != $GSL_SUCCESS;
     printf "%.5e %.5e %.5e\n", $t, $y->[0], $y->[1];
 }
 gsl_odeiv_evolve_free($e);
 gsl_odeiv_control_free($c);
 gsl_odeiv_step_free($s);



=head1 AUTHORS

Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1;