03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Numerical exercises<br />

Chapter 14<br />

In this chapter, we list a number of exercises where the different aspects discussed in the course<br />

will be used. The goal is to implement a small application program in <strong>C++</strong>, run it and interpret<br />

the results.<br />

You can use any software that may help you with your task. A list of packages is provided<br />

at the end of this chapter. We have only installed Boost, Boost.Sandbox, GLAS, BLAS, and,<br />

LAPACK. Other smaller packages could be downloaded if necessary.<br />

In each exercise, a generic function or class will be developed, and its documentation. These<br />

functions and classes should be part of the namespace athens. The functions arguments will<br />

have to be described. Each template argument will have to satisfy concepts. You may have<br />

to define new concepts. If you are using STL or GLAS concepts, you can just refer to them,<br />

without definition.<br />

Write a small paper on the decisions you made <strong>for</strong> the development of the software. Use the<br />

software <strong>for</strong> some examples and report the results. You may write the report on paper or send<br />

it in electronic <strong>for</strong>m (PDF by preference).<br />

14.1 Computing an eigenfunction of the Poisson equation<br />

This is an example of a more complicated problem. It illustrates what is expected from the<br />

exercises. The actual exercises are less demanding.<br />

In this section, we derive software <strong>for</strong> the solution of the Poisson equation. We start with the<br />

1D problem and then move to the 2D problem.<br />

14.1.1 The 1D Poisson equation<br />

The 1D Poisson equation is<br />

− d2u = f (14.1)<br />

dx2 where u(x) is the solution and f the excitation and x ∈ [0, 1]. We impose the boundary<br />

conditions<br />

u(0) = u(1) = 0 .<br />

263

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!