@@ -8,7 +8,8 @@ module stdlib_math
8
8
public :: clip, gcd, linspace, logspace
9
9
public :: EULERS_NUMBER_SP, EULERS_NUMBER_DP
10
10
public :: DEFAULT_LINSPACE_LENGTH, DEFAULT_LOGSPACE_BASE, DEFAULT_LOGSPACE_LENGTH
11
- public :: arange, arg, argd, argpi, is_close, all_close, diff
11
+ public :: stdlib_meshgrid_ij, stdlib_meshgrid_xy
12
+ public :: arange, arg, argd, argpi, is_close, all_close, diff, meshgrid
12
13
13
14
integer , parameter :: DEFAULT_LINSPACE_LENGTH = 100
14
15
integer , parameter :: DEFAULT_LOGSPACE_LENGTH = 50
@@ -22,6 +23,9 @@ module stdlib_math
22
23
real (kind= sp), parameter :: PI_sp = acos (- 1.0_sp )
23
24
real (kind= dp), parameter :: PI_dp = acos (- 1.0_dp )
24
25
26
+ ! > Values for optional argument `indexing` of `meshgrid`
27
+ integer , parameter :: stdlib_meshgrid_xy = 0 , stdlib_meshgrid_ij = 1
28
+
25
29
interface clip
26
30
module procedure clip_int8
27
31
module procedure clip_int16
@@ -676,6 +680,301 @@ pure module function diff_2_int64(X, n, dim, prepend, append) result(y)
676
680
end function diff_2_int64
677
681
end interface diff
678
682
683
+
684
+ ! > Version: experimental
685
+ ! >
686
+ ! > Computes a list of coordinate matrices from coordinate vectors.
687
+ ! > ([Specification](../page/specs/stdlib_math.html#meshgrid))
688
+ interface meshgrid
689
+ module subroutine meshgrid_1_iint8_iint8 (&
690
+ x1 , &
691
+ xm1 , &
692
+ indexing &
693
+ )
694
+ integer (int8), intent (in ) :: x1(:)
695
+ integer (int8), intent (out ) :: xm1 (:)
696
+ integer , intent (in ), optional :: indexing
697
+ end subroutine meshgrid_1_iint8_iint8
698
+ module subroutine meshgrid_2_iint8_iint8 (&
699
+ x1 , x2 , &
700
+ xm1 , xm2 , &
701
+ indexing &
702
+ )
703
+ integer (int8), intent (in ) :: x1(:)
704
+ integer (int8), intent (out ) :: xm1 (:,:)
705
+ integer (int8), intent (in ) :: x2(:)
706
+ integer (int8), intent (out ) :: xm2 (:,:)
707
+ integer , intent (in ), optional :: indexing
708
+ end subroutine meshgrid_2_iint8_iint8
709
+ module subroutine meshgrid_3_iint8_iint8 (&
710
+ x1 , x2 , x3 , &
711
+ xm1 , xm2 , xm3 , &
712
+ indexing &
713
+ )
714
+ integer (int8), intent (in ) :: x1(:)
715
+ integer (int8), intent (out ) :: xm1 (:,:,:)
716
+ integer (int8), intent (in ) :: x2(:)
717
+ integer (int8), intent (out ) :: xm2 (:,:,:)
718
+ integer (int8), intent (in ) :: x3(:)
719
+ integer (int8), intent (out ) :: xm3 (:,:,:)
720
+ integer , intent (in ), optional :: indexing
721
+ end subroutine meshgrid_3_iint8_iint8
722
+ module subroutine meshgrid_4_iint8_iint8 (&
723
+ x1 , x2 , x3 , x4 , &
724
+ xm1 , xm2 , xm3 , xm4 , &
725
+ indexing &
726
+ )
727
+ integer (int8), intent (in ) :: x1(:)
728
+ integer (int8), intent (out ) :: xm1 (:,:,:,:)
729
+ integer (int8), intent (in ) :: x2(:)
730
+ integer (int8), intent (out ) :: xm2 (:,:,:,:)
731
+ integer (int8), intent (in ) :: x3(:)
732
+ integer (int8), intent (out ) :: xm3 (:,:,:,:)
733
+ integer (int8), intent (in ) :: x4(:)
734
+ integer (int8), intent (out ) :: xm4 (:,:,:,:)
735
+ integer , intent (in ), optional :: indexing
736
+ end subroutine meshgrid_4_iint8_iint8
737
+ module subroutine meshgrid_1_iint16_iint16 (&
738
+ x1 , &
739
+ xm1 , &
740
+ indexing &
741
+ )
742
+ integer (int16), intent (in ) :: x1(:)
743
+ integer (int16), intent (out ) :: xm1 (:)
744
+ integer , intent (in ), optional :: indexing
745
+ end subroutine meshgrid_1_iint16_iint16
746
+ module subroutine meshgrid_2_iint16_iint16 (&
747
+ x1 , x2 , &
748
+ xm1 , xm2 , &
749
+ indexing &
750
+ )
751
+ integer (int16), intent (in ) :: x1(:)
752
+ integer (int16), intent (out ) :: xm1 (:,:)
753
+ integer (int16), intent (in ) :: x2(:)
754
+ integer (int16), intent (out ) :: xm2 (:,:)
755
+ integer , intent (in ), optional :: indexing
756
+ end subroutine meshgrid_2_iint16_iint16
757
+ module subroutine meshgrid_3_iint16_iint16 (&
758
+ x1 , x2 , x3 , &
759
+ xm1 , xm2 , xm3 , &
760
+ indexing &
761
+ )
762
+ integer (int16), intent (in ) :: x1(:)
763
+ integer (int16), intent (out ) :: xm1 (:,:,:)
764
+ integer (int16), intent (in ) :: x2(:)
765
+ integer (int16), intent (out ) :: xm2 (:,:,:)
766
+ integer (int16), intent (in ) :: x3(:)
767
+ integer (int16), intent (out ) :: xm3 (:,:,:)
768
+ integer , intent (in ), optional :: indexing
769
+ end subroutine meshgrid_3_iint16_iint16
770
+ module subroutine meshgrid_4_iint16_iint16 (&
771
+ x1 , x2 , x3 , x4 , &
772
+ xm1 , xm2 , xm3 , xm4 , &
773
+ indexing &
774
+ )
775
+ integer (int16), intent (in ) :: x1(:)
776
+ integer (int16), intent (out ) :: xm1 (:,:,:,:)
777
+ integer (int16), intent (in ) :: x2(:)
778
+ integer (int16), intent (out ) :: xm2 (:,:,:,:)
779
+ integer (int16), intent (in ) :: x3(:)
780
+ integer (int16), intent (out ) :: xm3 (:,:,:,:)
781
+ integer (int16), intent (in ) :: x4(:)
782
+ integer (int16), intent (out ) :: xm4 (:,:,:,:)
783
+ integer , intent (in ), optional :: indexing
784
+ end subroutine meshgrid_4_iint16_iint16
785
+ module subroutine meshgrid_1_iint32_iint32 (&
786
+ x1 , &
787
+ xm1 , &
788
+ indexing &
789
+ )
790
+ integer (int32), intent (in ) :: x1(:)
791
+ integer (int32), intent (out ) :: xm1 (:)
792
+ integer , intent (in ), optional :: indexing
793
+ end subroutine meshgrid_1_iint32_iint32
794
+ module subroutine meshgrid_2_iint32_iint32 (&
795
+ x1 , x2 , &
796
+ xm1 , xm2 , &
797
+ indexing &
798
+ )
799
+ integer (int32), intent (in ) :: x1(:)
800
+ integer (int32), intent (out ) :: xm1 (:,:)
801
+ integer (int32), intent (in ) :: x2(:)
802
+ integer (int32), intent (out ) :: xm2 (:,:)
803
+ integer , intent (in ), optional :: indexing
804
+ end subroutine meshgrid_2_iint32_iint32
805
+ module subroutine meshgrid_3_iint32_iint32 (&
806
+ x1 , x2 , x3 , &
807
+ xm1 , xm2 , xm3 , &
808
+ indexing &
809
+ )
810
+ integer (int32), intent (in ) :: x1(:)
811
+ integer (int32), intent (out ) :: xm1 (:,:,:)
812
+ integer (int32), intent (in ) :: x2(:)
813
+ integer (int32), intent (out ) :: xm2 (:,:,:)
814
+ integer (int32), intent (in ) :: x3(:)
815
+ integer (int32), intent (out ) :: xm3 (:,:,:)
816
+ integer , intent (in ), optional :: indexing
817
+ end subroutine meshgrid_3_iint32_iint32
818
+ module subroutine meshgrid_4_iint32_iint32 (&
819
+ x1 , x2 , x3 , x4 , &
820
+ xm1 , xm2 , xm3 , xm4 , &
821
+ indexing &
822
+ )
823
+ integer (int32), intent (in ) :: x1(:)
824
+ integer (int32), intent (out ) :: xm1 (:,:,:,:)
825
+ integer (int32), intent (in ) :: x2(:)
826
+ integer (int32), intent (out ) :: xm2 (:,:,:,:)
827
+ integer (int32), intent (in ) :: x3(:)
828
+ integer (int32), intent (out ) :: xm3 (:,:,:,:)
829
+ integer (int32), intent (in ) :: x4(:)
830
+ integer (int32), intent (out ) :: xm4 (:,:,:,:)
831
+ integer , intent (in ), optional :: indexing
832
+ end subroutine meshgrid_4_iint32_iint32
833
+ module subroutine meshgrid_1_iint64_iint64 (&
834
+ x1 , &
835
+ xm1 , &
836
+ indexing &
837
+ )
838
+ integer (int64), intent (in ) :: x1(:)
839
+ integer (int64), intent (out ) :: xm1 (:)
840
+ integer , intent (in ), optional :: indexing
841
+ end subroutine meshgrid_1_iint64_iint64
842
+ module subroutine meshgrid_2_iint64_iint64 (&
843
+ x1 , x2 , &
844
+ xm1 , xm2 , &
845
+ indexing &
846
+ )
847
+ integer (int64), intent (in ) :: x1(:)
848
+ integer (int64), intent (out ) :: xm1 (:,:)
849
+ integer (int64), intent (in ) :: x2(:)
850
+ integer (int64), intent (out ) :: xm2 (:,:)
851
+ integer , intent (in ), optional :: indexing
852
+ end subroutine meshgrid_2_iint64_iint64
853
+ module subroutine meshgrid_3_iint64_iint64 (&
854
+ x1 , x2 , x3 , &
855
+ xm1 , xm2 , xm3 , &
856
+ indexing &
857
+ )
858
+ integer (int64), intent (in ) :: x1(:)
859
+ integer (int64), intent (out ) :: xm1 (:,:,:)
860
+ integer (int64), intent (in ) :: x2(:)
861
+ integer (int64), intent (out ) :: xm2 (:,:,:)
862
+ integer (int64), intent (in ) :: x3(:)
863
+ integer (int64), intent (out ) :: xm3 (:,:,:)
864
+ integer , intent (in ), optional :: indexing
865
+ end subroutine meshgrid_3_iint64_iint64
866
+ module subroutine meshgrid_4_iint64_iint64 (&
867
+ x1 , x2 , x3 , x4 , &
868
+ xm1 , xm2 , xm3 , xm4 , &
869
+ indexing &
870
+ )
871
+ integer (int64), intent (in ) :: x1(:)
872
+ integer (int64), intent (out ) :: xm1 (:,:,:,:)
873
+ integer (int64), intent (in ) :: x2(:)
874
+ integer (int64), intent (out ) :: xm2 (:,:,:,:)
875
+ integer (int64), intent (in ) :: x3(:)
876
+ integer (int64), intent (out ) :: xm3 (:,:,:,:)
877
+ integer (int64), intent (in ) :: x4(:)
878
+ integer (int64), intent (out ) :: xm4 (:,:,:,:)
879
+ integer , intent (in ), optional :: indexing
880
+ end subroutine meshgrid_4_iint64_iint64
881
+ module subroutine meshgrid_1_rsp_rsp (&
882
+ x1 , &
883
+ xm1 , &
884
+ indexing &
885
+ )
886
+ real (sp), intent (in ) :: x1(:)
887
+ real (sp), intent (out ) :: xm1 (:)
888
+ integer , intent (in ), optional :: indexing
889
+ end subroutine meshgrid_1_rsp_rsp
890
+ module subroutine meshgrid_2_rsp_rsp (&
891
+ x1 , x2 , &
892
+ xm1 , xm2 , &
893
+ indexing &
894
+ )
895
+ real (sp), intent (in ) :: x1(:)
896
+ real (sp), intent (out ) :: xm1 (:,:)
897
+ real (sp), intent (in ) :: x2(:)
898
+ real (sp), intent (out ) :: xm2 (:,:)
899
+ integer , intent (in ), optional :: indexing
900
+ end subroutine meshgrid_2_rsp_rsp
901
+ module subroutine meshgrid_3_rsp_rsp (&
902
+ x1 , x2 , x3 , &
903
+ xm1 , xm2 , xm3 , &
904
+ indexing &
905
+ )
906
+ real (sp), intent (in ) :: x1(:)
907
+ real (sp), intent (out ) :: xm1 (:,:,:)
908
+ real (sp), intent (in ) :: x2(:)
909
+ real (sp), intent (out ) :: xm2 (:,:,:)
910
+ real (sp), intent (in ) :: x3(:)
911
+ real (sp), intent (out ) :: xm3 (:,:,:)
912
+ integer , intent (in ), optional :: indexing
913
+ end subroutine meshgrid_3_rsp_rsp
914
+ module subroutine meshgrid_4_rsp_rsp (&
915
+ x1 , x2 , x3 , x4 , &
916
+ xm1 , xm2 , xm3 , xm4 , &
917
+ indexing &
918
+ )
919
+ real (sp), intent (in ) :: x1(:)
920
+ real (sp), intent (out ) :: xm1 (:,:,:,:)
921
+ real (sp), intent (in ) :: x2(:)
922
+ real (sp), intent (out ) :: xm2 (:,:,:,:)
923
+ real (sp), intent (in ) :: x3(:)
924
+ real (sp), intent (out ) :: xm3 (:,:,:,:)
925
+ real (sp), intent (in ) :: x4(:)
926
+ real (sp), intent (out ) :: xm4 (:,:,:,:)
927
+ integer , intent (in ), optional :: indexing
928
+ end subroutine meshgrid_4_rsp_rsp
929
+ module subroutine meshgrid_1_rdp_rdp (&
930
+ x1 , &
931
+ xm1 , &
932
+ indexing &
933
+ )
934
+ real (dp), intent (in ) :: x1(:)
935
+ real (dp), intent (out ) :: xm1 (:)
936
+ integer , intent (in ), optional :: indexing
937
+ end subroutine meshgrid_1_rdp_rdp
938
+ module subroutine meshgrid_2_rdp_rdp (&
939
+ x1 , x2 , &
940
+ xm1 , xm2 , &
941
+ indexing &
942
+ )
943
+ real (dp), intent (in ) :: x1(:)
944
+ real (dp), intent (out ) :: xm1 (:,:)
945
+ real (dp), intent (in ) :: x2(:)
946
+ real (dp), intent (out ) :: xm2 (:,:)
947
+ integer , intent (in ), optional :: indexing
948
+ end subroutine meshgrid_2_rdp_rdp
949
+ module subroutine meshgrid_3_rdp_rdp (&
950
+ x1 , x2 , x3 , &
951
+ xm1 , xm2 , xm3 , &
952
+ indexing &
953
+ )
954
+ real (dp), intent (in ) :: x1(:)
955
+ real (dp), intent (out ) :: xm1 (:,:,:)
956
+ real (dp), intent (in ) :: x2(:)
957
+ real (dp), intent (out ) :: xm2 (:,:,:)
958
+ real (dp), intent (in ) :: x3(:)
959
+ real (dp), intent (out ) :: xm3 (:,:,:)
960
+ integer , intent (in ), optional :: indexing
961
+ end subroutine meshgrid_3_rdp_rdp
962
+ module subroutine meshgrid_4_rdp_rdp (&
963
+ x1 , x2 , x3 , x4 , &
964
+ xm1 , xm2 , xm3 , xm4 , &
965
+ indexing &
966
+ )
967
+ real (dp), intent (in ) :: x1(:)
968
+ real (dp), intent (out ) :: xm1 (:,:,:,:)
969
+ real (dp), intent (in ) :: x2(:)
970
+ real (dp), intent (out ) :: xm2 (:,:,:,:)
971
+ real (dp), intent (in ) :: x3(:)
972
+ real (dp), intent (out ) :: xm3 (:,:,:,:)
973
+ real (dp), intent (in ) :: x4(:)
974
+ real (dp), intent (out ) :: xm4 (:,:,:,:)
975
+ integer , intent (in ), optional :: indexing
976
+ end subroutine meshgrid_4_rdp_rdp
977
+ end interface meshgrid
679
978
contains
680
979
681
980
elemental function clip_int8 (x , xmin , xmax ) result(res)
0 commit comments