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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14.1. COMPUTING AN EIGENFUNCTION OF THE POISSON EQUATION 271<br />

0.45<br />

0.4<br />

0.35<br />

0.3<br />

0.25<br />

0.2<br />

0.15<br />

"x.out"<br />

0.1<br />

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1<br />

Figure 14.1: First eigenvector of the 1D Poisson operator<br />

int main() {<br />

typedef glas::dense vector v type ;<br />

int n = 10 ;<br />

v type x( n ) ;<br />

glas::random seed seed ;<br />

glas::random( x, seed ) ;<br />

v type d( n ) ; std::fill( begin(d), end(d), 2.0 ) ;<br />

v type e( n−1 ) ; std::fill( begin(e), end(e), −1.0 ) ;<br />

solve< v type, v type > solver( d, e ) ;<br />

athens::inverse iteration( solver, x, 100, lambda ) ;<br />

std::cout ≪ ”lambda = ” ≪ lambda ≪ std::endl ;<br />

std::ofstream xf( ”x.out” ) ;<br />

<strong>for</strong> ( int i=0; i plot "x.out" w l<br />

gnuplot>

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

Saved successfully!

Ooh no, something went wrong!