Computational Physics - Department of Physics
3.3 Classes in C++ 69 meaning that it sets the real and imaginary parts to zero. Note the way a member function is defined. The ...
70 3 Numerical differentiation and interpolation Complex& Complex::operator= (constComplex& c) { re = c.re; im = c.im; r ...
3.3 Classes in C++ 71 inlineComplexoperator(constComplex& a,constComplex& b) { returnComplex(a.reb.re - a.imb.im, a.imb. ...
72 3 Numerical differentiation and interpolation T Re ()const; // T real_part = a.Re(); T Im ()const; // T imag_part = a.Im(); T ...
3.3 Classes in C++ 73 Our classVectorhas as data a plain one-dimensional array. We define several functions which operate on the ...
74 3 Numerical differentiation and interpolation Vector v;// declare a vector of length 0 // this actually means calling the fun ...
3.3 Classes in C++ 75 inti; for(i = 0; i < length; i++){// (C++ arrays start at 0) A[i] = w.A[i];// fill in teh vector w } re ...
76 3 Numerical differentiation and interpolation ostream&operator<< (ostream& o,constVector& v) {v.print(o);re ...
3.3 Classes in C++ 77 { T*A; intlength; public: ... T&operator() (inti){returnA[i-1];} ... }; In a code which uses this clas ...
78 3 Numerical differentiation and interpolation v5(1) = 2.5;// or alternatively v5[1] = 2.5; v5(2) = 1.0;// or alternatively v5 ...
3.3 Classes in C++ 79 /** *@brief Constructor. Creates a vector initializing its elements to zero *@param int_length. The number ...
80 3 Numerical differentiation and interpolation boolredim(intn1); /****************************************************/ /* (US ...
3.3 Classes in C++ 81 / Division of the entries of a vector by a scalar. / friendVectoroperator/(constVector&,double);// u = ...
82 3 Numerical differentiation and interpolation // Alternative to operator[] inline const double& Vector::operator()(inti)c ...
3.3 Classes in C++ 83 Vector::Vector(int_length,// length of the array const double*array){// one-dimensioal array length =_leng ...
84 3 Numerical differentiation and interpolation Vector& Vector::operator=(constVector& w){// v = w if(this!= &w){ / ...
3.3 Classes in C++ 85 // Postmultiplication operator Vectoroperator(constVector& v,doublescalar){// u = va returnVector(v)*= ...
86 3 Numerical differentiation and interpolation doublevi = fabs(vec[i]); if(norm < 100 && vi < 100){ norm = sqrt( ...
3.4 Modules in Fortran 87 SUBROUTINE allocate_sp_array(this_array,n) TYPE (single_particle_descript), INTENT(INOUT) :: this_arra ...
88 3 Numerical differentiation and interpolation CASE ('proton&neutron') CALL read_nuclear_sp_data END SELECT END SUBROUTINE ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf