@@ -509,39 +509,27 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
509
509
510
510
max_order = alg. max_order
511
511
min_order = alg. min_order
512
- max = (max_order - 1 ) ÷ 4 * 2 + 1
513
- min = (min_order - 1 ) ÷ 4 * 2 + 1
512
+ max_stages = (max_order - 1 ) ÷ 4 * 2 + 1
513
+ min_stages = (min_order - 1 ) ÷ 4 * 2 + 1
514
514
if (alg. min_order < 5 )
515
515
error (" min_order choice $min_order below 5 is not compatible with the algorithm" )
516
- elseif (max < min )
516
+ elseif (max_stages < min_stages )
517
517
error (" max_order $max_order is below min_order $min_order " )
518
518
end
519
- num_stages = min
519
+ num_stages = min_stages
520
520
521
521
tabs = [RadauIIATableau5 (uToltype, constvalue (tTypeNoUnits)), RadauIIATableau9 (uToltype, constvalue (tTypeNoUnits)), RadauIIATableau13 (uToltype, constvalue (tTypeNoUnits))]
522
- if (min == 3 || min == 5 || min == 7 )
523
- i = 9
524
- else
525
- i = min
526
- end
527
- while i <= max
522
+ i = max (min_stages, 9 )
523
+ while i <= max_stages
528
524
push! (tabs, RadauIIATableau (uToltype, constvalue (tTypeNoUnits), i))
529
525
i += 2
530
526
end
531
- cont = Vector {typeof(u)} (undef, max )
532
- for i in 1 : max
527
+ cont = Vector {typeof(u)} (undef, max_stages )
528
+ for i in 1 : max_stages
533
529
cont[i] = zero (u)
534
530
end
535
531
536
- if (min == 3 )
537
- index = 1
538
- elseif (min == 5 )
539
- index = 2
540
- elseif (min == 7 )
541
- index = 3
542
- else
543
- index = 4
544
- end
532
+ index = min ((min_stages - 1 ) ÷ 2 , 4 )
545
533
546
534
κ = alg. κ != = nothing ? convert (uToltype, alg. κ) : convert (uToltype, 1 // 100 )
547
535
J = false .* _vec (rate_prototype) .* _vec (rate_prototype)'
@@ -605,70 +593,58 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
605
593
606
594
max_order = alg. max_order
607
595
min_order = alg. min_order
608
- max = (max_order - 1 ) ÷ 4 * 2 + 1
609
- min = (min_order - 1 ) ÷ 4 * 2 + 1
596
+ max_stages = (max_order - 1 ) ÷ 4 * 2 + 1
597
+ min_stages = (min_order - 1 ) ÷ 4 * 2 + 1
610
598
if (alg. min_order < 5 )
611
599
error (" min_order choice $min_order below 5 is not compatible with the algorithm" )
612
- elseif (max < min )
600
+ elseif (max_stages < min_stages )
613
601
error (" max_order $max_order is below min_order $min_order " )
614
602
end
615
- num_stages = min
603
+ num_stages = min_stages
616
604
617
605
tabs = [RadauIIATableau5 (uToltype, constvalue (tTypeNoUnits)), RadauIIATableau9 (uToltype, constvalue (tTypeNoUnits)), RadauIIATableau13 (uToltype, constvalue (tTypeNoUnits))]
618
- if (min == 3 || min == 5 || min == 7 )
619
- i = 9
620
- else
621
- i = min
622
- end
623
- while i <= max
606
+ i = max (min_stages, 9 )
607
+ while i <= max_stages
624
608
push! (tabs, RadauIIATableau (uToltype, constvalue (tTypeNoUnits), i))
625
609
i += 2
626
610
end
627
611
628
- if (min == 3 )
629
- index = 1
630
- elseif (min == 5 )
631
- index = 2
632
- elseif (min == 7 )
633
- index = 3
634
- else
635
- index = 4
636
- end
612
+ index = min ((min_stages - 1 ) ÷ 2 , 4 )
637
613
638
614
κ = alg. κ != = nothing ? convert (uToltype, alg. κ) : convert (uToltype, 1 // 100 )
639
615
640
- z = Vector {typeof(u)} (undef, max )
641
- w = Vector {typeof(u)} (undef, max )
642
- for i in 1 : max
616
+ z = Vector {typeof(u)} (undef, max_stages )
617
+ w = Vector {typeof(u)} (undef, max_stages )
618
+ for i in 1 : max_stages
643
619
z[i] = zero (u)
644
620
w[i] = zero (u)
645
621
end
646
622
647
- αdt = [zero (t) for i in 1 : max ]
648
- βdt = [zero (t) for i in 1 : max ]
649
- c_prime = Vector {typeof(t)} (undef, max ) # time stepping
650
- for i in 1 : max
623
+ αdt = [zero (t) for i in 1 : max_stages ]
624
+ βdt = [zero (t) for i in 1 : max_stages ]
625
+ c_prime = Vector {typeof(t)} (undef, max_stages ) # time stepping
626
+ for i in 1 : max_stages
651
627
c_prime[i] = zero (t)
652
628
end
653
629
654
630
dw1 = zero (u)
655
631
ubuff = zero (u)
656
- dw2 = [similar (u, Complex{eltype (u)}) for _ in 1 : (max - 1 ) ÷ 2 ]
632
+ dw2 = [similar (u, Complex{eltype (u)}) for _ in 1 : (max_stages - 1 ) ÷ 2 ]
657
633
recursivefill! .(dw2, false )
658
- cubuff = [similar (u, Complex{eltype (u)}) for _ in 1 : (max - 1 ) ÷ 2 ]
634
+ cubuff = [similar (u, Complex{eltype (u)}) for _ in 1 : (max_stages - 1 ) ÷ 2 ]
659
635
recursivefill! .(cubuff, false )
660
- dw = [zero (u) for i in 1 : max ]
636
+ dw = [zero (u) for i in 1 : max_stages ]
661
637
662
- cont = [zero (u) for i in 1 : max ]
638
+ cont = [zero (u) for i in 1 : max_stages ]
663
639
664
- derivatives = Matrix {typeof(u)} (undef, max, max )
665
- for i in 1 : max , j in 1 : max
640
+ derivatives = Matrix {typeof(u)} (undef, max_stages, max_stages )
641
+ for i in 1 : max_stages , j in 1 : max_stages
666
642
derivatives[i, j] = zero (u)
667
643
end
668
644
669
645
fsalfirst = zero (rate_prototype)
670
- fw = [zero (rate_prototype) for i in 1 : max ]
671
- ks = [zero (rate_prototype) for i in 1 : max ]
646
+ fw = [zero (rate_prototype) for i in 1 : max_stages ]
647
+ ks = [zero (rate_prototype) for i in 1 : max_stages ]
672
648
673
649
k = ks[1 ]
674
650
@@ -677,7 +653,7 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
677
653
error (" Non-concrete Jacobian not yet supported by AdaptiveRadau." )
678
654
end
679
655
680
- W2 = [similar (J, Complex{eltype (W1)}) for _ in 1 : (max - 1 ) ÷ 2 ]
656
+ W2 = [similar (J, Complex{eltype (W1)}) for _ in 1 : (max_stages - 1 ) ÷ 2 ]
681
657
recursivefill! .(W2, false )
682
658
683
659
du1 = zero (rate_prototype)
@@ -695,7 +671,7 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
695
671
696
672
linsolve2 = [
697
673
init (LinearProblem (W2[i], _vec (cubuff[i]); u0 = _vec (dw2[i])), alg. linsolve, alias_A = true , alias_b = true ,
698
- assumptions = LinearSolve. OperatorAssumptions (true )) for i in 1 : (max - 1 ) ÷ 2 ]
674
+ assumptions = LinearSolve. OperatorAssumptions (true )) for i in 1 : (max_stages - 1 ) ÷ 2 ]
699
675
700
676
rtol = reltol isa Number ? reltol : zero (reltol)
701
677
atol = reltol isa Number ? reltol : zero (reltol)
0 commit comments