[PD-cvs] pd/extra/choice choice.c,1.1.1.1,1.2
Miller Puckette
millerpuckette at users.sourceforge.net
Sat Nov 6 17:07:24 CET 2004
Update of /cvsroot/pure-data/pd/extra/choice
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10939/pd/extra/choice
Modified Files:
choice.c
Log Message:
0.38 test 9 (mostly bug fixes)
Index: choice.c
===================================================================
RCS file: /cvsroot/pure-data/pd/extra/choice/choice.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** choice.c 29 Jul 2002 17:06:16 -0000 1.1.1.1
--- choice.c 6 Nov 2004 16:07:22 -0000 1.2
***************
*** 51,60 ****
for (j = 0; j < x->x_n; j++)
{
! t_elem *e = x->x_vec + j;
! t_float *w = e->e_weight;
! post("%2d age %2d \
w %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f",
! j, (int)(e->e_age), w[0], w[1], w[2], w[3], w[4], w[5],
! w[6], w[7], w[8], w[9]);
}
}
--- 51,60 ----
for (j = 0; j < x->x_n; j++)
{
! t_elem *e = x->x_vec + j;
! t_float *w = e->e_weight;
! post("%2d age %2d \
w %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f",
! j, (int)(e->e_age), w[0], w[1], w[2], w[3], w[4], w[5],
! w[6], w[7], w[8], w[9]);
}
}
***************
*** 66,70 ****
float sum, normal;
x->x_vec = (t_elem *)resizebytes(x->x_vec, oldn * sizeof(t_elem),
! newn * sizeof(t_elem));
x->x_n = newn;
e = x->x_vec + oldn;
--- 66,70 ----
float sum, normal;
x->x_vec = (t_elem *)resizebytes(x->x_vec, oldn * sizeof(t_elem),
! newn * sizeof(t_elem));
x->x_n = newn;
e = x->x_vec + oldn;
***************
*** 73,83 ****
for (i = 0, sum = 0; i < DIMENSION; i++)
{
! float f = atom_getfloatarg(i, argc, argv);
! e->e_weight[i] = f;
! sum += f*f;
}
normal = (float)(sum > 0 ? 1./sqrt(sum) : 1);
for (i = 0; i < DIMENSION; i++)
! e->e_weight[i] *= normal;
}
--- 73,83 ----
for (i = 0, sum = 0; i < DIMENSION; i++)
{
! float f = atom_getfloatarg(i, argc, argv);
! e->e_weight[i] = f;
! sum += f*f;
}
normal = (float)(sum > 0 ? 1./sqrt(sum) : 1);
for (i = 0; i < DIMENSION; i++)
! e->e_weight[i] *= normal;
}
***************
*** 89,112 ****
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;
! 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 (sum > bestsum)
! {
! bestsum = sum;
! sum = 1;
! bestindex = j;
! }
}
if (bestindex >= 0)
{
! for (j = 0; j < x->x_n; j++)
! x->x_vec[j].e_age += 1.;
! x->x_vec[bestindex].e_age = 1;
}
outlet_float(x->x_obj.ob_outlet, (float)bestindex);
--- 89,112 ----
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;
! 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 (sum > bestsum)
! {
! bestsum = sum;
! sum = 1;
! bestindex = j;
! }
}
if (bestindex >= 0)
{
! for (j = 0; j < x->x_n; j++)
! x->x_vec[j].e_age += 1.;
! x->x_vec[bestindex].e_age = 1;
}
outlet_float(x->x_obj.ob_outlet, (float)bestindex);
***************
*** 121,125 ****
{
choice_class = class_new(gensym("choice"), (t_newmethod)choice_new,
! (t_method)choice_free, sizeof(t_choice), 0, A_DEFFLOAT, 0);
class_addmethod(choice_class, (t_method)choice_add, gensym("add"), A_GIMME, 0);
class_addmethod(choice_class, (t_method)choice_clear, gensym("clear"), 0);
--- 121,125 ----
{
choice_class = class_new(gensym("choice"), (t_newmethod)choice_new,
! (t_method)choice_free, sizeof(t_choice), 0, A_DEFFLOAT, 0);
class_addmethod(choice_class, (t_method)choice_add, gensym("add"), A_GIMME, 0);
class_addmethod(choice_class, (t_method)choice_clear, gensym("clear"), 0);
More information about the Pd-cvs
mailing list