Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SDA
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
Show more breadcrumbs
Julien David
SDA
Commits
d24f9e12
Commit
d24f9e12
authored
5 years ago
by
david
Browse files
Options
Downloads
Patches
Plain Diff
long double in C
parent
80e299b3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
C/analyzer.c
+8
-8
8 additions, 8 deletions
C/analyzer.c
C/analyzer.h
+5
-5
5 additions, 5 deletions
C/analyzer.h
C/main.c
+4
-4
4 additions, 4 deletions
C/main.c
with
17 additions
and
17 deletions
C/analyzer.c
+
8
−
8
View file @
d24f9e12
...
...
@@ -35,25 +35,25 @@ void analyzer_append(analyzer_t * a, double x){
}
}
double
get_total_cost
(
analyzer_t
*
a
){
long
double
get_total_cost
(
analyzer_t
*
a
){
return
(
a
->
size
)
?
a
->
cumulative_cost
[
a
->
size
-
1
]
:
-
1
;
}
double
get_amortized_cost
(
analyzer_t
*
a
,
size_t
pos
){
long
double
get_amortized_cost
(
analyzer_t
*
a
,
size_t
pos
){
if
(
pos
>=
0
&&
pos
<
a
->
size
)
return
(
pos
)
?
a
->
cumulative_cost
[
pos
]
/
pos
:
a
->
cumulative_cost
[
pos
];
return
-
1
;
}
double
get_average_cost
(
analyzer_t
*
a
){
long
double
get_average_cost
(
analyzer_t
*
a
){
if
(
a
->
size
)
return
a
->
cumulative_cost
[
a
->
size
-
1
]
/
a
->
size
;
return
-
1
;
}
double
get_variance
(
analyzer_t
*
a
){
double
mean
,
mean_square
;
long
double
get_variance
(
analyzer_t
*
a
){
long
double
mean
,
mean_square
;
if
(
a
->
size
){
mean
=
get_average_cost
(
a
);
mean_square
=
mean
*
mean
;
...
...
@@ -62,7 +62,7 @@ double get_variance(analyzer_t * a){
return
-
1
;
}
double
get_standard_deviation
(
analyzer_t
*
a
){
long
double
get_standard_deviation
(
analyzer_t
*
a
){
if
(
a
->
size
)
return
sqrt
(
get_variance
(
a
));
return
-
1
;
...
...
@@ -73,7 +73,7 @@ void save_values(analyzer_t * a, char * path){
int
i
;
if
(
(
f
=
fopen
(
path
,
"w"
))
!=
NULL
){
for
(
i
=
0
;
i
<
a
->
size
;
++
i
){
fprintf
(
f
,
"%d %lf %
l
f
\n
"
,
i
,
a
->
cost
[
i
],
get_amortized_cost
(
a
,
i
));
fprintf
(
f
,
"%d %lf %
L
f
\n
"
,
i
,
a
->
cost
[
i
],
get_amortized_cost
(
a
,
i
));
}
}
else
{
fprintf
(
stderr
,
"Could not save values in file %s"
,
path
);
...
...
@@ -83,6 +83,6 @@ void save_values(analyzer_t * a, char * path){
void
plot_values
(
analyzer_t
*
a
){
int
i
;
for
(
i
=
0
;
i
<
a
->
size
;
++
i
){
printf
(
"%d %lf %
l
f
\n
"
,
i
,
a
->
cost
[
i
],
get_amortized_cost
(
a
,
i
));
printf
(
"%d %lf %
L
f
\n
"
,
i
,
a
->
cost
[
i
],
get_amortized_cost
(
a
,
i
));
}
}
This diff is collapsed.
Click to expand it.
C/analyzer.h
+
5
−
5
View file @
d24f9e12
...
...
@@ -51,7 +51,7 @@ void analyzer_append(analyzer_t * a, double cost);
@param a est une analyse.
@returns la somme des coûts enregistrés dans cette analyse.
*/
double
get_total_cost
(
analyzer_t
*
a
);
long
double
get_total_cost
(
analyzer_t
*
a
);
/**
Renvoie le coût amorti d'une opération.
...
...
@@ -60,7 +60,7 @@ double get_total_cost(analyzer_t * a);
@param pos est l'indice de l'opération pour laquelle on veut connaître le coût amorti.
@returns le coût amorti d'une opération.
*/
double
get_amortized_cost
(
analyzer_t
*
a
,
size_t
pos
);
long
double
get_amortized_cost
(
analyzer_t
*
a
,
size_t
pos
);
/**
Renvoie la moyenne des coûts de toutes les opérations enregistrées dans l'analyse.
...
...
@@ -68,7 +68,7 @@ double get_amortized_cost(analyzer_t * a, size_t pos);
@param a est une analyse.
@returns la moyenne des coûts de toutes les opérations enregistrées dans l'analyse.
*/
double
get_average_cost
(
analyzer_t
*
a
);
long
double
get_average_cost
(
analyzer_t
*
a
);
/**
Renvoie la variance des coûts de toutes les opérations enregistrées dans l'analyse.
...
...
@@ -76,7 +76,7 @@ double get_average_cost(analyzer_t * a);
@param a est une analyse.
@returns la variance des coûts de toutes les opérations enregistrées dans l'analyse.
*/
double
get_variance
(
analyzer_t
*
a
);
long
double
get_variance
(
analyzer_t
*
a
);
/**
Renvoie l'écart-type des coûts de toutes les opérations enregistrées dans l'analyse.
...
...
@@ -84,7 +84,7 @@ double get_variance(analyzer_t * a);
@param a est une analyse.
@returns l'écart-type des coûts de toutes les opérations enregistrées dans l'analyse.
*/
double
get_standard_deviation
(
analyzer_t
*
a
);
long
double
get_standard_deviation
(
analyzer_t
*
a
);
/**
Sauvegarde la liste des coûts et des coûts amortis dans un fichier.
...
...
This diff is collapsed.
Click to expand it.
C/main.c
+
4
−
4
View file @
d24f9e12
...
...
@@ -38,10 +38,10 @@ int main(int argc, char ** argv){
}
// Affichage de quelques statistiques sur l'expérience.
fprintf
(
stderr
,
"Total cost: %
l
f
\n
"
,
get_total_cost
(
time_analysis
));
fprintf
(
stderr
,
"Average cost: %
l
f
\n
"
,
get_average_cost
(
time_analysis
));
fprintf
(
stderr
,
"Variance: %
l
f
\n
"
,
get_variance
(
time_analysis
));
fprintf
(
stderr
,
"Standard deviation: %
l
f
\n
"
,
get_standard_deviation
(
time_analysis
));
fprintf
(
stderr
,
"Total cost: %
L
f
\n
"
,
get_total_cost
(
time_analysis
));
fprintf
(
stderr
,
"Average cost: %
L
f
\n
"
,
get_average_cost
(
time_analysis
));
fprintf
(
stderr
,
"Variance: %
L
f
\n
"
,
get_variance
(
time_analysis
));
fprintf
(
stderr
,
"Standard deviation: %
L
f
\n
"
,
get_standard_deviation
(
time_analysis
));
// Sauvegarde les données de l'expérience.
save_values
(
time_analysis
,
"../plots/dynamic_array_time_c.plot"
);
...
...
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