Generate an identity matrix of shape (nrow,ncol)
. Note that all diagonal elements of the output matrix are set to 1
.
More...
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 ⛓
12 type(Display_type) :: Display
14 Display
= Display_type(file
= "main.out.f90", marginBottom
= 1_IK)
20 call Display
%write(
"genEye(3_IK, 3_IK) =")
21 call Display
%write(
genEye(
3_IK,
3_IK) )
23 call Display
%write(
"genEye(4_IK, 2_IK) =")
24 call Display
%write(
genEye(
4_IK,
2_IK) )
26 call Display
%write(
"genEye(2_IK, 3_IK) =")
27 call Display
%write(
genEye(
2_IK,
3_IK) )
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)) )
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)) )
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)) )
46 call Display
%write(
"genEye(2_IK, 2_IK, like = 0._RK128) =")
47 call Display
%write(
genEye(
2_IK,
2_IK, like
= 0._RK128) )
49 call Display
%write(
"genEye(1_IK, 1_IK, like = 0._RK64) =")
50 call Display
%write(
genEye(
1_IK,
1_IK, like
= 0._RK64) )
52 call Display
%write(
"genEye(3_IK, 3_IK, like = 0._RK32) =")
53 call Display
%write(
genEye(
3_IK,
3_IK, like
= 0._RK32) )
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 ⛓
2gfortran -O3 -ffree-line-length-none -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_gnu_*.so -o main.exe
Example Unix compile command via Intel ifort
compiler ⛓
2ifort -standard-semantics -O3 -Wl,-rpath,../../../../lib -I../../../../include main.f90 ../../../../lib/libparamonte_fortran_*_intel_*.so -o main.exe
Example output ⛓
3+1.0000000000000000,
+0.0000000000000000,
+0.0000000000000000
4+0.0000000000000000,
+1.0000000000000000,
+0.0000000000000000
5+0.0000000000000000,
+0.0000000000000000,
+1.0000000000000000
9+1.0000000000000000,
+0.0000000000000000
10+0.0000000000000000,
+1.0000000000000000
11+0.0000000000000000,
+0.0000000000000000
12+0.0000000000000000,
+0.0000000000000000
16+1.0000000000000000,
+0.0000000000000000,
+0.0000000000000000
17+0.0000000000000000,
+1.0000000000000000,
+0.0000000000000000
19genEye(
2_IK,
2_IK, like
= (
0._CK128,
0._CK128))
=
21(
+1.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000), (
+0.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000)
22(
+0.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000), (
+1.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000)
24genEye(
5_IK,
2_IK, like
= (
0._CK64,
0._CK64))
=
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)
32genEye(
2_IK,
4_IK, like
= (
0._CK32,
0._CK32))
=
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)
37genEye(
2_IK,
2_IK, like
= 0._RK128)
=
39+1.00000000000000000000000000000000000,
+0.00000000000000000000000000000000000
40+0.00000000000000000000000000000000000,
+1.00000000000000000000000000000000000
42genEye(
1_IK,
1_IK, like
= 0._RK64)
=
46genEye(
3_IK,
3_IK, like
= 0._RK32)
=
48+1.00000000,
+0.00000000,
+0.00000000
49+0.00000000,
+1.00000000,
+0.00000000
50+0.00000000,
+0.00000000,
+1.00000000
- 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.
- 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: