rs is gone
This commit is contained in:
parent
fe4d06be47
commit
e9802e5c00
4 changed files with 1 additions and 99 deletions
|
|
@ -144,7 +144,6 @@ printing/ft_putendl.c\
|
|||
printing/ft_putnbr.c\
|
||||
printing/ft_putstr.c\
|
||||
printing/hexdump.c\
|
||||
rs/rs.c\
|
||||
sstr/ft_sstradd.c\
|
||||
sstr/ft_sstrcat.c\
|
||||
sstr/ft_sstrdel.c\
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/07 18:07:31 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/11/20 12:41:50 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,7 +26,6 @@
|
|||
# include "error.h"
|
||||
# include "color.h"
|
||||
# include "cliopts.h"
|
||||
# include "rs.h"
|
||||
|
||||
# include "lst.h"
|
||||
# include "dlst.h"
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rs.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/07 18:05:30 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/07 18:18:16 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LIBFT_RS_H
|
||||
# define LIBFT_RS_H
|
||||
|
||||
# include <float.h>
|
||||
# include <dlfcn.h>
|
||||
# include <math.h>
|
||||
|
||||
extern struct s_stats {
|
||||
int count;
|
||||
double min;
|
||||
double max;
|
||||
double avg;
|
||||
double m;
|
||||
double stdev;
|
||||
double var;
|
||||
} g_rs;
|
||||
|
||||
void rs_clear();
|
||||
void rs_push(double n);
|
||||
void rs_calcmore();
|
||||
|
||||
#endif
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rs.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/10/07 17:57:54 by jhalford #+# #+# */
|
||||
/* Updated: 2017/10/07 18:19:47 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <math.h>
|
||||
|
||||
struct s_stats g_rs = {0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
double sqrt(double x);
|
||||
|
||||
void rs_clear(void)
|
||||
{
|
||||
g_rs.count = 0;
|
||||
g_rs.min = DBL_MAX;
|
||||
g_rs.max = -DBL_MAX;
|
||||
}
|
||||
|
||||
void rs_push(double n)
|
||||
{
|
||||
double delta;
|
||||
|
||||
g_rs.count++;
|
||||
n < g_rs.min ? g_rs.min = n : (0);
|
||||
n > g_rs.max ? g_rs.max = n : (0);
|
||||
if (g_rs.count == 1)
|
||||
{
|
||||
g_rs.avg = n;
|
||||
g_rs.m = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = n - g_rs.avg;
|
||||
g_rs.avg += delta / g_rs.count;
|
||||
g_rs.m += delta * (n - g_rs.avg);
|
||||
}
|
||||
}
|
||||
|
||||
void rs_calcmore(void)
|
||||
{
|
||||
if (g_rs.count == 0)
|
||||
{
|
||||
g_rs.min = 0;
|
||||
g_rs.max = 0;
|
||||
}
|
||||
if (g_rs.count < 2)
|
||||
{
|
||||
g_rs.var = 0;
|
||||
g_rs.stdev = 0;
|
||||
return ;
|
||||
}
|
||||
g_rs.var = g_rs.m / (g_rs.count - 1);
|
||||
g_rs.stdev = sqrt(g_rs.var);
|
||||
}
|
||||
Loading…
Reference in a new issue