MatrixDiag_mod::genEye Interface Reference

Generate an identity matrix of shape (nrow,ncol). Note that all diagonal elements of the output matrix are set to 1. More...

Detailed Description

Generate an identity matrix of shape (nrow,ncol). Note that all diagonal elements of the output matrix are set to 1.

Parameters
[in]nrow: The input positive integer of default kind IK representing the number of rows of the eye matrix.
[in]ncol: The input positive integer of default kind IK representing the number of columns of the eye matrix.
[in]like: The input scalar number of either
  type real of kind RK32, RK64, or RK128 or
  type complex of kind CK32, CK64, or CK128.
  The type and kind of like shall be used to set the type and kind of the output matrix. The value of like is ignored.
  (optional, default = 0._RK, that is, a real number of default kind RK).
Returns
Eye : The output identity matrix of shape (nrow,ncol) whose diagonal elements are set to unity. If the input argument like is missing, then the output matrix will be of type real of default kind RK. Otherwise, it will have the same type and kind as the input scalar like.
Warning
The positivity of the input values for nrow and ncol is only checked when the preprocessor flag CHECK_ENABLED=1 is set.
This pure procedures documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1. By default, pure procedures are pure in release build and impure in debug and testing builds.
See also
getEye
genDiag

Example usage

1program example
2
3 use Constants_mod, only: IK
4 use Constants_mod, only: CK32, CK64, CK128
5 use Constants_mod, only: RK32, RK64, RK128
6 use Constants_mod, only: IK8, IK16, IK32, IK64
8 use MatrixDiag_mod, only: genEye
9
10 implicit none
11
12 type(Display_type) :: Display
13
14 Display = Display_type(file = "main.out.f90", marginBottom = 1_IK)
15
16 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 ! Real eye of different shapes of default kind.
18 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
20 call Display%write("genEye(3_IK, 3_IK) =")
21 call Display%write( genEye(3_IK, 3_IK) )
22
23 call Display%write("genEye(4_IK, 2_IK) =")
24 call Display%write( genEye(4_IK, 2_IK) )
25
26 call Display%write("genEye(2_IK, 3_IK) =")
27 call Display%write( genEye(2_IK, 3_IK) )
28
29 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 ! Complex eye of different shapes.
31 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
33 call Display%write("genEye(2_IK, 2_IK, like = (0._CK128, 0._CK128)) =")
34 call Display%write( genEye(2_IK, 2_IK, like = (0._CK128, 0._CK128)) )
35
36 call Display%write("genEye(5_IK, 2_IK, like = (0._CK64, 0._CK64)) =")
37 call Display%write( genEye(5_IK, 2_IK, like = (0._CK64, 0._CK64)) )
38
39 call Display%write("genEye(2_IK, 4_IK, like = (0._CK32, 0._CK32)) =")
40 call Display%write( genEye(2_IK, 4_IK, like = (0._CK32, 0._CK32)) )
41
42 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 ! Real eye of different shapes.
44 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45
46 call Display%write("genEye(2_IK, 2_IK, like = 0._RK128) =")
47 call Display%write( genEye(2_IK, 2_IK, like = 0._RK128) )
48
49 call Display%write("genEye(1_IK, 1_IK, like = 0._RK64) =")
50 call Display%write( genEye(1_IK, 1_IK, like = 0._RK64) )
51
52 call Display%write("genEye(3_IK, 3_IK, like = 0._RK32) =")
53 call Display%write( genEye(3_IK, 3_IK, like = 0._RK32) )
54
55end program example
Generate an identity matrix of shape (nrow,ncol). Note that all diagonal elements of the output matri...
This module contains the mathematical and programming constants.
integer, parameter IK
default integer kind in Fortran mode.
integer, parameter RK64
64-bit real kind in Fortran mode.
integer, parameter CK64
double-precision complex kind.
integer, parameter RK32
32-bit real kind in Fortran mode.
integer, parameter IK32
32-bit integer kind in Fortran mode.
integer, parameter CK32
single-precision complex kind.
integer, parameter IK16
16-bit integer kind in Fortran mode.
integer, parameter CK128
quad-precision complex kind.
integer, parameter IK64
64-bit integer kind in Fortran mode.
integer, parameter IK8
8-bit integer kind in Fortran mode.
integer, parameter RK128
128-bit real kind in Fortran mode.
This module contains classes and procedures for decorating and outputting text.
This module contains mathematical procedures relevant to generating diagonal matrices or extracting t...

