Commit cefb5d10 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added percentile()

parent 46702ff7
......@@ -628,6 +628,8 @@ src/nth_element.h -text
src/operator_help.h -text
src/par_io.c -text
src/par_io.h -text
src/percentiles.c -text
src/percentiles.h -text
src/percentiles_hist.c -text
src/percentiles_hist.h -text
src/pipe.c -text
......
......@@ -92,6 +92,8 @@ libcdo_la_SOURCES = \
par_io.h \
percentiles_hist.c \
percentiles_hist.h \
percentiles.c \
percentiles.h \
pipe.c \
pipe.h \
pragma_omp_atomic_update.h \
......
......@@ -147,8 +147,8 @@ am_libcdo_la_OBJECTS = libcdo_la-cdo_pthread.lo libcdo_la-cdo_vlist.lo \
libcdo_la-merge_sort2.lo libcdo_la-modules.lo \
libcdo_la-namelist.lo libcdo_la-normal.lo \
libcdo_la-nth_element.lo libcdo_la-par_io.lo \
libcdo_la-percentiles_hist.lo libcdo_la-pipe.lo \
libcdo_la-process.lo libcdo_la-pstream.lo \
libcdo_la-percentiles_hist.lo libcdo_la-percentiles.lo \
libcdo_la-pipe.lo libcdo_la-process.lo libcdo_la-pstream.lo \
libcdo_la-pthread_debug.lo libcdo_la-readline.lo \
libcdo_la-realtime.lo libcdo_la-remaplib.lo \
libcdo_la-remapsort.lo libcdo_la-remap_scrip_io.lo \
......@@ -574,24 +574,25 @@ libcdo_la_SOURCES = cdo_int.h compare.h cdo_pthread.c cdo_vlist.c \
merge_sort2.c merge_sort2.h modules.c modules.h namelist.c \
namelist.h normal.c nth_element.c nth_element.h \
operator_help.h par_io.c par_io.h percentiles_hist.c \
percentiles_hist.h pipe.c pipe.h pragma_omp_atomic_update.h \
printinfo.h process.c process.h pstream.c pstream.h \
pstream_write.h pstream_int.h pthread_debug.c pthread_debug.h \
readline.c realtime.c remap.h remaplib.c remapsort.c \
remap_scrip_io.c remap_search_reg2d.c remap_search_latbins.c \
remap_store_link.c remap_store_link.h remap_store_link_cnsrv.c \
remap_store_link_cnsrv.h remap_conserv.c remap_conserv_scrip.c \
remap_distwgt.c remap_bicubic_scrip.c remap_bilinear_scrip.c \
stdnametable.c stdnametable.h specspace.c specspace.h \
statistic.c statistic.h table.c text.c text.h timebase.h \
timer.c userlog.c util.c util.h zaxis.c kdtreelib/kdtree.h \
kdtreelib/kdtree_cartesian.c kdtreelib/kdtree_common.c \
kdtreelib/kdtree_spherical.c kdtreelib/pmergesort.c \
kdtreelib/pqueue.c kdtreelib/pqueue.h clipping/clipping.c \
clipping/clipping.h clipping/area.c clipping/area.h \
clipping/ensure_array_size.c clipping/ensure_array_size.h \
clipping/geometry.h clipping/grid.h clipping/points.h \
clipping/dep_list.h clipping/grid_cell.c clipping/grid_cell.h \
percentiles_hist.h percentiles.c percentiles.h pipe.c pipe.h \
pragma_omp_atomic_update.h printinfo.h process.c process.h \
pstream.c pstream.h pstream_write.h pstream_int.h \
pthread_debug.c pthread_debug.h readline.c realtime.c remap.h \
remaplib.c remapsort.c remap_scrip_io.c remap_search_reg2d.c \
remap_search_latbins.c remap_store_link.c remap_store_link.h \
remap_store_link_cnsrv.c remap_store_link_cnsrv.h \
remap_conserv.c remap_conserv_scrip.c remap_distwgt.c \
remap_bicubic_scrip.c remap_bilinear_scrip.c stdnametable.c \
stdnametable.h specspace.c specspace.h statistic.c statistic.h \
table.c text.c text.h timebase.h timer.c userlog.c util.c \
util.h zaxis.c kdtreelib/kdtree.h kdtreelib/kdtree_cartesian.c \
kdtreelib/kdtree_common.c kdtreelib/kdtree_spherical.c \
kdtreelib/pmergesort.c kdtreelib/pqueue.c kdtreelib/pqueue.h \
clipping/clipping.c clipping/clipping.h clipping/area.c \
clipping/area.h clipping/ensure_array_size.c \
clipping/ensure_array_size.h clipping/geometry.h \
clipping/grid.h clipping/points.h clipping/dep_list.h \
clipping/grid_cell.c clipping/grid_cell.h \
clipping/intersection.c clipping/utils.c clipping/utils.h
#
cdo_SOURCES = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
......@@ -1064,6 +1065,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-normal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-nth_element.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-par_io.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-percentiles.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-percentiles_hist.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-pipe.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcdo_la-process.Plo@am__quote@
......@@ -1499,6 +1501,13 @@ libcdo_la-percentiles_hist.lo: percentiles_hist.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-percentiles_hist.lo `test -f 'percentiles_hist.c' || echo '$(srcdir)/'`percentiles_hist.c
libcdo_la-percentiles.lo: percentiles.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-percentiles.lo -MD -MP -MF $(DEPDIR)/libcdo_la-percentiles.Tpo -c -o libcdo_la-percentiles.lo `test -f 'percentiles.c' || echo '$(srcdir)/'`percentiles.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-percentiles.Tpo $(DEPDIR)/libcdo_la-percentiles.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='percentiles.c' object='libcdo_la-percentiles.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-percentiles.lo `test -f 'percentiles.c' || echo '$(srcdir)/'`percentiles.c
libcdo_la-pipe.lo: pipe.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-pipe.lo -MD -MP -MF $(DEPDIR)/libcdo_la-pipe.Tpo -c -o libcdo_la-pipe.lo `test -f 'pipe.c' || echo '$(srcdir)/'`pipe.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-pipe.Tpo $(DEPDIR)/libcdo_la-pipe.Plo
......
#include <math.h>
#include "percentiles.h"
#include "nth_element.h"
double percentile(double *array, unsigned len, double p)
{
double percentil;
percentil = nth_element(array, len, (int)ceil(len*(p/100.0))-1);
return percentil;
}
#ifndef _PERCENTILES_H
#define _PERCENTILES_H
double percentile(double *array, unsigned len, double p);
#endif /* _PERCENTILES_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment