next up previous contents
Next: Working with classes Up: No Title Previous: Contents

Infrastructure

 

To be able to solve Poisson's equation as a single line of code

  phi=I(Linv((-4*pi)*O(J(rho))));
requires two capabilities not common in c programs. First, in the above expression, the calls to functions such as J(..) return not single numbers but entire arrays. Second, the expression (-4*pi)*O(..) represents not a simple scalar multiplication but rather multiplication of the scalar (-4*pi) with the entire array returned by O(..). We therefore need the ability to work with objects like arrays as easily as we work with numbers in c.

C++ supports these capabilities with exactly the same syntax as c, so that, if you know c, then programming in C++ (at least the kind we do in scientific programming) is fairly straightforward. The only tricky part is that you must explicitly program how your different objects behave.

For this first problem, we give you with some of this infrastructure as a guide for you to build the rest. This will take some time, but once it is working, it will make the rest of our work in the semester much nicer.





Tomas Arias
Fri Apr 14 12:12:49 EDT 2000