Example Unix compile command via GNU gfortran compiler
1#!/bin/bash
2gfortran -O3 -ffree-line-length-none -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_gnu_*.so -o main.exe
3./main.exe

Example Unix compile command via Intel ifort compiler
1#!/bin/bash
2ifort -standard-semantics -O3 -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_intel_*.so -o main.exe
3./main.exe

Example output
1genEye(3_IK, 3_IK) =
2
3+1.0000000000000000, +0.0000000000000000, +0.0000000000000000
4+0.0000000000000000, +1.0000000000000000, +0.0000000000000000
5+0.0000000000000000, +0.0000000000000000, +1.0000000000000000
6
7genEye(4_IK, 2_IK) =
8
9+1.0000000000000000, +0.0000000000000000
10+0.0000000000000000, +1.0000000000000000
11+0.0000000000000000, +0.0000000000000000
12+0.0000000000000000, +0.0000000000000000
13
14genEye(2_IK, 3_IK) =
15
16+1.0000000000000000, +0.0000000000000000, +0.0000000000000000
17+0.0000000000000000, +1.0000000000000000, +0.0000000000000000
18
19genEye(2_IK, 2_IK, like = (0._CK128, 0._CK128)) =
20
21(+1.00000000000000000000000000000000000, +0.00000000000000000000000000000000000), (+0.00000000000000000000000000000000000, +0.00000000000000000000000000000000000)
22(+0.00000000000000000000000000000000000, +0.00000000000000000000000000000000000), (+1.00000000000000000000000000000000000, +0.00000000000000000000000000000000000)
23
24genEye(5_IK, 2_IK, like = (0._CK64, 0._CK64)) =
25
26(+1.0000000000000000, +0.0000000000000000), (+0.0000000000000000, +0.0000000000000000)
27(+0.0000000000000000, +0.0000000000000000), (+1.0000000000000000, +0.0000000000000000)
28(+0.0000000000000000, +0.0000000000000000), (+0.0000000000000000, +0.0000000000000000)
29(+0.0000000000000000, +0.0000000000000000), (+0.0000000000000000, +0.0000000000000000)
30(+0.0000000000000000, +0.0000000000000000), (+0.0000000000000000, +0.0000000000000000)
31
32genEye(2_IK, 4_IK, like = (0._CK32, 0._CK32)) =
33
34(+1.00000000, +0.00000000), (+0.00000000, +0.00000000), (+0.00000000, +0.00000000), (+0.00000000, +0.00000000)
35(+0.00000000, +0.00000000), (+1.00000000, +0.00000000), (+0.00000000, +0.00000000), (+0.00000000, +0.00000000)
36
37genEye(2_IK, 2_IK, like = 0._RK128) =
38
39+1.00000000000000000000000000000000000, +0.00000000000000000000000000000000000
40+0.00000000000000000000000000000000000, +1.00000000000000000000000000000000000
41
42genEye(1_IK, 1_IK, like = 0._RK64) =
43
44+1.0000000000000000
45
46genEye(3_IK, 3_IK, like = 0._RK32) =
47
48+1.00000000, +0.00000000, +0.00000000
49+0.00000000, +1.00000000, +0.00000000
50+0.00000000, +0.00000000, +1.00000000
51
Test:
Test_MatrixDiag_mod
Todo:
The functionality of this interface can be expanded to make the input argument ncol optional by adding further possible interfaces.
Remarks
For details of naming abbreviations, see this page.
For details of the naming conventions, see this page.
This software is distributed under the MIT-license. If you use any parts or concepts originated from this library, please acknowledge the usage by citing the publications of the ParaMonte library.
Author
Amir Shahmoradi, Apr 21, 2017, 1:54 AM, ICES, The University of Texas at Austin

Definition at line 552 of file MatrixDiag_mod.f90.


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