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

Generate and return the conversion of the input value to a complex value of default kind CK. More...

Detailed Description

Generate and return the conversion of the input value to a complex value of default kind CK.

Parameters
[in]val: The input scalar or array of arbitrary rank of either,
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU), or
  2. type logical of kind any supported by the processor (e.g., LK), or
whose value will be converted to an output of type complex of default kind CK.
Returns
conversion : The scalar or array of the same shape as the input val of the type complex of default kind CK, containing the conversion of the input value val.
  1. If the input val is a logical that evaluates to .true., then conversion = (1., 1.), otherwise conversion = (0., 0.).
  2. If the input val is a character, then conversion is the result of the List-directed I/O action read(val,*) conversion.


Possible calling interfaces

conversion = getComplex(val)
Generate and return the conversion of the input value to a complex value of default kind CK.
This module contains procedures and types for facilitating the conversion of values of different type...
Remarks
The procedures under discussion are pure.
The procedures under discussion are elemental.
See also
getStr
getInt
setInt
getReal
setReal
getComplex
setComplex
getLogical
setLogical


Example usage

1program example
2
3 use pm_kind, only: IK
4 use pm_kind, only: LK, SK ! all processor types and kinds are supported.
5 use pm_io, only: display_type
7
8 implicit none
9
10 type(display_type) :: disp
11 disp = display_type(file = "main.out.F90")
12
13 call disp%skip()
14 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
15 call disp%show("! Convert logical values to complex.")
16 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
17 call disp%skip()
18
19 call disp%skip()
20 call disp%show("getComplex(.true._LK)")
21 call disp%show( getComplex(.true._LK) )
22 call disp%skip()
23
24 call disp%skip()
25 call disp%show("getComplex(.false._LK)")
26 call disp%show( getComplex(.false._LK) )
27 call disp%skip()
28
29 call disp%skip()
30 call disp%show("getComplex([.true._LK, .false._LK, .true._LK])")
31 call disp%show( getComplex([.true._LK, .false._LK, .true._LK]) )
32 call disp%skip()
33
34 call disp%skip()
35 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
36 call disp%show("! Convert string values to complex.")
37 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
38 call disp%skip()
39
40 call disp%skip()
41 call disp%show("getComplex(SK_'1.e0')")
42 call disp%show( getComplex(SK_'1.e0') )
43 call disp%skip()
44
45 call disp%skip()
46 call disp%show("getComplex(SK_'1.d0')")
47 call disp%show( getComplex(SK_'1.d0') )
48 call disp%skip()
49
50 call disp%skip()
51 call disp%show("getComplex(SK_'1.d0 -1.d0')")
52 call disp%show( getComplex(SK_'1.d0 -1.d0') )
53 call disp%skip()
54
55 call disp%skip()
56 call disp%show("getComplex(SK_'1.d0, -1.d0')")
57 call disp%show( getComplex(SK_'1.d0, -1.d0') )
58 call disp%skip()
59
60 call disp%skip()
61 call disp%show("getComplex(SK_'(1.d0, -1.d0)')")
62 call disp%show( getComplex(SK_'(1.d0, -1.d0)') )
63 call disp%skip()
64
65 call disp%skip()
66 call disp%show("getComplex(SK_'(1.d0, -1.e0)')")
67 call disp%show( getComplex(SK_'(1.d0, -1.e0)') )
68 call disp%skip()
69
70 call disp%skip()
71 call disp%show("getComplex(SK_'(1., -1.), paramonte')")
72 call disp%show( getComplex(SK_'(1., -1.), paramonte') )
73 call disp%skip()
74
75 call disp%skip()
76 call disp%show("getComplex([character(10,SK) :: '1, -1', '1, paramonte', '100, -100'])")
77 call disp%show( getComplex([character(10,SK) :: '1, -1', '1, paramonte', '100, -100']) )
78 call disp%skip()
79
80 call disp%skip()
81 call disp%show("getComplex(SK_'1., -1., paramonte')")
82 call disp%show( getComplex(SK_'1., -1., paramonte') )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("getComplex(SK_'1., paramonte')")
87 call disp%show( getComplex(SK_'1., paramonte') )
88 call disp%skip()
89
90 call disp%skip()
91 call disp%show("getComplex(SK_'1.d0')")
92 call disp%show( getComplex(SK_'1.d0') )
93 call disp%skip()
94
95 call disp%skip()
96 call disp%show("getComplex([character(10,SK) :: '(1, -1)', '10', '100, -100'])")
97 call disp%show( getComplex([character(10,SK) :: '(1, -1)', '10', '100, -100']) )
98 call disp%skip()
99
100end program example
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 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 LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
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 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
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3! Convert logical values to complex.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7getComplex(.true._LK)
8(+1.0000000000000000, +1.0000000000000000)
9
10
11getComplex(.false._LK)
12(+0.0000000000000000, +0.0000000000000000)
13
14
15getComplex([.true._LK, .false._LK, .true._LK])
16(+1.0000000000000000, +1.0000000000000000), (+0.0000000000000000, +0.0000000000000000), (+1.0000000000000000, +1.0000000000000000)
17
18
19!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20! Convert string values to complex.
21!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23
24getComplex(SK_'1.e0')
25(+1.0000000000000000, +0.0000000000000000)
26
27
28getComplex(SK_'1.d0')
29(+1.0000000000000000, +0.0000000000000000)
30
31
32getComplex(SK_'1.d0 -1.d0')
33(+1.0000000000000000, -1.0000000000000000)
34
35
36getComplex(SK_'1.d0, -1.d0')
37(+1.0000000000000000, -1.0000000000000000)
38
39
40getComplex(SK_'(1.d0, -1.d0)')
41(+1.0000000000000000, -1.0000000000000000)
42
43
44getComplex(SK_'(1.d0, -1.e0)')
45(+1.0000000000000000, -1.0000000000000000)
46
47
48getComplex(SK_'(1., -1.), paramonte')
49(+1.0000000000000000, -1.0000000000000000)
50
51
52getComplex([character(10,SK) :: '1, -1', '1, paramonte', '100, -100'])
53(+1.0000000000000000, -1.0000000000000000), (+1.0000000000000000, +0.0000000000000000), (+100.00000000000000, -100.00000000000000)
54
55
56getComplex(SK_'1., -1., paramonte')
57(+1.0000000000000000, -1.0000000000000000)
58
59
60getComplex(SK_'1., paramonte')
61(+1.0000000000000000, +0.0000000000000000)
62
63
64getComplex(SK_'1.d0')
65(+1.0000000000000000, +0.0000000000000000)
66
67
68getComplex([character(10,SK) :: '(1, -1)', '10', '100, -100'])
69(+1.0000000000000000, -1.0000000000000000), (+10.000000000000000, +0.0000000000000000), (+100.00000000000000, -100.00000000000000)
70
71
Test:
test_pm_val2complex
Todo:
Low Priority: This generic interface can be extended to support conversion to complex of arbitrary kind via an optional input mold argument whose type and kind dictates that of the output.


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 at Austin

Definition at line 113 of file pm_val2complex.F90.


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