Commit 6fcdaa4b authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'pranay_36/purr-data-pd-l2ork_double_secondary'

parents 4ff50d41 310cf1fc
...@@ -11,42 +11,29 @@ inputs to int and their outputs back to float. */ ...@@ -11,42 +11,29 @@ inputs to int and their outputs back to float. */
#include "m_pd.h" #include "m_pd.h"
#include <math.h> #include <math.h>
#if !defined(HAVE_SINF) #if PD_FLOATSIZE == 32
#define sinf sin #define POW powf
#endif #define SIN sinf
#define COS cosf
#if !defined(HAVE_COSF) #define ATAN atanf
#define cosf cos #define ATAN2 atan2f
#endif #define SQRT sqrtf
#define LOG logf
#if !defined(HAVE_ATANF) #define EXP expf
#define atanf atan #define FABS fabsf
#endif #define MAXLOG 87.3365
#elif PD_FLOATSIZE == 64
#if !defined(HAVE_ATAN2F) #define POW pow
#define atan2f atan2 #define SIN sin
#endif #define COS cos
#define ATAN atan
#if !defined(HAVE_SQRTF) #define ATAN2 atan2
#define sqrtf sqrt #define SQRT sqrt
#endif #define LOG log
#define EXP exp
#if !defined(HAVE_LOGF) #define FABS fabs
#define logf log #define MAXLOG 87.3365
#endif
#if !defined(HAVE_EXPF)
#define expf exp
#endif
#if !defined(HAVE_FABSF)
#define fabsf fabs
#endif
#if !defined(HAVE_POWF)
#define powf pow
#endif #endif
typedef struct _binop typedef struct _binop
{ {
t_object x_obj; t_object x_obj;
...@@ -158,10 +145,10 @@ static void binop1_pow_bang(t_binop *x) ...@@ -158,10 +145,10 @@ static void binop1_pow_bang(t_binop *x)
{ {
if (x->x_f1 >= 0) if (x->x_f1 >= 0)
outlet_float(x->x_obj.ob_outlet, outlet_float(x->x_obj.ob_outlet,
powf(x->x_f1, x->x_f2)); POW(x->x_f1, x->x_f2));
else if (x->x_f2 <= -1 || x->x_f2 >= 1 || x->x_f2 == 0) else if (x->x_f2 <= -1 || x->x_f2 >= 1 || x->x_f2 == 0)
outlet_float(x->x_obj.ob_outlet, outlet_float(x->x_obj.ob_outlet,
powf(x->x_f1, x->x_f2)); POW(x->x_f1, x->x_f2));
else else
{ {
pd_error(x, "pow: calculation resulted in a NaN"); pd_error(x, "pow: calculation resulted in a NaN");
...@@ -174,10 +161,10 @@ static void binop1_pow_float(t_binop *x, t_float f) ...@@ -174,10 +161,10 @@ static void binop1_pow_float(t_binop *x, t_float f)
x->x_f1 = f; x->x_f1 = f;
if (x->x_f1 >= 0) if (x->x_f1 >= 0)
outlet_float(x->x_obj.ob_outlet, outlet_float(x->x_obj.ob_outlet,
powf(x->x_f1, x->x_f2)); POW(x->x_f1, x->x_f2));
else if (x->x_f2 <= -1 || x->x_f2 >= 1 || x->x_f2 == 0) else if (x->x_f2 <= -1 || x->x_f2 >= 1 || x->x_f2 == 0)
outlet_float(x->x_obj.ob_outlet, outlet_float(x->x_obj.ob_outlet,
powf(x->x_f1, x->x_f2)); POW(x->x_f1, x->x_f2));
else { else {
pd_error(x, "pow: calculation resulted in a NaN"); pd_error(x, "pow: calculation resulted in a NaN");
outlet_float(x->x_obj.ob_outlet, 0); outlet_float(x->x_obj.ob_outlet, 0);
...@@ -564,7 +551,7 @@ static void *sin_new(void) ...@@ -564,7 +551,7 @@ static void *sin_new(void)
static void sin_float(t_object *x, t_float f) static void sin_float(t_object *x, t_float f)
{ {
outlet_float(x->ob_outlet, sinf(f)); outlet_float(x->ob_outlet, SIN(f));
} }
static t_class *cos_class; /* ----------- cos --------------- */ static t_class *cos_class; /* ----------- cos --------------- */
...@@ -578,7 +565,7 @@ static void *cos_new(void) ...@@ -578,7 +565,7 @@ static void *cos_new(void)
static void cos_float(t_object *x, t_float f) static void cos_float(t_object *x, t_float f)
{ {
outlet_float(x->ob_outlet, cosf(f)); outlet_float(x->ob_outlet, COS(f));
} }
static t_class *tan_class; /* ----------- tan --------------- */ static t_class *tan_class; /* ----------- tan --------------- */
...@@ -592,8 +579,8 @@ static void *tan_new(void) ...@@ -592,8 +579,8 @@ static void *tan_new(void)
static void tan_float(t_object *x, t_float f) static void tan_float(t_object *x, t_float f)
{ {
t_float c = cosf(f); t_float c = COS(f);
t_float t = (c == 0 ? 0 : sinf(f)/c); t_float t = (c == 0 ? 0 : SIN(f)/c);
outlet_float(x->ob_outlet, t); outlet_float(x->ob_outlet, t);
} }
...@@ -608,7 +595,7 @@ static void *atan_new(void) ...@@ -608,7 +595,7 @@ static void *atan_new(void)
static void atan_float(t_object *x, t_float f) static void atan_float(t_object *x, t_float f)
{ {
outlet_float(x->ob_outlet, atanf(f)); outlet_float(x->ob_outlet, ATAN(f));
} }
static t_class *atan2_class; /* ----------- atan2 --------------- */ static t_class *atan2_class; /* ----------- atan2 --------------- */
...@@ -630,7 +617,7 @@ static void *atan2_new(void) ...@@ -630,7 +617,7 @@ static void *atan2_new(void)
static void atan2_float(t_atan2 *x, t_float f) static void atan2_float(t_atan2 *x, t_float f)
{ {
t_float r = (f == 0 && x->x_f == 0 ? 0 : atan2f(f, x->x_f)); t_float r = (f == 0 && x->x_f == 0 ? 0 : ATAN2(f, x->x_f));
outlet_float(x->x_ob.ob_outlet, r); outlet_float(x->x_ob.ob_outlet, r);
} }
...@@ -645,7 +632,7 @@ static void *sqrt_new(void) ...@@ -645,7 +632,7 @@ static void *sqrt_new(void)
static void sqrt_float(t_object *x, t_float f) static void sqrt_float(t_object *x, t_float f)
{ {
t_float r = (f > 0 ? sqrtf(f) : 0); t_float r = (f > 0 ? SQRT(f) : 0);
outlet_float(x->ob_outlet, r); outlet_float(x->ob_outlet, r);
} }
...@@ -660,7 +647,7 @@ static void *log_new(void) ...@@ -660,7 +647,7 @@ static void *log_new(void)
static void log_float(t_object *x, t_float f) static void log_float(t_object *x, t_float f)
{ {
t_float r = (f > 0 ? logf(f) : -1000); t_float r = (f > 0 ? LOG(f) : -1000);
outlet_float(x->ob_outlet, r); outlet_float(x->ob_outlet, r);
} }
...@@ -678,7 +665,7 @@ static void exp_float(t_object *x, t_float f) ...@@ -678,7 +665,7 @@ static void exp_float(t_object *x, t_float f)
{ {
t_float g; t_float g;
if (f > MAXLOG) f = MAXLOG; if (f > MAXLOG) f = MAXLOG;
g = expf(f); g = EXP(f);
outlet_float(x->ob_outlet, g); outlet_float(x->ob_outlet, g);
} }
...@@ -693,7 +680,7 @@ static void *abs_new(void) ...@@ -693,7 +680,7 @@ static void *abs_new(void)
static void abs_float(t_object *x, t_float f) static void abs_float(t_object *x, t_float f)
{ {
outlet_float(x->ob_outlet, fabsf(f)); outlet_float(x->ob_outlet, FABS(f));
} }
static t_class *wrap_class; /* ----------- wrap --------------- */ static t_class *wrap_class; /* ----------- wrap --------------- */
......
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