ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_complexMinMax::maxloc Interface Reference

Generate and return the component-wise location of the maximum value of (both real and imaginary parts of) the input complex. More...

Detailed Description

Generate and return the component-wise location of the maximum value of (both real and imaginary parts of) the input complex.

This generic interfaces extends the behavior of the intrinsic Fortran maxloc(a, dim = dim) for arguments of real type to arguments of type complex.

Parameters
[in]array: The input array of rank (1..2) of type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128).
[in]dim: The input scalar of type integer of default kind IK of value 1 <= dim <= rank(array), representing the dimension along which the location of the maximum must be computed.
(optional. If missing, the output value is a scalar containing the location of the maximum of the entire input array.)
Returns
val : The output,
  1. vector of size 2, if array is of rank 1 or if the input argument dim is missing,
  2. array of shape (1:2, size(array, 3 - dim)), if array is of rank 2 and the input argument dim is present,
of type integer of default kind IK.
  1. The elements in the first row of loc contain the locations of the first occurrences of the maximum values of the corresponding real parts of the input array.
  2. The elements in the second row of loc contain the locations of the first occurrences of the maximum values of the corresponding imaginary parts of the input array.
The returned locations are 0 if the input array has a zero size.


Possible calling interfaces

loc(1:2) = maxloc(array) ! = [maxloc(array%re), maxloc(array%im)]
loc(1:2) = maxloc(array(:), dim) ! = [maxloc(array%re, dim), maxloc(array%im, dim)]
loc(1:2, 1:size(array, 3 - dim)) = maxloc(array(:,:), dim)
Generate and return the component-wise location of the maximum value of (both real and imaginary part...
This module contains procedures and generic interfaces for computing element-wise minimum/maximum val...
Warning
The condition 1 <= dim .and. dim <= rank(sample) must hold for the corresponding input arguments.
This condition is verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
See also
min
max
minval
maxval
minloc
maxloc
pm_complexCompareAll
pm_complexCompareAny
pm_complexCompareLex
pm_arrayMinMax
pm_mathMinMax


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_complexMinMax, only: maxloc
5 use pm_distUnif, only: getUnifRand
6 use pm_io, only: display_type
7
8 implicit none
9
10 integer(IK) :: ndim, nsam
11 type(display_type) :: disp
12 disp = display_type(file = "main.out.F90")
13
14 block
15 use pm_kind, only: CKG => CKS
16 complex(CKG), allocatable :: array(:,:)
17 call disp%skip()
18 call disp%show("ndim = 3; nsam = 5")
19 ndim = 3; nsam = 5
20 call disp%show("array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)")
21 array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)
22 call disp%show("array")
23 call disp%show( array )
24 call disp%show("maxloc(array)")
25 call disp%show( maxloc(array) )
26 call disp%show("maxloc(array, dim = 1_IK)")
27 call disp%show( maxloc(array, dim = 1_IK) )
28 call disp%show("maxloc(array, dim = 2_IK)")
29 call disp%show( maxloc(array, dim = 2_IK) )
30 call disp%show("maxloc([complex(CKG)::])")
31 call disp%show( maxloc([complex(CKG)::]) )
32 call disp%show("maxloc([complex(CKG)::], dim = 1_IK)")
33 call disp%show( maxloc([complex(CKG)::], dim = 1_IK) )
34 call disp%show("maxloc([complex(CKG)::], dim = 2_IK)")
35 call disp%show( maxloc([complex(CKG)::], dim = 2_IK) )
36 call disp%skip()
37 end block
38
39 block
40 use pm_kind, only: CKG => CKD
41 complex(CKG), allocatable :: array(:,:)
42 call disp%skip()
43 call disp%show("ndim = 3; nsam = 5")
44 ndim = 3; nsam = 5
45 call disp%show("array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)")
46 array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)
47 call disp%show("array")
48 call disp%show( array )
49 call disp%show("maxloc(array)")
50 call disp%show( maxloc(array) )
51 call disp%show("maxloc(array, dim = 1_IK)")
52 call disp%show( maxloc(array, dim = 1_IK) )
53 call disp%show("maxloc(array, dim = 2_IK)")
54 call disp%show( maxloc(array, dim = 2_IK) )
55 call disp%show("maxloc([complex(CKG)::])")
56 call disp%show( maxloc([complex(CKG)::]) )
57 call disp%show("maxloc([complex(CKG)::], dim = 1_IK)")
58 call disp%show( maxloc([complex(CKG)::], dim = 1_IK) )
59 call disp%show("maxloc([complex(CKG)::], dim = 2_IK)")
60 call disp%show( maxloc([complex(CKG)::], dim = 2_IK) )
61 call disp%skip()
62 end block
63
64 block
65 use pm_kind, only: CKG => CKH
66 complex(CKG), allocatable :: array(:,:)
67 call disp%skip()
68 call disp%show("ndim = 3; nsam = 5")
69 ndim = 3; nsam = 5
70 call disp%show("array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)")
71 array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)
72 call disp%show("array")
73 call disp%show( array )
74 call disp%show("maxloc(array)")
75 call disp%show( maxloc(array) )
76 call disp%show("maxloc(array, dim = 1_IK)")
77 call disp%show( maxloc(array, dim = 1_IK) )
78 call disp%show("maxloc(array, dim = 2_IK)")
79 call disp%show( maxloc(array, dim = 2_IK) )
80 call disp%show("maxloc([complex(CKG)::])")
81 call disp%show( maxloc([complex(CKG)::]) )
82 call disp%show("maxloc([complex(CKG)::], dim = 1_IK)")
83 call disp%show( maxloc([complex(CKG)::], dim = 1_IK) )
84 call disp%show("maxloc([complex(CKG)::], dim = 2_IK)")
85 call disp%show( maxloc([complex(CKG)::], dim = 2_IK) )
86 call disp%skip()
87 end block
88
89end program example
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for computing various statistical quantities related to t...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter CKH
The scalar integer constant of intrinsic default kind, representing the highest-precision complex kin...
Definition: pm_kind.F90:843
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
Definition: pm_kind.F90:570
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter CKD
The double precision complex kind in Fortran mode. On most platforms, this is a 64-bit real kind.
Definition: pm_kind.F90:571
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2ndim = 3; nsam = 5
3array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)
4array
5(-8.78194046, +3.47414970), (+8.79135513, +0.697899818), (-8.03136826, +6.93602371), (+8.49336243, -4.56511784), (-5.64777279, -4.81931591)
6(-5.30135918, +0.426164627), (-2.61457348, +4.73218632), (+7.87217855, -2.30726933), (+7.33732224, -5.95557404), (+5.78321838, +7.45577955)
7(-8.00815010, -8.93078423), (-7.18362474, +8.97918320), (-3.50221419, +4.63403606), (+8.40249443, +6.26731110), (+4.89908600, -2.44802094)
8maxloc(array)
9+4, +6
10maxloc(array, dim = 1_IK)
11+2, +1, +2, +1, +2
12+1, +3, +1, +3, +2
13maxloc(array, dim = 2_IK)
14+2, +3, +4
15+3, +5, +2
16maxloc([complex(CKG)::])
17+0, +0
18maxloc([complex(CKG)::], dim = 1_IK)
19+0, +0
20maxloc([complex(CKG)::], dim = 2_IK)
21+0, +0
22
23
24ndim = 3; nsam = 5
25array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)
26array
27(-0.70898817382399315, -8.3469603152713923), (-2.1309641638310257, -7.8052671272072764), (-0.56286186752471679, -5.0202376313549557), (-0.47662369771161828, +7.5305265631827618), (-2.2519605043786335, -8.8950286867097610)
28(-4.4334445994928142, -1.5092078409581995), (-8.4480493670047743, -1.7392570062733843), (+1.7047952570371172, -5.9861708967364695), (+1.0819321523177901, -2.1823578248826401), (+8.4226111443162637, +3.5813424942020315)
29(-3.3250832244041866, +2.5424626918013775), (+5.8885224654566262, -7.3018147081806823), (+3.5928451647129074, +2.0775367984431039), (+1.8974058686450643, -5.9380449429161803), (-4.1680922542730698, +4.8458590019564038)
30maxloc(array)
31+14, +10
32maxloc(array, dim = 1_IK)
33+1, +3, +3, +3, +2
34+3, +2, +3, +1, +3
35maxloc(array, dim = 2_IK)
36+4, +5, +2
37+4, +5, +5
38maxloc([complex(CKG)::])
39+0, +0
40maxloc([complex(CKG)::], dim = 1_IK)
41+0, +0
42maxloc([complex(CKG)::], dim = 2_IK)
43+0, +0
44
45
46ndim = 3; nsam = 5
47array = getUnifRand((-9._CKG, -9._CKG), (+9._CKG, +9._CKG), ndim, nsam)
48array
49(+1.90254449850793376615282134973470783, -5.50090925549086996478465049856450409), (+3.53126672517116405360364814240748712, +5.92328905900090545696200522421820622), (+0.362898728736214255805516417237930851, +5.52904109704567341749703359525356196), (-5.47433927353377148392532773076620113, -6.59334801170062455661201736953041585), (+3.56315278426792842283377316599802958, -7.95594983202456299497464004098842442)
50(-5.45650820102160235245704634993105400, +8.32161397394863223493164752997483320), (-0.472381251594697042911791888004271487, +0.761343211443685345640185485089176501), (+1.93590317957779206319836207716975009, +2.05976216749427508569404514476202655), (-8.07112734316731696388112866559093925, -5.45741352769508857537160653239118118), (+0.660600309579940141703927149297605800, +6.91280487393623141646935764003677273)
51(-6.90823572710216085150819160620886451, +1.51489879837198996852663934735429640), (-8.46274982217222191677744815988973335, -8.35713082324746024321177167572460867), (-1.28527097950918311974168091269338205, +0.261605036263893681361874442364759567), (+3.65501031906140454169530791105201450, +3.07848502429842287487240222092413287), (-3.20799615540214803461398926191297055, +2.30608332642260726438977336166879445)
52maxloc(array)
53+12, +2
54maxloc(array, dim = 1_IK)
55+1, +1, +2, +3, +1
56+2, +1, +1, +3, +2
57maxloc(array, dim = 2_IK)
58+5, +3, +4
59+2, +1, +4
60maxloc([complex(CKG)::])
61+0, +0
62maxloc([complex(CKG)::], dim = 1_IK)
63+0, +0
64maxloc([complex(CKG)::], dim = 2_IK)
65+0, +0
66
67
Test:
test_pm_complexMinMax
Todo:
Normal Priority: This generic interface can be extended with optional mask and back arguments to match those of the intrinsic maxloc().


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 1282 of file pm_complexMinMax.F90.


The documentation for this interface was generated from the following file: