Skip to content

Commit

Permalink
katja's double precision patches
Browse files Browse the repository at this point in the history
  • Loading branch information
eighthave committed Oct 3, 2011
1 parent c7fb8e4 commit 982ad1a
Show file tree
Hide file tree
Showing 26 changed files with 1,042 additions and 1,034 deletions.
155 changes: 78 additions & 77 deletions extra/bonk~/bonk~.c

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions extra/choice/choice.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static t_class *choice_class;

typedef struct _elem
{
float e_age;
t_float e_age;
t_float e_weight[DIMENSION];
} t_elem;

Expand Down Expand Up @@ -63,7 +63,7 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)
{
int oldn = x->x_n, newn = oldn + 1, i;
t_elem *e;
float sum, normal;
t_float sum, normal;
x->x_vec = (t_elem *)resizebytes(x->x_vec, oldn * sizeof(t_elem),
newn * sizeof(t_elem));
x->x_n = newn;
Expand All @@ -72,30 +72,30 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)

for (i = 0, sum = 0; i < DIMENSION; i++)
{
float f = atom_getfloatarg(i, argc, argv);
t_float f = atom_getfloatarg(i, argc, argv);
e->e_weight[i] = f;
sum += f*f;
}
normal = (float)(sum > 0 ? 1./sqrt(sum) : 1);
normal = (t_float)(sum > 0 ? 1./sqrt(sum) : 1);
for (i = 0; i < DIMENSION; i++)
e->e_weight[i] *= normal;
}

static void choice_list(t_choice *x, t_symbol *s, int argc, t_atom *argv)
{
int i, j;
float bestsum = 0;
t_float bestsum = 0;
int bestindex = -1;
t_float invec[DIMENSION];
for (i = 0; i < DIMENSION; i++)
invec[i] = atom_getfloatarg(i, argc, argv);
for (j = 0; j < x->x_n; j++)
{
t_elem *e = x->x_vec + j;
float sum;
t_float sum;
for (i = 0, sum = 0; i < DIMENSION; i++)
sum += e->e_weight[i] * invec[i];
if (x->x_nonrepeat) sum *= (float)(log(e->e_age));
if (x->x_nonrepeat) sum *= (t_float)(log(e->e_age));
if (sum > bestsum)
{
bestsum = sum;
Expand All @@ -109,7 +109,7 @@ static void choice_list(t_choice *x, t_symbol *s, int argc, t_atom *argv)
x->x_vec[j].e_age += 1.;
x->x_vec[bestindex].e_age = 1;
}
outlet_float(x->x_obj.ob_outlet, (float)bestindex);
outlet_float(x->x_obj.ob_outlet, (t_float)bestindex);
}

static void choice_free(t_choice *x)
Expand Down
34 changes: 17 additions & 17 deletions extra/expr~/vexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ struct ex_ex *eval_store(struct expr *expr, struct ex_ex *eptr,
struct ex_ex *eval_sigidx(struct expr *expr, struct ex_ex *eptr,
struct ex_ex *optr, int i);
static int cal_sigidx(struct ex_ex *optr, /* The output value */
int i, float rem_i, /* integer and fractinal part of index */
int i, t_float rem_i, /* integer and fractinal part of index */
int idx, /* index of current fexpr~ processing */
int vsize, /* vector size */
float *curvec, float *prevec); /* current and previous table */
t_float *curvec, t_float *prevec); /* current and previous table */
t_ex_func *find_func(char *s);
void ex_dzdetect(struct expr *expr);

Expand Down Expand Up @@ -691,7 +691,7 @@ case ET_INT: \
case ET_INT: \
if (optr->ex_type == ET_VEC) { \
op = optr->ex_vec; \
scalar = (float)DZC(left.ex_int, OPR, right.ex_int); \
scalar = (t_float)DZC(left.ex_int, OPR, right.ex_int); \
for (j = 0; j < expr->exp_vsize; j++) \
*op++ = scalar; \
} else { \
Expand All @@ -702,12 +702,12 @@ case ET_INT: \
case ET_FLT: \
if (optr->ex_type == ET_VEC) { \
op = optr->ex_vec; \
scalar = DZC(((float)left.ex_int), OPR, right.ex_flt);\
scalar = DZC(((t_float)left.ex_int), OPR, right.ex_flt);\
for (j = 0; j < expr->exp_vsize; j++) \
*op++ = scalar; \
} else { \
optr->ex_type = ET_FLT; \
optr->ex_flt = DZC(((float)left.ex_int), OPR, \
optr->ex_flt = DZC(((t_float)left.ex_int), OPR, \
right.ex_flt); \
} \
break; \
Expand Down Expand Up @@ -743,7 +743,7 @@ case ET_FLT: \
case ET_INT: \
if (optr->ex_type == ET_VEC) { \
op = optr->ex_vec; \
scalar = DZC((float) left.ex_flt, OPR, right.ex_int); \
scalar = DZC((t_float) left.ex_flt, OPR, right.ex_int); \
for (j = 0; j < expr->exp_vsize; j++) \
*op++ = scalar; \
} else { \
Expand Down Expand Up @@ -854,7 +854,7 @@ break;
switch(left.ex_type) { \
case ET_INT: \
if (optr->ex_type == ET_VEC) { \
ex_mkvector(optr->ex_vec,(float)(OPR left.ex_int),\
ex_mkvector(optr->ex_vec,(t_float)(OPR left.ex_int),\
expr->exp_vsize);\
break; \
} \
Expand Down Expand Up @@ -960,7 +960,7 @@ ex_eval(struct expr *expr, struct ex_ex *eptr, struct ex_ex *optr, int idx)
switch (eptr->ex_type) {
case ET_INT:
if (optr->ex_type == ET_VEC)
ex_mkvector(optr->ex_vec, (float) eptr->ex_int,
ex_mkvector(optr->ex_vec, (t_float) eptr->ex_int,
expr->exp_vsize);
else
*optr = *eptr;
Expand Down Expand Up @@ -1407,19 +1407,19 @@ eval_sigidx(struct expr *expr, struct ex_ex *eptr, struct ex_ex *optr, int idx)
struct ex_ex arg;
struct ex_ex *reteptr;
int i = 0, j = 0;
float fi = 0, /* index in float */
rem_i = 0; /* remains of the float */
t_float fi = 0, /* index in t_float */
rem_i = 0; /* remains of the t_float */
char *tbl;

arg.ex_type = 0;
arg.ex_int = 0;
reteptr = ex_eval(expr, eptr + 1, &arg, idx);
if (arg.ex_type == ET_FLT) {
fi = arg.ex_flt; /* float index */
fi = arg.ex_flt; /* t_float index */
i = (int) arg.ex_flt; /* integer index */
rem_i = arg.ex_flt - i; /* remains of integer */
} else if (arg.ex_type == ET_INT) {
fi = arg.ex_int; /* float index */
fi = arg.ex_int; /* t_float index */
i = arg.ex_int;
rem_i = 0;
} else {
Expand Down Expand Up @@ -1504,10 +1504,10 @@ eval_sigidx(struct expr *expr, struct ex_ex *eptr, struct ex_ex *optr, int idx)
*/
static int
cal_sigidx(struct ex_ex *optr, /* The output value */
int i, float rem_i, /* integer and fractinal part of index */
int i, t_float rem_i, /* integer and fractinal part of index */
int idx, /* index of current fexpr~ processing */
int vsize, /* vector size */
float *curvec, float *prevec) /* current and previous table */
t_float *curvec, t_float *prevec) /* current and previous table */
{
int n;

Expand Down Expand Up @@ -1873,8 +1873,8 @@ atoif(char *s, long int *value, long int *type)
char *p;
long int_val = 0;
int flt = 0;
float pos = 0;
float flt_val = 0;
t_float pos = 0;
t_float flt_val = 0;
int base = 10;

p = s;
Expand Down Expand Up @@ -1940,7 +1940,7 @@ atoif(char *s, long int *value, long int *type)
default:
if (flt) {
*type = ET_FLT;
*((float *) value) = flt_val;
*((t_float *) value) = flt_val;
} else {
*type = ET_INT;
*value = int_val;
Expand Down
5 changes: 3 additions & 2 deletions extra/expr~/vexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#else /* MSP */
#include "ext.h"
#include "z_dsp.h"
typedef float t_float; // t_float is from m_pd.h
#endif

#include "fts_to_pd.h"
Expand Down Expand Up @@ -107,7 +108,7 @@ struct ex_ex;
struct ex_ex {
union {
long v_int;
float v_flt;
t_float v_flt;
t_float *v_vec; /* this is an for allocated vector */
long op;
char *ptr;
Expand Down Expand Up @@ -209,7 +210,7 @@ typedef struct expr {
t_float *exp_tmpres[MAX_VARS]; /* temporty result for fexpr~ */
int exp_vsize; /* the size of the signal vector */
int exp_nivec; /* # of vector inlets */
float exp_f; /* control value to be transformed to signal */
t_float exp_f; /* control value to be transformed to signal */
} t_expr;

typedef struct ex_funcs {
Expand Down
Loading

0 comments on commit 982ad1a

Please sign in to comment.