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
3aecce5e
Commit
3aecce5e
authored
2 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Patches
Plain Diff
ADD: begin linked list; TODO: struct cluster, struct point(vector,cluster)
parent
d5d3eccc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/linkedlist.c
+36
-0
36 additions, 0 deletions
src/linkedlist.c
src/linkedlist.h
+29
-0
29 additions, 0 deletions
src/linkedlist.h
src/main.c
+20
-3
20 additions, 3 deletions
src/main.c
with
85 additions
and
3 deletions
src/linkedlist.c
0 → 100644
+
36
−
0
View file @
3aecce5e
//
// by Boris Stefanovic on 31/05/22
//
#include
"linkedlist.h"
ll_vint_node_t
*
ll_vint_create_node
(
const
vector_int_t
*
vec
)
{
ll_vint_node_t
*
node
=
malloc
(
sizeof
(
ll_vint_node_t
));
if
(
NULL
==
node
)
return
NULL
;
node
->
data
=
vec
;
node
->
next
=
NULL
;
}
ll_vint_t
*
ll_vint_create
()
{
ll_vint_t
*
ll
=
NULL
;
ll
=
malloc
(
sizeof
(
ll_vint_t
));
if
(
NULL
==
ll
)
return
NULL
;
ll
->
head
=
NULL
;
ll
->
tail
=
NULL
;
return
ll
;
}
void
ll_vint_append
(
ll_vint_t
*
list
,
const
vector_int_t
*
vector
)
{
if
(
NULL
==
vector
)
return
;
ll_vint_node_t
*
node
=
ll_vint_create_node
(
vector
);
if
(
NULL
==
list
->
head
)
{
list
->
head
=
node
;
list
->
tail
=
list
->
head
;
list
->
head
->
next
=
NULL
;
}
else
{
// TODO
}
}
This diff is collapsed.
Click to expand it.
src/linkedlist.h
0 → 100644
+
29
−
0
View file @
3aecce5e
//
// by Boris Stefanovic on 31/05/22
//
#ifndef PROG_KMEANS_LINKEDLIST_H
#define PROG_KMEANS_LINKEDLIST_H
#include
"vector.h"
typedef
struct
ll_vector_int_node
{
const
vector_int_t
*
data
;
struct
ll_vector_int_node
*
next
;
}
ll_vint_node_t
;
typedef
struct
ll_vector_int
{
ll_vint_node_t
*
head
;
ll_vint_node_t
*
tail
;
size_t
size
;
}
ll_vint_t
;
ll_vint_node_t
*
ll_vint_create_node
(
const
vector_int_t
*
vec
);
ll_vint_t
*
ll_vint_create
();
void
ll_vint_append
(
ll_vint_t
*
list
,
const
vector_int_t
*
vector
);
#endif //PROG_KMEANS_LINKEDLIST_H
This diff is collapsed.
Click to expand it.
src/main.c
+
20
−
3
View file @
3aecce5e
...
...
@@ -6,6 +6,7 @@
#include
<string.h>
#include
<unistd.h>
#include
"common.h"
#include
"linkedlist.h"
#include
"vector.h"
void
help
(
const
char
*
callname
)
{
...
...
@@ -50,6 +51,20 @@ vector_int_t* line_to_vector_int(char* line, const size_t dim) {
}
ll_vint_t
*
get_vector_list
(
FILE
*
ifile
,
const
size_t
dim
)
{
ll_vint_t
*
list
=
ll_vint_create
();
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
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<=
1
)
help
(
argv
[
0
]);
char
*
ipath
=
NULL
;
...
...
@@ -77,9 +92,11 @@ int main(int argc, char** argv) {
char
*
line
=
NULL
;
size_t
len
=
0
;
while
(
getline
(
&
line
,
&
len
,
ifile
)
!=
-
1
)
{
vector_int_t
*
vector
=
line_to_vector_int
(
line
,
dim
);
//TODO
free
(
line
);
if
(
len
!=
0
)
{
vector_int_t
*
vector
=
line_to_vector_int
(
line
,
dim
);
//TODO
free
(
line
);
}
}
// WRITE
FILE
*
ofile
=
opath
!=
NULL
?
fopen
(
opath
,
"w"
)
:
stdout
;
...
...
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