From: Lei Qiao Date: Mon, 20 Apr 2015 19:16:44 +0000 (-0500) Subject: simplify accessing to Vector element. X-Git-Tag: v8.3.0-rc1~225^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F856%2Fhead;p=dealii.git simplify accessing to Vector element. --- diff --git a/examples/step-33/step-33.cc b/examples/step-33/step-33.cc index bbe74f4719..991cb80db0 100644 --- a/examples/step-33/step-33.cc +++ b/examples/step-33/step-33.cc @@ -172,20 +172,6 @@ namespace Step33 // = \frac{|\rho \mathbf v|^2}{2\rho}$ (note that the independent // variables contain the momentum components $\rho v_i$, not the // velocities $v_i$). - // - // There is one slight problem: We will need to call the following - // functions with input arguments of type - // std::vector@ and - // Vector@. The problem is that the former has an - // access operator operator[] whereas the latter, for - // historical reasons, has operator(). We wouldn't be able to - // write the function in a generic way if we were to use one or the other - // of these. Fortunately, we can use the following trick: instead of - // writing v[i] or v(i), we can use - // *(v.begin() + i), i.e. we generate an iterator that points - // to the ith element, and then dereference it. This works - // for both kinds of vectors -- not the prettiest solution, but one that - // works. template static typename InputVector::value_type @@ -193,9 +179,9 @@ namespace Step33 { typename InputVector::value_type kinetic_energy = 0; for (unsigned int d=0; d