-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHDMod.f90
More file actions
7408 lines (5006 loc) · 259 KB
/
HDMod.f90
File metadata and controls
7408 lines (5006 loc) · 259 KB
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
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!*************************************************************************
!* Hyperdual Number Module (HDMod) of Fortran Codes
!*----------------------------------------------------------------
Module HDMod
implicit none
public
integer, parameter :: SPRhyd = KIND(1.0) ! Single Precision
integer, parameter :: DP_hyd = KIND(1.d0) ! Double Precision
! integer, parameter :: QP = KIND(1.q0) ! Quadruple Precision
integer, parameter :: PRhyd = DP_hyd ! Set the precision
real(PRhyd), parameter, private :: pi = ACOS(-1.0_PRhyd)
complex(PRhyd), parameter, private :: pi_c = (pi, 0.0_PRhyd)
!--- DEFINITION OF HYPERDUAL TYPE
TYPE hyperdual
real(PRhyd) :: x
real(PRhyd) :: dx1
real(PRhyd) :: dx2
real(PRhyd) :: dx1x2
END TYPE
!================================================================!
! Overloading hdual functions !
!================================================================!
!----- Constructor
interface hdual
module procedure hdual_from_dble
end interface
!----- Assignment
interface assignment(=)
module procedure hdual_assign_hdual, hdual_assign_dble, hdual_assign_int, &
hdual_array_assign_hdual, hdual_array_assign_hdual_array, hdual_array_assign_dble, &
hdual_array_assign_dble_array, hdual_array_assign_int, hdual_array_assign_int_array, &
hdual_matrix_assign_hdual, hdual_matrix_assign_hdual_matrix, hdual_matrix_assign_dble, &
hdual_matrix_assign_dble_matrix, hdual_matrix_assign_int, hdual_matrix_assign_int_matrix, &
hdual_tens_assign_hdual, hdual_tens_assign_hdual_tens, hdual_tens_assign_dble, &
hdual_tens_assign_dble_tens, hdual_tens_assign_int, hdual_tens_assign_int_tens, hdual_4d_assign_hdual_4d, &
hdual_4d_assign_dble_4d, hdual_4d_assign_dble_4d_SPRhyd, hdual_4d_assign_dble, hdual_5d_assign_dble
end interface
!----- Comparison operators
interface operator(==)
module procedure hdual_eq_hdual, hdual_eq_dble, hdual_eq_dble_SPRhyd, dble_eq_hdual, dble_eq_hdual_SPRhyd
end interface
interface operator(/=)
module procedure hdual_ne_hdual, hdual_ne_dble, hdual_ne_dble_SPRhyd, dble_ne_hdual, dble_ne_hdual_SPRhyd
end interface
interface operator(>)
module procedure hdual_gt_hdual, hdual_gt_dble, hdual_gt_dble_SPRhyd, dble_gt_hdual, dble_gt_hdual_SPRhyd
end interface
interface operator(>=)
module procedure hdual_ge_hdual, hdual_ge_dble, hdual_ge_dble_SPRhyd, dble_ge_hdual, dble_ge_hdual_SPRhyd
end interface
interface operator(<)
module procedure hdual_lt_hdual, hdual_lt_dble, hdual_lt_dble_SPRhyd, dble_lt_hdual, dble_lt_hdual_SPRhyd
end interface
interface operator(<=)
module procedure hdual_le_hdual, hdual_le_dble, hdual_le_dble_SPRhyd, dble_le_hdual, dble_le_hdual_SPRhyd
end interface
interface operator (+)
module procedure hdual_plus_hdual, hdual_plus_hdual_array, hdual_plus_hdual_matrix, &
hdual_plus_hdual_tens, hdual_plus_dble, hdual_plus_dble_SPRhyd, hdual_plus_dble_array, &
hdual_plus_dble_array_SPRhyd, hdual_plus_dble_matrix, hdual_plus_dble_matrix_SPRhyd, hdual_plus_dble_tens, &
hdual_plus_dble_tens_SPRhyd, hdual_plus_int, hdual_plus_int_array, hdual_plus_int_matrix, hdual_plus_int_tens, &
hdual_array_plus_hdual, hdual_array_plus_hdual_array, hdual_array_plus_dble, &
hdual_array_plus_dble_SPRhyd, hdual_array_plus_dble_array, hdual_array_plus_dble_array_SPRhyd, &
hdual_array_plus_int, hdual_array_plus_int_array, &
hdual_matrix_plus_hdual, hdual_matrix_plus_hdual_matrix, hdual_matrix_plus_dble, &
hdual_matrix_plus_dble_SPRhyd, hdual_matrix_plus_dble_matrix, hdual_matrix_plus_dble_matrix_SPRhyd, &
hdual_matrix_plus_int, hdual_matrix_plus_int_matrix, hdual_tens_plus_hdual, hdual_tens_plus_hdual_tens, &
hdual_tens_plus_dble, hdual_tens_plus_dble_SPRhyd, hdual_tens_plus_dble_tens, hdual_tens_plus_dble_tens_SPRhyd, &
hdual_tens_plus_int, hdual_tens_plus_int_tens, hdual_4d_plus_hdual, hdual_4d_plus_hdual_4d, &
hdual_4d_plus_dble, hdual_4d_plus_dble_4d, hdual_4d_plus_dble_4d_SPRhyd, hdual_4d_plus_int, hdual_4d_plus_int_4d, &
dble_plus_hdual, dble_plus_hdual_SPRhyd, dble_plus_hdual_array, &
dble_plus_hdual_array_SPRhyd, dble_plus_hdual_matrix, dble_plus_hdual_matrix_SPRhyd, dble_plus_hdual_tens, &
dble_plus_hdual_tens_SPRhyd, dble_array_plus_hdual, dble_array_plus_hdual_SPRhyd, dble_array_plus_hdual_array, &
dble_array_plus_hdual_array_SPRhyd, dble_matrix_plus_hdual, dble_matrix_plus_hdual_SPRhyd, &
dble_matrix_plus_hdual_matrix, &
dble_matrix_plus_hdual_matrix_SPRhyd, dble_tens_plus_hdual, dble_tens_plus_hdual_SPRhyd, dble_tens_plus_hdual_tens, &
dble_tens_plus_hdual_tens_SPRhyd, dble_4d_plus_hdual, dble_4d_plus_hdual_SPRhyd, dble_4d_plus_hdual_4d, &
dble_4d_plus_hdual_4d_SPRhyd, int_plus_hdual, int_plus_hdual_array, int_plus_hdual_matrix, &
int_plus_hdual_tens, int_array_plus_hdual, int_array_plus_hdual_array, &
int_matrix_plus_hdual, int_matrix_plus_hdual_matrix, &
int_tens_plus_hdual, int_tens_plus_hdual_tens
end interface
interface operator(-)
module procedure hdual_minus_hdual, hdual_minus_hdual_array, hdual_minus_hdual_matrix, &
hdual_minus_hdual_tens, hdual_minus_dble, hdual_minus_dble_SPRhyd, hdual_minus_dble_array, &
hdual_minus_dble_array_SPRhyd, hdual_minus_dble_matrix, hdual_minus_dble_matrix_SPRhyd, &
hdual_minus_dble_tens, hdual_minus_dble_tens_SPRhyd, hdual_minus_int, hdual_minus_int_array, &
hdual_minus_int_matrix, hdual_minus_int_tens, hdual_array_minus_hdual, hdual_array_minus_hdual_array, &
hdual_array_minus_dble, hdual_array_minus_dble_SPRhyd, hdual_array_minus_dble_array, &
hdual_array_minus_dble_array_SPRhyd, hdual_array_minus_int, hdual_array_minus_int_array, &
hdual_matrix_minus_hdual, hdual_matrix_minus_hdual_matrix, &
hdual_matrix_minus_dble, hdual_matrix_minus_dble_SPRhyd, hdual_matrix_minus_dble_matrix, &
hdual_matrix_minus_dble_matrix_SPRhyd, hdual_matrix_minus_int, hdual_matrix_minus_int_matrix, &
hdual_tens_minus_hdual, hdual_tens_minus_hdual_tens, &
hdual_tens_minus_dble, hdual_tens_minus_dble_SPRhyd, hdual_tens_minus_dble_tens, &
hdual_tens_minus_dble_tens_SPRhyd, hdual_tens_minus_int, hdual_tens_minus_int_tens, &
dble_minus_hdual, dble_minus_hdual_SPRhyd, dble_minus_hdual_array, dble_minus_hdual_array_SPRhyd, &
dble_minus_hdual_matrix, dble_minus_hdual_matrix_SPRhyd, dble_minus_hdual_tens, dble_minus_hdual_tens_SPRhyd, &
dble_array_minus_hdual, dble_array_minus_hdual_SPRhyd, dble_array_minus_hdual_array, &
dble_array_minus_hdual_array_SPRhyd, dble_matrix_minus_hdual, dble_matrix_minus_hdual_SPRhyd, &
dble_matrix_minus_hdual_matrix, dble_matrix_minus_hdual_matrix_SPRhyd, dble_tens_minus_hdual, &
dble_tens_minus_hdual_SPRhyd, dble_tens_minus_hdual_tens, dble_tens_minus_hdual_tens_SPRhyd, &
int_minus_hdual, int_minus_hdual_array, &
int_minus_hdual_matrix, int_minus_hdual_tens, &
int_array_minus_hdual, int_array_minus_hdual_array, &
int_matrix_minus_hdual, int_matrix_minus_hdual_matrix, &
int_tens_minus_hdual, int_tens_minus_hdual_tens, minus_hdual, &
minus_hdual_array, minus_hdual_matrix, minus_hdual_tens
end interface
interface operator(*)
module procedure hdual_mul_hdual, hdual_mul_hdual_array, hdual_mul_hdual_matrix, &
hdual_mul_hdual_tens, hdual_mul_dble, hdual_mul_dble_SPRhyd, hdual_mul_dble_array, &
hdual_mul_dble_array_SPRhyd, hdual_mul_dble_matrix, hdual_mul_dble_matrix_SPRhyd, hdual_mul_dble_tens, &
hdual_mul_dble_tens_SPRhyd, hdual_mul_int, hdual_mul_int_array, hdual_mul_int_matrix, hdual_mul_int_tens, &
hdual_array_mul_hdual, hdual_array_mul_dble, hdual_array_mul_dble_SPRhyd, hdual_array_mul_int, &
hdual_matrix_mul_hdual, hdual_matrix_mul_dble, hdual_matrix_mul_dble_SPRhyd, hdual_matrix_mul_int, &
hdual_tens_mul_hdual, hdual_tens_mul_dble, hdual_tens_mul_dble_SPRhyd, hdual_tens_mul_int, &
dble_mul_hdual, dble_mul_hdual_SPRhyd, dble_mul_hdual_array, dble_mul_hdual_array_SPRhyd, dble_mul_hdual_matrix, &
dble_mul_hdual_matrix_SPRhyd, dble_mul_hdual_tens, dble_mul_hdual_tens_SPRhyd, dble_array_mul_hdual, &
dble_array_mul_hdual_SPRhyd, dble_matrix_mul_hdual, dble_matrix_mul_hdual_SPRhyd, &
dble_tens_mul_hdual, dble_tens_mul_hdual_SPRhyd, &
int_mul_hdual, int_mul_hdual_array, int_mul_hdual_matrix, &
int_mul_hdual_tens, int_array_mul_hdual, int_matrix_mul_hdual, &
int_tens_mul_hdual, hdual_array_mul_hdual_array, &
hdual_array_mul_dble_array ,dble_array_mul_hdual_array, &
hdual_array_mul_dble_array_SPRhyd ,dble_array_mul_hdual_array_SPRhyd, hdual_matrix_mul_hdual_matrix, &
hdual_matrix_mul_dble_matrix, hdual_matrix_mul_dble_matrix_SPRhyd, dble_matrix_mul_hdual_matrix, &
dble_matrix_mul_hdual_matrix_SPRhyd, hdual_tens_mul_hdual_tens, &
hdual_tens_mul_dble_tens, hdual_tens_mul_dble_tens_SPRhyd, dble_tens_mul_hdual_tens, &
dble_tens_mul_hdual_tens_SPRhyd, hdual_4d_mul_dble_4d, hdual_4d_mul_dble_4d_SPRhyd
end interface
interface operator(/)
module procedure hdual_div_hdual, hdual_div_dble, hdual_div_dble_SPRhyd, hdual_div_int, &
hdual_array_div_hdual, hdual_array_div_dble, hdual_array_div_dble_SPRhyd, hdual_array_div_int, &
hdual_matrix_div_hdual, hdual_matrix_div_dble, hdual_matrix_div_dble_SPRhyd, hdual_matrix_div_int, &
hdual_tens_div_hdual, hdual_tens_div_dble, hdual_tens_div_dble_SPRhyd, hdual_tens_div_int, &
dble_div_hdual, dble_div_hdual_SPRhyd, dble_div_hdual_tens_SPRhyd, int_div_hdual, &
dble_array_div_hdual, dble_array_div_hdual_SPRhyd, int_array_div_hdual, &
dble_matrix_div_hdual, dble_matrix_div_hdual_SPRhyd, int_matrix_div_hdual, &
dble_tens_div_hdual, dble_tens_div_hdual_SPRhyd, int_tens_div_hdual, hdual_array_div_dble_array, &
hdual_array_div_dble_array_SPRhyd, hdual_array_div_hdual_array
end interface
! Probably need more elemental divisions
interface operator(**)
module procedure hdual_pow_hdual, hdual_pow_int, hdual_pow_dble, hdual_pow_dble_SPRhyd, dble_pow_hdual, &
dble_pow_hdual_SPRhyd, hdual_array_pow_dble, hdual_array_pow_dble_SPRhyd
end interface
!----- Intrinsic functions
interface dble
module procedure dble_hdual, dble_hdual_array, dble_hdual_matrix
end interface
interface abs
module procedure abs_hdual, abs_hdual_array, abs_hdual_matrix
end interface
interface sign
module procedure sign_hdual_hdual, sign_hdual_dble, sign_hdual_dble_SPR, sign_dble_hdual, sign_dble_hdual_SPR
end interface
interface max
module procedure max_hdual_hdual, max_hdual_dble, max_hdual_dble_SPRhyd, max_dble_hdual, &
max_dble_hdual_SPRhyd, max_hdual_array_dble, max_hdual_matrix_dble, max_hdual_matrix_dble_SPRhyd, &
max_hdual_tens_dble, max_hdual_tens_dble_SPRhyd, &
max_hdual_4d_dble, max_hdual_4d_dble_SPRhyd, max_hdual_array_hdual_array, max_three_hdual
end interface
interface min
module procedure min_hdual_hdual, min_hdual_dble, min_hdual_dble_SPRhyd, min_dble_hdual, min_dble_hdual_SPRhyd, &
min_hdual_three, min_hdual_four, min_hdual_five
end interface
interface maxval
module procedure maxval_hdual_array, maxval_hdual_matrix
end interface
interface minval
module procedure minval_hdual_4d
end interface
interface minloc
module procedure minloc_hdual_4d
end interface
interface dot_product
module procedure &
dot_product_hdual_array_hdual_array, dot_product_hdual_array_dble_array, &
dot_product_hdual_array_dble_array_SPRhyd, dot_product_dble_array_hdual_array, &
dot_product_dble_array_hdual_array_SPRhyd
end interface
interface sqrt
module procedure hdsqrt
end interface
interface exp
module procedure hdexp
end interface
interface log
module procedure hdlog
end interface
interface log10
module procedure hdlog10
end interface
interface cos
module procedure hdcos
end interface
interface sin
module procedure hdsin
end interface
interface tan
module procedure hdtan
end interface
interface cosh
module procedure hdcosh
end interface
interface sinh
module procedure hdsinh
end interface
interface tanh
module procedure hdtanh
end interface
interface acos
module procedure hdacos
end interface
interface asin
module procedure hdasin
end interface
interface atan
module procedure hdatan
end interface
interface nint
module procedure hdnint
end interface
interface sum
module procedure hdsum, hdsum_2d, hdsum_3d, hdsum_4d, hdsum_mask, hdsum_2d_dim, &
hdsum_3d_dim, hdsum_4d_dim, hdsum_5d_dim
end interface
! interface real
! module procedure real_hdual
! end interface
interface erf
module procedure hderf
end interface
interface erfc
module procedure hderfc
end interface
CONTAINS
!================================================================!
! Overloading hdual functions !
!================================================================!
!----------------------------------------------------------------!
! CONSTRUCTOR !
!----------------------------------------------------------------!
function hdual_from_dble(x11,x12,x21,x22) result(q)
implicit none
real(PRhyd), intent(in) :: x11, x12, x21, x22
TYPE(hyperdual) :: q
q%x = x11
q%dx1 = x12
q%dx2 = x21
q%dx1x2 = x22
end function hdual_from_dble
!----------------------------------------------------------------!
! ASSIGNMENT !
!----------------------------------------------------------------!
subroutine hdual_assign_hdual(qleft, qright)
implicit none
TYPE(hyperdual), intent(out) :: qleft
TYPE(hyperdual), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_assign_hdual
subroutine hdual_assign_dble(qleft, xright)
implicit none
TYPE(hyperdual), intent(out) :: qleft
real(PRhyd), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_assign_dble
subroutine hdual_assign_int(qleft, xright)
implicit none
TYPE(hyperdual), intent(out) :: qleft
integer, intent(in) :: xright
qleft%x = REAL(xright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_assign_int
subroutine hdual_array_assign_hdual(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:), intent(out) :: qleft
TYPE(hyperdual), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_array_assign_hdual
subroutine hdual_array_assign_hdual_array(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:), intent(out) :: qleft
TYPE(hyperdual), dimension(:), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_array_assign_hdual_array
subroutine hdual_array_assign_dble(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:), intent(out) :: qleft
real(PRhyd), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_array_assign_dble
subroutine hdual_array_assign_dble_array(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:), intent(out) :: qleft
real(PRhyd), dimension(:), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_array_assign_dble_array
subroutine hdual_array_assign_int(qleft, iright)
implicit none
TYPE(hyperdual), dimension(:), intent(out) :: qleft
integer, intent(in) :: iright
qleft%x = REAL(iright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_array_assign_int
subroutine hdual_array_assign_int_array(qleft, iright)
implicit none
TYPE(hyperdual), dimension(:), intent(out) :: qleft
integer, dimension(:), intent(in) :: iright
qleft%x = REAL(iright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_array_assign_int_array
subroutine hdual_matrix_assign_hdual(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:,:), intent(out) :: qleft
TYPE(hyperdual), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_matrix_assign_hdual
subroutine hdual_matrix_assign_hdual_matrix(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:,:), intent(out) :: qleft
TYPE(hyperdual), dimension(:,:), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_matrix_assign_hdual_matrix
subroutine hdual_matrix_assign_dble(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:), intent(out) :: qleft
real(PRhyd), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_matrix_assign_dble
subroutine hdual_matrix_assign_dble_matrix(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:), intent(out) :: qleft
real(PRhyd), dimension(:,:), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_matrix_assign_dble_matrix
subroutine hdual_matrix_assign_int(qleft, iright)
implicit none
TYPE(hyperdual), dimension(:,:), intent(out) :: qleft
integer, intent(in) :: iright
qleft%x = REAL(iright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_matrix_assign_int
subroutine hdual_matrix_assign_int_matrix(qleft, iright)
implicit none
TYPE(hyperdual), dimension(:,:), intent(out) :: qleft
integer, dimension(:,:), intent(in) :: iright
qleft%x = REAL(iright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_matrix_assign_int_matrix
subroutine hdual_tens_assign_hdual(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:,:,:), intent(out) :: qleft
TYPE(hyperdual), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_tens_assign_hdual
subroutine hdual_tens_assign_hdual_tens(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:,:,:), intent(out) :: qleft
TYPE(hyperdual), dimension(:,:,:), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_tens_assign_hdual_tens
subroutine hdual_tens_assign_dble(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:,:), intent(out) :: qleft
real(PRhyd), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_tens_assign_dble
subroutine hdual_tens_assign_dble_tens(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:,:), intent(out) :: qleft
real(PRhyd), dimension(:,:,:), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_tens_assign_dble_tens
subroutine hdual_tens_assign_int(qleft, iright)
implicit none
TYPE(hyperdual), dimension(:,:,:), intent(out) :: qleft
integer, intent(in) :: iright
qleft%x = REAL(iright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_tens_assign_int
subroutine hdual_tens_assign_int_tens(qleft, iright)
implicit none
TYPE(hyperdual), dimension(:,:,:), intent(out) :: qleft
integer, dimension(:,:,:), intent(in) :: iright
qleft%x = REAL(iright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_tens_assign_int_tens
subroutine hdual_4d_assign_hdual_4d(qleft, qright)
implicit none
TYPE(hyperdual), dimension(:,:,:,:), intent(out) :: qleft
TYPE(hyperdual), dimension(:,:,:,:), intent(in) :: qright
qleft%x = qright%x
qleft%dx1 = qright%dx1
qleft%dx2 = qright%dx2
qleft%dx1x2 = qright%dx1x2
end subroutine hdual_4d_assign_hdual_4d
subroutine hdual_4d_assign_dble(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:,:,:), intent(out) :: qleft
REAL(PRhyd), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_4d_assign_dble
subroutine hdual_4d_assign_dble_4d(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:,:,:), intent(out) :: qleft
REAL(PRhyd), dimension(:,:,:,:), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_4d_assign_dble_4d
subroutine hdual_4d_assign_dble_4d_SPRhyd(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:,:,:), intent(out) :: qleft
REAL(SPRhyd), dimension(:,:,:,:), intent(in) :: xright
qleft%x = REAL(xright, PRhyd)
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_4d_assign_dble_4d_SPRhyd
subroutine hdual_5d_assign_dble(qleft, xright)
implicit none
TYPE(hyperdual), dimension(:,:,:,:,:), intent(out) :: qleft
REAL(PRhyd), intent(in) :: xright
qleft%x = xright
qleft%dx1 = 0.0_PRhyd
qleft%dx2 = 0.0_PRhyd
qleft%dx1x2 = 0.0_PRhyd
end subroutine hdual_5d_assign_dble
!----------------------------------------------------------------!
! COMPARISON OPERATORS !
!----------------------------------------------------------------!
!----- EQ operator (==)
function hdual_eq_hdual(qleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft, qright
logical :: bool
bool = ( qleft%x .EQ. qright%x )
end function hdual_eq_hdual
function hdual_eq_dble(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(PRhyd), intent(in) :: xright
logical :: bool
bool = ( qleft%x .EQ. xright)
end function hdual_eq_dble
function hdual_eq_dble_SPRhyd(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(SPRhyd), intent(in) :: xright
logical :: bool
bool = ( REAL(qleft%x,SPRhyd) .EQ. xright)
end function hdual_eq_dble_SPRhyd
function dble_eq_hdual(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(PRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft .EQ. qright%x )
end function dble_eq_hdual
function dble_eq_hdual_SPRhyd(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(SPRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft .EQ. REAL(qright%x,SPRhyd) )
end function dble_eq_hdual_SPRhyd
!----- NE operator (/=)
function hdual_ne_hdual(qleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft, qright
logical :: bool
bool = ( .NOT. (qleft .EQ. qright) )
end function hdual_ne_hdual
function hdual_ne_dble(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(PRhyd), intent(in) :: xright
logical :: bool
bool = ( qleft%x .NE. xright)
end function hdual_ne_dble
function hdual_ne_dble_SPRhyd(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(SPRhyd), intent(in) :: xright
logical :: bool
bool = ( REAL(qleft%x,SPRhyd) .NE. xright )
end function hdual_ne_dble_SPRhyd
function dble_ne_hdual(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(PRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft .NE. qright%x )
end function dble_ne_hdual
function dble_ne_hdual_SPRhyd(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(SPRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft .NE. REAL(qright%x,SPRhyd) )
end function dble_ne_hdual_SPRhyd
!----- GT operator (>)
function hdual_gt_hdual(qleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft, qright
logical :: bool
bool = ( qleft%x > qright%x )
end function hdual_gt_hdual
function hdual_gt_dble(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(PRhyd), intent(in) :: xright
logical :: bool
bool = ( qleft%x > xright)
end function hdual_gt_dble
function hdual_gt_dble_SPRhyd(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(SPRhyd), intent(in) :: xright
logical :: bool
bool = ( REAL(qleft%x, SPRhyd) > xright )
end function hdual_gt_dble_SPRhyd
function dble_gt_hdual(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(PRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft > qright%x )
end function dble_gt_hdual
function dble_gt_hdual_SPRhyd(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(SPRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft > REAL(qright%x,SPRhyd) )
end function dble_gt_hdual_SPRhyd
!----- GE operator (>=)
function hdual_ge_hdual(qleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft, qright
logical :: bool
bool = ( qleft%x >= qright%x )
end function hdual_ge_hdual
function hdual_ge_dble(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(PRhyd), intent(in) :: xright
logical :: bool
bool = ( qleft%x >= xright)
end function hdual_ge_dble
function hdual_ge_dble_SPRhyd(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(SPRhyd), intent(in) :: xright
logical :: bool
bool = (REAL(qleft%x,SPRhyd) >= xright)
end function hdual_ge_dble_SPRhyd
function dble_ge_hdual(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(PRhyd), intent(in) :: xleft
logical :: bool
bool = (xleft >= qright%x )
end function dble_ge_hdual
function dble_ge_hdual_SPRhyd(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(SPRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft >= REAL( qright%x,SPRhyd ) )
end function dble_ge_hdual_SPRhyd
!----- LT operator (<)
function hdual_lt_hdual(qleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft, qright
logical :: bool
bool = ( qleft%x < REAL(qright%x,PRhyd) )
end function hdual_lt_hdual
function hdual_lt_dble(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(PRhyd), intent(in) :: xright
logical :: bool
bool = ( qleft%x < xright )
end function hdual_lt_dble
function hdual_lt_dble_SPRhyd(qleft, xright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft
REAL(SPRhyd), intent(in) :: xright
logical :: bool
bool = ( REAL(qleft%x, SPRhyd) < xright )
end function hdual_lt_dble_SPRhyd
function dble_lt_hdual(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(PRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft < qright%x )
end function dble_lt_hdual
function dble_lt_hdual_SPRhyd(xleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qright
REAL(SPRhyd), intent(in) :: xleft
logical :: bool
bool = ( xleft < REAL(qright%x,SPRhyd) )
end function dble_lt_hdual_SPRhyd
!----- LE operator (<=)
function hdual_le_hdual(qleft, qright) result(bool)
implicit none
TYPE(hyperdual), intent(in) :: qleft, qright
logical :: bool
bool = ( qleft%x <= qright%x )