Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
math_optimisation
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scott.birner
math_optimisation
Commits
b4722579
Commit
b4722579
authored
3 years ago
by
nicolas.rivier
Browse files
Options
Downloads
Patches
Plain Diff
regrouper groups
parent
6e02e917
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/C/equation.c
+22
-0
22 additions, 0 deletions
src/C/equation.c
src/C/equation.h
+1
-0
1 addition, 0 deletions
src/C/equation.h
src/C/main.c
+14
-0
14 additions, 0 deletions
src/C/main.c
with
37 additions
and
0 deletions
src/C/equation.c
+
22
−
0
View file @
b4722579
...
...
@@ -105,6 +105,28 @@ void create_group_random(group_t *group, point_t* points, int n_points, int n_gr
free
(
tmp
);
}
group_t
*
regroups
(
point_t
*
a
,
point_t
*
b
,
int
nbrPoint
)
{
group_t
*
group
;
group
->
n_points
=
nbrPoint
*
2
;
group
->
n_groups
=
1
;
group
->
points
=
malloc
(
sizeof
(
point_t
*
)
*
1
);
for
(
int
i
=
0
;
i
<
group
->
n_groups
;
i
++
)
{
group
->
points
[
i
]
=
malloc
(
sizeof
(
point_t
)
*
(
int
)(
nbrPoint
*
2
));
}
int
p
=
0
;
for
(
int
i
=
0
;
i
<
nbrPoint
;
i
++
)
{
group
->
points
[
0
][
p
++
]
=
a
[
i
];
}
for
(
int
i
=
0
;
i
<
nbrPoint
;
i
++
)
{
group
->
points
[
0
][
p
++
]
=
b
[
i
];
}
return
group
;
}
void
print_group
(
group_t
*
group
){
for
(
int
i
=
0
;
i
<
group
->
n_groups
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
src/C/equation.h
+
1
−
0
View file @
b4722579
...
...
@@ -49,6 +49,7 @@ double fd(vector_t x); // test
// Gestion des groupes
void
create_group
(
group_t
*
group
,
point_t
*
points
,
int
n_points
,
int
n_groups
);
void
create_group_random
(
group_t
*
group
,
point_t
*
points
,
int
n_points
,
int
n_groups
);
group_t
*
regroups
(
point_t
*
a
,
point_t
*
b
,
int
nbrPoint
);
void
print_group
(
group_t
*
group
);
void
destroy_group
(
group_t
*
group
);
...
...
This diff is collapsed.
Click to expand it.
src/C/main.c
+
14
−
0
View file @
b4722579
...
...
@@ -59,6 +59,20 @@ int main(int argc, char* argv[]) {
create_group_random
(
&
groups
,
points
,
nb_points
,
3
);
print_group
(
&
groups
);
group_t
*
g1_2
=
regroups
(
groups
.
points
[
0
],
groups
.
points
[
1
],
10
);
print_group
(
&
groups
);
group_t
*
g1_3
=
regroups
(
groups
.
points
[
0
],
groups
.
points
[
1
],
10
);
// Error depassement de memoir :(
group_t
*
g2_3
=
regroups
(
groups
.
points
[
1
],
groups
.
points
[
2
],
10
);
vector_t
g1_2AB
=
descente_radian
(
g1_2
->
points
[
0
],
g1_2
->
n_points
/
groups
.
n_groups
);
vector_t
g1_3AB
=
descente_radian
(
g1_3
->
points
[
0
],
g1_3
->
n_points
/
groups
.
n_groups
);
vector_t
g2_3AB
=
descente_radian
(
g2_3
->
points
[
0
],
g2_3
->
n_points
/
groups
.
n_groups
);
printf
(
"gradient(%f,%f)
\n
"
,
g1_2AB
.
x
,
g1_2AB
.
y
);
printf
(
"gradient(%f,%f)
\n
"
,
g1_3AB
.
x
,
g1_3AB
.
y
);
printf
(
"gradient(%f,%f)
\n
"
,
g2_3AB
.
x
,
g2_3AB
.
y
);
destroy_group
(
g1_2
);
destroy_group
(
g1_3
);
destroy_group
(
g2_3
);
vector_t
resAB
=
descente_radian
(
points
,
nb_points
);
point_t
*
AB
=
malloc
(
sizeof
(
point_t
));
*
AB
=
(
point_t
){
resAB
.
x
,
resAB
.
y
};
...
...
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