prime, a MATLAB code which counts the number of primes between 1 and N, and is intended as a starting point for a parallel version.
The algorithm is completely naive. For each integer I, it simply checks whether any smaller J evenly divides it. The total amount of work for a given N is thus roughly proportional to 1/2*N^2.
Here are the counts of the number of primes for some selected values of N:
|N||Number of Primes|
The following results were observed for the elapsed time, running on a Macintosh PowerPC G5:
total = prime ( n )where
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
prime is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.
collatz, a MATLAB code which computes and analyzes the collatz sequence (or "hailstone" sequence or "3n+1 sequence");
fft_serial, a MATLAB code which demonstrates the computation of a fast fourier transform, and is intended as a starting point for implementing a parallel version.
fire_simulation, a MATLAB code which simulates a forest fire over a rectangular array of trees, starting at a single random location. it is intended as a starting point for the development of a parallel version.
md, a MATLAB code which carries out a molecular dynamics simulation, and is intended as a starting point for implementing a parallel version.
mxm, a MATLAB code which sets up a matrix multiplication problem a=b*c, intended as a starting point for implementing a parallel version.
poisson, a MATLAB code which computes an approximate solution to the poisson equation in a rectangle, and is intended as the starting point for the creation of a parallel version.
prime_plot a MATLAB code which displays a box plot of the prime and composite numbers.
quad, a MATLAB code which approximates an integral using a quadrature rule, and is intended as a starting point for parallelization exercises.
quad2d, a MATLAB code which approximates an integral over a 2d region using a product quadrature rule, and is intended as a starting point for parallelization exercises.
satisfy, a MATLAB code which demonstrates, for a particular circuit, an exhaustive search for solutions of the circuit satisfiability problem.
search_test, a MATLAB code which searches the integers from a to b for a value j such that f(j) = c. this version of the program is intended as a starting point for a parallel approach.
timer_test, MATLAB codes which demonstrate how to compute cpu time or elapsed time.