File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -123,11 +123,12 @@ This is an `intent(in)` and `optional` argument.
123
123
124
124
### Return value
125
125
126
- Return the identity matrix, i.e. a matrix with ones on the main diagonal and zeros elsewhere. The return value is of type ` integer ` .
126
+ Return the identity matrix, i.e. a matrix with ones on the main diagonal and zeros elsewhere. The return value is of type ` integer(int8) ` .
127
+ The use of ` int8 ` was suggested to save storage.
127
128
128
129
#### Warning
129
130
130
- Since the result of ` eye ` is of ` integer ` type, one should be careful about using it in arithmetic expressions. For example:
131
+ Since the result of ` eye ` is of ` integer(int8) ` type, one should be careful about using it in arithmetic expressions. For example:
131
132
``` fortran
132
133
real :: A(:,:)
133
134
!> Be careful
Original file line number Diff line number Diff line change @@ -91,17 +91,17 @@ contains
91
91
92
92
integer, intent(in) :: dim1
93
93
integer, intent(in), optional :: dim2
94
- integer, allocatable :: result(:, :)
94
+ integer(int8) , allocatable :: result(:, :)
95
95
96
96
integer :: dim2_
97
97
integer :: i
98
98
99
99
dim2_ = optval(dim2, dim1)
100
100
allocate(result(dim1, dim2_))
101
101
102
- result = 0
102
+ result = 0_int8
103
103
do i = 1, min(dim1, dim2_)
104
- result(i, i) = 1
104
+ result(i, i) = 1_int8
105
105
end do
106
106
107
107
end function eye
You can’t perform that action at this time.
0 commit comments