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.
123123
124124### Return value
125125
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.
127128
128129#### Warning
129130
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:
131132``` fortran
132133real :: A(:,:)
133134!> Be careful
Original file line number Diff line number Diff line change @@ -91,17 +91,17 @@ contains
9191
9292 integer, intent(in) :: dim1
9393 integer, intent(in), optional :: dim2
94- integer, allocatable :: result(:, :)
94+ integer(int8) , allocatable :: result(:, :)
9595
9696 integer :: dim2_
9797 integer :: i
9898
9999 dim2_ = optval(dim2, dim1)
100100 allocate(result(dim1, dim2_))
101101
102- result = 0
102+ result = 0_int8
103103 do i = 1, min(dim1, dim2_)
104- result(i, i) = 1
104+ result(i, i) = 1_int8
105105 end do
106106
107107 end function eye
You can’t perform that action at this time.
0 commit comments