Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prog_kmeans
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
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
boris.stefanov
prog_kmeans
Commits
21de63b2
Commit
21de63b2
authored
2 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Patches
Plain Diff
ADD: cluster
parent
3aecce5e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/cluster.c
+14
-0
14 additions, 0 deletions
src/cluster.c
src/cluster.h
+21
-0
21 additions, 0 deletions
src/cluster.h
src/kmeans.c
+6
-0
6 additions, 0 deletions
src/kmeans.c
src/kmeans.h
+12
-0
12 additions, 0 deletions
src/kmeans.h
src/main.c
+5
-10
5 additions, 10 deletions
src/main.c
with
58 additions
and
10 deletions
src/cluster.c
0 → 100644
+
14
−
0
View file @
21de63b2
//
// by Boris Stefanovic on 01/06/22
//
#include
"cluster.h"
#include
"vector.h"
cluster_point_int_t
*
cluster_point_int_create
(
vector_int_t
*
vector
)
{
cluster_point_int_t
*
elem
=
malloc
(
sizeof
(
cluster_point_int_t
));
if
(
NULL
==
elem
)
return
NULL
;
elem
->
vector
=
vector
;
elem
->
cluster
=
NULL
;
}
This diff is collapsed.
Click to expand it.
src/cluster.h
0 → 100644
+
21
−
0
View file @
21de63b2
//
// by Boris Stefanovic on 01/06/22
//
#ifndef PROG_KMEANS_CLUSTER_H
#define PROG_KMEANS_CLUSTER_H
#include
"vector.h"
typedef
vector_int_t
cluster_int_t
;
// a cluster may be represented by its center
typedef
struct
cluster_point_int
{
vector_int_t
*
vector
;
cluster_int_t
*
cluster
;
// justified by "many-to-one" relationship and several passes over all points
}
cluster_point_int_t
;
cluster_point_int_t
*
cluster_point_int_create
(
vector_int_t
*
vector
);
#endif //PROG_KMEANS_CLUSTER_H
This diff is collapsed.
Click to expand it.
src/kmeans.c
0 → 100644
+
6
−
0
View file @
21de63b2
//
// by Boris Stefanovic on 01/06/22
//
#include
"kmeans.h"
#include
"cluster.h"
This diff is collapsed.
Click to expand it.
src/kmeans.h
0 → 100644
+
12
−
0
View file @
21de63b2
//
// by Boris Stefanovic on 01/06/22
//
#ifndef PROG_KMEANS_KMEANS_H
#define PROG_KMEANS_KMEANS_H
//
#endif //PROG_KMEANS_KMEANS_H
This diff is collapsed.
Click to expand it.
src/main.c
+
5
−
10
View file @
21de63b2
...
...
@@ -58,10 +58,11 @@ ll_vint_t* get_vector_list(FILE* ifile, const size_t dim) {
while
(
getline
(
&
line
,
&
len
,
ifile
)
!=
-
1
)
{
if
(
len
!=
0
)
{
vector_int_t
*
vector
=
line_to_vector_int
(
line
,
dim
);
//TODO
ll_vint_append
(
list
,
vector
);
free
(
line
);
}
}
return
list
;
}
...
...
@@ -89,15 +90,9 @@ int main(int argc, char** argv) {
printf
(
"NUMBER OF CLUSTERS MUST BE STRICTLY POSITIVE !
\n
"
);
return
EXIT_FAILURE
;
}
char
*
line
=
NULL
;
size_t
len
=
0
;
while
(
getline
(
&
line
,
&
len
,
ifile
)
!=
-
1
)
{
if
(
len
!=
0
)
{
vector_int_t
*
vector
=
line_to_vector_int
(
line
,
dim
);
//TODO
free
(
line
);
}
}
ll_vint_t
*
list
=
get_vector_list
(
ifile
,
dim
);
// ALGORITHM
// TODO
// WRITE
FILE
*
ofile
=
opath
!=
NULL
?
fopen
(
opath
,
"w"
)
:
stdout
;
// TODO
...
...
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