Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Prateek Mishra
purr-data
Commits
9a2fdfc7
Commit
9a2fdfc7
authored
6 years ago
by
Pranay Gupta
Browse files
Options
Downloads
Patches
Plain Diff
double precision patches for choice_class
parent
9eb33fae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pd/extra/choice/choice.c
+8
-8
8 additions, 8 deletions
pd/extra/choice/choice.c
with
8 additions
and
8 deletions
pd/extra/choice/choice.c
+
8
−
8
View file @
9a2fdfc7
...
@@ -17,7 +17,7 @@ static t_class *choice_class;
...
@@ -17,7 +17,7 @@ static t_class *choice_class;
typedef
struct
_elem
typedef
struct
_elem
{
{
float
e_age
;
t_
float
e_age
;
t_float
e_weight
[
DIMENSION
];
t_float
e_weight
[
DIMENSION
];
}
t_elem
;
}
t_elem
;
...
@@ -63,7 +63,7 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)
...
@@ -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
;
int
oldn
=
x
->
x_n
,
newn
=
oldn
+
1
,
i
;
t_elem
*
e
;
t_elem
*
e
;
float
sum
,
normal
;
t_
float
sum
,
normal
;
x
->
x_vec
=
(
t_elem
*
)
resizebytes
(
x
->
x_vec
,
oldn
*
sizeof
(
t_elem
),
x
->
x_vec
=
(
t_elem
*
)
resizebytes
(
x
->
x_vec
,
oldn
*
sizeof
(
t_elem
),
newn
*
sizeof
(
t_elem
));
newn
*
sizeof
(
t_elem
));
x
->
x_n
=
newn
;
x
->
x_n
=
newn
;
...
@@ -72,11 +72,11 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)
...
@@ -72,11 +72,11 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)
for
(
i
=
0
,
sum
=
0
;
i
<
DIMENSION
;
i
++
)
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
;
e
->
e_weight
[
i
]
=
f
;
sum
+=
f
*
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
++
)
for
(
i
=
0
;
i
<
DIMENSION
;
i
++
)
e
->
e_weight
[
i
]
*=
normal
;
e
->
e_weight
[
i
]
*=
normal
;
}
}
...
@@ -84,7 +84,7 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)
...
@@ -84,7 +84,7 @@ static void choice_add(t_choice *x, t_symbol *s, int argc, t_atom *argv)
static
void
choice_list
(
t_choice
*
x
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
static
void
choice_list
(
t_choice
*
x
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
{
int
i
,
j
;
int
i
,
j
;
float
bestsum
=
0
;
t_
float
bestsum
=
0
;
int
bestindex
=
-
1
;
int
bestindex
=
-
1
;
t_float
invec
[
DIMENSION
];
t_float
invec
[
DIMENSION
];
for
(
i
=
0
;
i
<
DIMENSION
;
i
++
)
for
(
i
=
0
;
i
<
DIMENSION
;
i
++
)
...
@@ -92,10 +92,10 @@ static void choice_list(t_choice *x, t_symbol *s, int argc, t_atom *argv)
...
@@ -92,10 +92,10 @@ static void choice_list(t_choice *x, t_symbol *s, int argc, t_atom *argv)
for
(
j
=
0
;
j
<
x
->
x_n
;
j
++
)
for
(
j
=
0
;
j
<
x
->
x_n
;
j
++
)
{
{
t_elem
*
e
=
x
->
x_vec
+
j
;
t_elem
*
e
=
x
->
x_vec
+
j
;
float
sum
;
t_
float
sum
;
for
(
i
=
0
,
sum
=
0
;
i
<
DIMENSION
;
i
++
)
for
(
i
=
0
,
sum
=
0
;
i
<
DIMENSION
;
i
++
)
sum
+=
e
->
e_weight
[
i
]
*
invec
[
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
)
if
(
sum
>
bestsum
)
{
{
bestsum
=
sum
;
bestsum
=
sum
;
...
@@ -109,7 +109,7 @@ static void choice_list(t_choice *x, t_symbol *s, int argc, t_atom *argv)
...
@@ -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
[
j
].
e_age
+=
1
.;
x
->
x_vec
[
bestindex
].
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
)
static
void
choice_free
(
t_choice
*
x
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment