Skip to content

Commit

Permalink
Update Exercise 9
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdeakin committed Nov 24, 2014
1 parent cd3fc29 commit 1fc2c9b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Exercises/Exercise09/C/pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program will numerically compute the integral of
4/(1+x*x)
from 0 to 1. The value of this integral is pi -- which
4/(1+x*x)
from 0 to 1. The value of this integral is pi -- which
is great since it gives us an easy way to check the answer.
The is the original sequential program. It uses the timer
Expand Down Expand Up @@ -38,4 +38,5 @@ int main ()
pi = step * sum;
run_time = wtime() - start_time;
printf("\n pi with %ld steps is %lf in %lf seconds\n", num_steps, pi, run_time);
}
}

2 changes: 1 addition & 1 deletion Exercises/Exercise09/Cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ifndef CPPC
CPPC = g++
endif

CCFLAGS = -O3 -std=c++11 -lrt
CCFLAGS = -O3 -lrt

LIBS = -lm

Expand Down
9 changes: 5 additions & 4 deletions Exercises/Exercise09/Cpp/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
This program will numerically compute the integral of
4/(1+x*x)
from 0 to 1. The value of this integral is pi -- which
4/(1+x*x)
from 0 to 1. The value of this integral is pi -- which
is great since it gives us an easy way to check the answer.
The is the original sequential program. It uses the timer
Expand Down Expand Up @@ -41,4 +41,5 @@ int main ()
pi = step * sum;
double run_time = static_cast<double>(timer.getTimeMilliseconds()) / 1000.0;
printf("\n pi with %ld steps is %lf in %lf seconds\n", num_steps, pi, run_time);
}
}

7 changes: 4 additions & 3 deletions Exercises/Exercise09/Python/pi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# This program will numerically compute the integral of
#
# 4/(1+x*x)
#
# from 0 to 1. The value of this integral is pi -- which
# 4/(1+x*x)
#
# from 0 to 1. The value of this integral is pi -- which
# is great since it gives us an easy way to check the answer.
#
# This the original sequential program.
Expand Down Expand Up @@ -37,3 +37,4 @@
run_time = time() - start_time;

print "\npi with", num_steps, "steps is", pi, "in", run_time, "seconds\n"

0 comments on commit 1fc2c9b

Please sign in to comment.