]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/strategies/transform/inverse_transformer.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / strategies / transform / inverse_transformer.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6
7// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#ifndef BOOST_GEOMETRY_STRATEGIES_TRANSFORM_INVERSE_TRANSFORMER_HPP
15#define BOOST_GEOMETRY_STRATEGIES_TRANSFORM_INVERSE_TRANSFORMER_HPP
16
17// Remove the ublas checking, otherwise the inverse might fail
18// (while nothing seems to be wrong)
19#ifdef BOOST_UBLAS_TYPE_CHECK
20#undef BOOST_UBLAS_TYPE_CHECK
21#endif
22#define BOOST_UBLAS_TYPE_CHECK 0
23
24#include <boost/numeric/ublas/lu.hpp>
25#include <boost/numeric/ublas/io.hpp>
26
27#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
28
29
30namespace boost { namespace geometry
31{
32
33namespace strategy { namespace transform
34{
35
36/*!
37\brief Transformation strategy to do an inverse transformation in a Cartesian coordinate system
38\ingroup strategies
39 */
40template
41<
42 typename CalculationType,
43 std::size_t Dimension1,
44 std::size_t Dimension2
45>
46class inverse_transformer
47 : public ublas_transformer<CalculationType, Dimension1, Dimension2>
48{
49public :
50 template <typename Transformer>
51 inline inverse_transformer(Transformer const& input)
52 {
53 typedef boost::numeric::ublas::matrix<CalculationType> matrix_type;
54
55 // create a working copy of the input
56 matrix_type copy(input.matrix());
57
58 // create a permutation matrix for the LU-factorization
59 typedef boost::numeric::ublas::permutation_matrix<> permutation_matrix;
60 permutation_matrix pm(copy.size1());
61
62 // perform LU-factorization
63 int res = boost::numeric::ublas::lu_factorize<matrix_type>(copy, pm);
64 if( res == 0 )
65 {
66 // create identity matrix
67 this->m_matrix.assign(boost::numeric::ublas::identity_matrix<CalculationType>(copy.size1()));
68
69 // backsubstitute to get the inverse
70 boost::numeric::ublas::lu_substitute(copy, pm, this->m_matrix);
71 }
72 }
73
74};
75
76
77}} // namespace strategy::transform
78
79
80}} // namespace boost::geometry
81
82#endif // BOOST_GEOMETRY_STRATEGIES_TRANSFORM_INVERSE_TRANSFORMER_HPP