[Dune-devel] [Dune-Commit] [Commit] dune-geometry - cb66db8: Add explicit conversion, needed when using high precision types like boost::multiprecision

Andreas Buhr andreas at andreasbuhr.de
Fri Jun 13 12:14:41 CEST 2014


Dear Duners, dear Markus,

On 06/12/2014 07:08 PM, Markus Blatt wrote:
>> >  
>> >        /* The second case effectively results in x* = 0 */
>> > -      ctype dfcxn = (cxn > Traits::tolerance() || cxn < -Traits::tolerance()) ? df / cxn : 0;
>> > +      ctype dfcxn = (cxn > Traits::tolerance() || cxn < -Traits::tolerance()) ? ctype(df / cxn) : ctype(0);
>> >  
> Sorry for being dense, but I do not get why this is needed and hope to
> learn something.

I am glad you ask. The problem is indeed quite subtle. I am using the
code with a "boost::multiprecision::mpf_float_1000" to calculate some
reference results with 1000 digits accuracy.

"df" and "cxn" are of type "ctype", but that does not mean that "df /
cxn" is automatically of type "ctype". boost::multiprecision uses
expression templates, so "df / cxn" becomes an
"boost::multiprecision::detail::expression". The "?:" operator then sees
the types (bool|expression|int) and generates an error.

For reference, I attached the complete compile output.

I hope this answers your question?

cheers,
Andreas

-------------- next part --------------
In file included from /home/andreasbuhr/development/dune-andi-demos/dune-andi/src/symbolic_integration_tests/simplex_3d_nedelec_p1_rotrot.hh:4:0,
                 from /home/andreasbuhr/development/dune-andi-demos/dune-andi/src/symbolic_integration_tests/test_simplex_3d_nedelec_p1_rotrot.cpp:13:
/home/andreasbuhr/development/dune-andi-demos/dune-geometry/dune/geometry/multilineargeometry.hh: In instantiation of ‘static void Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::jacobianTransposed(Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::TopologyId, std::integral_constant<int, dim>, Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::CornerIterator&, const ctype&, const LocalCoordinate&, const ctype&, Dune::FieldMatrix<ct, rows, cdim>&) [with bool add = false; int rows = 3; int dim = 3; ct = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >; int mydim = 3; int cdim = 3; Traits = Dune::MultiLinearGeometryTraits<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > >; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::TopologyId = unsigned int; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::CornerIterator = __gnu_cxx::__normal_iterator<const Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3>*, std::vector<Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3>, std::allocator<Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3> > > >; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::ctype = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::LocalCoordinate = Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3>]’:
/home/andreasbuhr/development/dune-andi-demos/dune-geometry/dune/geometry/multilineargeometry.hh:328:25:   required from ‘Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::JacobianTransposed Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::jacobianTransposed(const LocalCoordinate&) const [with ct = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >; int mydim = 3; int cdim = 3; Traits = Dune::MultiLinearGeometryTraits<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > >; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::JacobianTransposed = Dune::FieldMatrix<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3, 3>; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::LocalCoordinate = Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3>]’
/home/andreasbuhr/development/dune-andi-demos/dune-geometry/dune/geometry/multilineargeometry.hh:299:106:   required from ‘Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::ctype Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::integrationElement(const LocalCoordinate&) const [with ct = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >; int mydim = 3; int cdim = 3; Traits = Dune::MultiLinearGeometryTraits<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > >; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::ctype = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >; Dune::MultiLinearGeometry<ct, mydim, cdim, Traits>::LocalCoordinate = Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3>]’
/home/andreasbuhr/development/dune-andi-demos/dune-pdelab/dune/pdelab/localoperator/electrodynamic.hh:229:13:   required from ‘void Dune::PDELab::Electrodynamic_S<Mu>::jacobian_volume(const EG&, const LFS&, const X&, const LFS&, M&) const [with EG = Dune::PDELab::ElementGeometry<Entity<Dune::MultiLinearGeometry<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3, 3, Dune::MultiLinearGeometryTraits<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > > > > >; LFS = FakeLFS<Dune::EdgeS0_5FiniteElement<Dune::MultiLinearGeometry<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3, 3, Dune::MultiLinearGeometryTraits<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > > >, boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > > >; X = Dune::FieldVector<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, 3>; M = Dune::PDELab::WeightedMatrixAccumulationView<Dune::PDELab::LocalMatrix<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > > >; Mu = Mu<boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> > >]’
/home/andreasbuhr/development/dune-andi-demos/dune-andi/src/symbolic_integration_tests/simplex_3d_nedelec_p1_rotrot.hh:254:3:   required from ‘void simplex_3d_nedelec_p1_rotrot_localoperator_dune(cdomaintype*, const simplex_3d_points<ctype>&) [with cdomaintype = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >]’
/home/andreasbuhr/development/dune-andi-demos/dune-andi/src/symbolic_integration_tests/test_simplex_3d_nedelec_p1_rotrot.cpp:51:70:   required from ‘void execute_tests() [with ctype = boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >]’
/home/andreasbuhr/development/dune-andi-demos/dune-andi/src/symbolic_integration_tests/test_simplex_3d_nedelec_p1_rotrot.cpp:111:58:   required from here
/home/andreasbuhr/development/dune-andi-demos/dune-geometry/dune/geometry/multilineargeometry.hh:737:79: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘boost::multiprecision::detail::expression<boost::multiprecision::detail::divide_immediates, boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, boost::multiprecision::number<boost::multiprecision::backends::gmp_float<1000u> >, void, void>’, and ‘int’)
       ctype dfcxn = (cxn > Traits::tolerance() || cxn < -Traits::tolerance()) ? df / cxn : 0;
                                                                               ^
compilation terminated due to -Wfatal-errors.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20140613/cbc56326/attachment.sig>


More information about the Dune-devel mailing list