improved math_expand algorithm
This commit is contained in:
parent
f3292507b5
commit
80bed8b8aa
11
src/math.f90
11
src/math.f90
|
@ -74,6 +74,7 @@ module math
|
||||||
public :: &
|
public :: &
|
||||||
math_init, &
|
math_init, &
|
||||||
math_qsort, &
|
math_qsort, &
|
||||||
|
math_expand, &
|
||||||
math_range, &
|
math_range, &
|
||||||
math_identity2nd, &
|
math_identity2nd, &
|
||||||
math_identity4th, &
|
math_identity4th, &
|
||||||
|
@ -382,14 +383,12 @@ pure function math_expand(what,how)
|
||||||
real(pReal), dimension(:), intent(in) :: what
|
real(pReal), dimension(:), intent(in) :: what
|
||||||
integer(pInt), dimension(:), intent(in) :: how
|
integer(pInt), dimension(:), intent(in) :: how
|
||||||
real(pReal), dimension(sum(how)) :: math_expand
|
real(pReal), dimension(sum(how)) :: math_expand
|
||||||
integer(pInt) :: i,j,o
|
integer(pInt) :: i,o
|
||||||
|
|
||||||
o = 0_pInt
|
o = 1_pInt
|
||||||
do i = 1, size(how)
|
do i = 1, size(how)
|
||||||
do j = 1, how(i)
|
math_expand(o:o+how(i)-1_pInt) = what(1+mod(i-1,size(what)))
|
||||||
o = o + 1_pInt
|
o = o + how(i)
|
||||||
math_expand(o) = what(1+mod(i-1,size(what)))
|
|
||||||
enddo
|
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
end function math_expand
|
end function math_expand
|
||||||
|
|
Loading…
Reference in New Issue