Skip to content

Addition of a subroutine to compute the median of array elements #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8dddff4
progress
jvdp1 Jun 3, 2021
dbc16af
median: add subroutine to compute median of elements of an array
jvdp1 Jun 4, 2021
5d38d82
median: mv to ord_sort + combine REAL and INTEGER procedures
jvdp1 Jun 5, 2021
935949e
median: mv to sort due to issue #428
jvdp1 Jun 5, 2021
d506f4a
median: some cleaning
jvdp1 Jun 6, 2021
2bc1a8b
median: remove trailing whitespaces
jvdp1 Jun 6, 2021
ac1a2a2
median: add check on shapes between mask and x
jvdp1 Jun 11, 2021
fdfd150
median: add pure statement
jvdp1 Jun 11, 2021
b19c537
Update src/stdlib_stats_median.fypp
jvdp1 Jun 11, 2021
8ed99fe
Update src/stdlib_stats_median.fypp
jvdp1 Jun 11, 2021
0d46361
median: update test
jvdp1 Jun 11, 2021
bad19f8
Merge branch 'median' of https://github.com/jvdp1/stdlib into median
jvdp1 Jun 11, 2021
3342c6a
median: add comments to common.fypp
jvdp1 Jun 11, 2021
929d5c1
Merge remote-tracking branch 'upstream/master' into median
jvdp1 Jun 16, 2021
7e3111e
median: replace sort to ord_sort
jvdp1 Jun 16, 2021
dfea79d
update specs
jvdp1 Jul 4, 2021
8f4a57f
modif reduce_subvector + select_subvector
jvdp1 Jul 4, 2021
4f43ce5
add comment regarding ord_sort
jvdp1 Jul 4, 2021
6644140
add comment + combined fypp loops
jvdp1 Jul 4, 2021
2ca833a
update hyperlinks
jvdp1 Jul 4, 2021
e0f68ed
add link in stdlib_stats.md
jvdp1 Jul 4, 2021
3eb4e4a
formatting
jvdp1 Jul 4, 2021
de2c419
Apply suggestions from code review
jvdp1 Jul 21, 2021
9bbcb74
median: reorder fypp variable
jvdp1 Jul 21, 2021
f17b890
median: replace _ by numbers
jvdp1 Jul 21, 2021
391c658
median: add in common.fypp where it is used for median case
jvdp1 Jul 21, 2021
afc92a2
median: add comment in test median
jvdp1 Jul 21, 2021
4d328dc
median: add warning about naive implementation
jvdp1 Jul 21, 2021
bdb47b7
median: return NaN when real array contain NaN
jvdp1 Jul 21, 2021
227f021
@ivan-pi suggestions from code review
jvdp1 Jul 23, 2021
9d38d9d
median: rename fypp RName by name
jvdp1 Jul 23, 2021
cbdc4ac
median: replace median_mask_all by median_all_mask
jvdp1 Jul 23, 2021
a13c700
Merge branch 'median' of https://github.com/jvdp1/stdlib into median
jvdp1 Jul 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
median: replace _ by numbers
  • Loading branch information
jvdp1 committed Jul 21, 2021
commit f17b890e7d42ff192ce7af8d1730de6b672b7ed7
12 changes: 6 additions & 6 deletions src/common.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ ${prefix + joinstr.join([line.strip() for line in txt.split("\n")]) + suffix}$
#!
#! E.g.,
#! select_subvector('j', 5, 2)
#! -> (j_, :, j___, j____, j_____)
#! -> (j1, :, j3, j4, j5)
#!
#:def select_subvector(varname, rank, idim)
#:assert rank > 0
#:call join_lines(joinstr=", ", prefix="(", suffix=")")
#:for i in range(1, idim)
${varname}$${ "_" * (i) }$
${varname}$${i}$
#:endfor
:
#:for i in range(idim + 1, rank + 1)
${varname}$${ "_" * (i) }$
${varname}$${i}$
#:endfor
#:endcall
#:enddef
Expand All @@ -197,17 +197,17 @@ ${prefix + joinstr.join([line.strip() for line in txt.split("\n")]) + suffix}$
#!
#! E.g.,
#! reduce_subvector('j', 5, 2)
#! -> (j_, j___, j____, j_____)
#! -> (j1, j3, j4, j5)
#!
#:def reduce_subvector(varname, rank, idim)
#:assert rank > 0
#:if rank > 1
#:call join_lines(joinstr=", ", prefix="(", suffix=")")
#:for i in range(1, idim)
${varname}$${ "_" * (i) }$
${varname}$${i}$
#:endfor
#:for i in range(idim + 1, rank + 1)
${varname}$${ "_" * (i) }$
${varname}$${i}$
#:endfor
#:endcall
#:endif
Expand Down
8 changes: 4 additions & 4 deletions src/stdlib_stats_median.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contains
integer :: c, n
#:if rank > 1
#:for fj in range(1, rank+1)
integer :: j${"_" * fj}$
integer :: j${fj}$
#:endfor
#:endif
${t1}$, allocatable :: x_tmp(:)
Expand All @@ -84,7 +84,7 @@ contains
case(${fi}$)
! Loop over every dimension of the array except "dim"
#:for fj in list(range(1, fi)) + list(range(fi+1, rank+1))
do j${"_" * fj}$ = 1, size(x, ${fj}$)
do j${fj}$ = 1, size(x, ${fj}$)
#:endfor
x_tmp(:) = x${select_subvector('j', rank, fi)}$
call sort(x_tmp)
Expand Down Expand Up @@ -162,7 +162,7 @@ contains
integer(kind = int64) :: c, n
#:if rank > 1
#:for fj in range(1, rank+1)
integer :: j${"_" * fj}$
integer :: j${fj}$
#:endfor
#:endif
${t1}$, allocatable :: x_tmp(:)
Expand All @@ -176,7 +176,7 @@ contains
case(${fi}$)
! Loop over every dimension of the array except "dim"
#:for fj in list(range(1, fi)) + list(range(fi+1, rank+1))
do j${"_" * fj}$ = 1, size(x, ${fj}$)
do j${fj}$ = 1, size(x, ${fj}$)
#:endfor
x_tmp = pack(x${select_subvector('j', rank, fi)}$, &
mask${select_subvector('j', rank, fi)}$)
Expand Down