Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmda3634_materials
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
srigavili
cmda3634_materials
Commits
17c6d2c7
Commit
17c6d2c7
authored
11 months ago
by
Jason R Wilson
Browse files
Options
Downloads
Patches
Plain Diff
files for PSA02
parent
357ad0f4
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PSA02/omp_kmeans.c
+5
-5
5 additions, 5 deletions
PSA02/omp_kmeans.c
with
5 additions
and
5 deletions
PSA02/omp_kmeans.c
+
5
−
5
View file @
17c6d2c7
...
...
@@ -40,21 +40,21 @@ int find_cluster (double kmeans[], double point[], int k, int dim) {
/* calculate the next kmeans */
void
calc_kmeans_next
(
double
data
[],
int
num_points
,
int
dim
,
double
kmeans
[],
double
kmeans_next
[],
int
k
)
{
int
num_points
[
k
];
int
cluster_size
[
k
];
for
(
int
i
=
0
;
i
<
k
;
i
++
)
{
num_points
[
i
]
=
0
;
cluster_size
[
i
]
=
0
;
}
vec_zero
(
kmeans_next
,
k
*
dim
);
for
(
int
i
=
0
;
i
<
num_points
;
i
++
)
{
int
cluster
=
find_cluster
(
kmeans
,
data
+
i
*
dim
,
k
,
dim
);
double
*
kmean
=
kmeans_next
+
cluster
*
dim
;
vec_add
(
kmean
,
data
+
i
*
dim
,
kmean
,
dim
);
num_points
[
cluster
]
+=
1
;
cluster_size
[
cluster
]
+=
1
;
}
for
(
int
i
=
0
;
i
<
k
;
i
++
)
{
double
*
kmean
=
kmeans_next
+
i
*
dim
;
if
(
num_points
[
i
]
>
0
)
{
vec_scalar_mult
(
kmean
,
1
.
0
/
num_points
[
i
],
kmean
,
dim
);
if
(
cluster_size
[
i
]
>
0
)
{
vec_scalar_mult
(
kmean
,
1
.
0
/
cluster_size
[
i
],
kmean
,
dim
);
}
else
{
printf
(
"error : cluster has no points!
\n
"
);
exit
(
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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