Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Taddeüs Kroes
uva
Commits
5c137bff
Commit
5c137bff
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Finished code of question 3.
parent
edff8604
No related branches found
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
simmod/ass1/.gitignore
+3
-0
3 additions, 0 deletions
simmod/ass1/.gitignore
simmod/ass1/Makefile
+12
-6
12 additions, 6 deletions
simmod/ass1/Makefile
simmod/ass1/sum.c
+14
-14
14 additions, 14 deletions
simmod/ass1/sum.c
with
29 additions
and
20 deletions
simmod/ass1/.gitignore
+
3
−
0
View file @
5c137bff
sum.float
sum.double
sum
speed.*.*
speed
fp
...
...
This diff is collapsed.
Click to expand it.
simmod/ass1/Makefile
+
12
−
6
View file @
5c137bff
FLAGS
=
-Wall
-Wextra
-std
=
c99
-pedantic
-O0
-lm
TYPES
=
float double LD
SPEED_TYPES
=
float double LD
SUM_TYPES
=
float double
OPS
=
ADD DIV MULT SQRT
all
:
fp speed report.pdf
float_double
all
:
fp speed report.pdf
sum
%.pdf
:
%.tex
pdflatex
$^
pdflatex
$^
speed
:
speed.c
for
t
in
$(
TYPES
);
do
\
for
t
in
$(
SPEED_
TYPES
);
do
\
for
o
in
$(
OPS
);
do
\
sed
"s#{TYPE}#
$$
t#"
$^
|
sed
"s#{OP}#
$$
o#"
>
speed.
$$
t.
$$
o.c
;
\
gcc
$(
FLAGS
)
-o
speed.
$$
t.
$$
o speed.
$$
t.
$$
o.c
;
\
...
...
@@ -21,8 +22,13 @@ speed: speed.c
fp
:
floating_point.o
gcc
$(
FLAGS
)
-o
$@
$^
float_double
:
float_vs_double.o
gcc
$(
FLAGS
)
-o
$@
$^
sum
:
sum.c
for
t
in
$(
SUM_TYPES
);
do
\
sed
"s#{TYPE}#
$$
t#"
$^
>
sum.
$$
t.c
;
\
gcc
$(
FLAGS
)
-o
sum.
$$
t sum.
$$
t.c
;
\
rm
sum.
$$
t.c
;
\
done
;
touch
$@
%.o
:
%.c
gcc
$(
FLAGS
)
-o
$@
-c
$^
...
...
@@ -31,4 +37,4 @@ float_double: float_vs_double.o
gcc
$(
FLAGS
)
-o
$*
$^
clean
:
rm
-vf
*
.o
*
.i
*
.s fp speed speed.
*
.
*
floating_point
rm
-vf
*
.o
*
.i
*
.s fp speed speed.
*
.
*
floating_point
sum
sum.float sum.double
This diff is collapsed.
Click to expand it.
simmod/ass1/
float_vs_double
.c
→
simmod/ass1/
sum
.c
+
14
−
14
View file @
5c137bff
#include
<stdlib.h>
#include
<stdio.h>
int
main
(
void
)
{
puts
(
"Using type {TYPE}."
);
puts
(
"Forward summation:"
);
printf
(
"N = 1e8: %e
\n
"
,
sum_forward
(
1e8
));
printf
(
"N = 2e8: %e
\n
"
,
sum_forward
(
2e8
));
puts
(
"Backward summation:"
);
printf
(
"N = 1e8: %e
\n
"
,
sum_backward
(
1e8
));
printf
(
"N = 2e8: %e
\n
"
,
sum_backward
(
2e8
));
return
0
;
}
{
TYPE
}
sum_forward
(
int
N
)
{
{
TYPE
}
sum
=
0
;
...
...
@@ -32,3 +18,17 @@ int main(void) {
return
sum
;
}
int
main
(
void
)
{
puts
(
"Using type {TYPE}."
);
puts
(
"Forward summation:"
);
printf
(
"N = 1e8: %e
\n
"
,
sum_forward
(
1e8
));
printf
(
"N = 2e8: %e
\n
"
,
sum_forward
(
2e8
));
puts
(
"Backward summation:"
);
printf
(
"N = 1e8: %e
\n
"
,
sum_backward
(
1e8
));
printf
(
"N = 2e8: %e
\n
"
,
sum_backward
(
2e8
));
return
0
;
}
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