DGtal  1.5.beta
DiscreteExteriorCalculusSolver.ih
1 /**
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU Lesser General Public License as
4  * published by the Free Software Foundation, either version 3 of the
5  * License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  *
15  **/
16 
17 /**
18  * @file DiscreteExteriorCalculusSolver.ih
19  * @author Pierre Gueth (\c pierre.gueth@liris.cnrs.fr )
20  * Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
21  *
22  * @date 2014/03/27
23  *
24  * Implementation of inline methods defined in DiscreteExteriorCalculusSolver.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 ///////////////////////////////////////////////////////////////////////////////
30 // IMPLEMENTATION of inline methods.
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 ///////////////////////////////////////////////////////////////////////////////
34 // ----------------------- Standard services ------------------------------
35 
36 template <typename C, typename S, DGtal::Order order_in, DGtal::Duality duality_in, DGtal::Order order_out, DGtal::Duality duality_out>
37 DGtal::DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>::DiscreteExteriorCalculusSolver()
38  : myCalculus(NULL)
39 {
40 }
41 
42 ///////////////////////////////////////////////////////////////////////////////
43 // Interface - public :
44 
45 template <typename C, typename S, DGtal::Order order_in, DGtal::Duality duality_in, DGtal::Order order_out, DGtal::Duality duality_out>
46 void
47 DGtal::DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>::selfDisplay(std::ostream& out) const
48 {
49  out << "[DiscreteExteriorCalculusSolver]";
50 }
51 
52 template <typename C, typename S, DGtal::Order order_in, DGtal::Duality duality_in, DGtal::Order order_out, DGtal::Duality duality_out>
53 DGtal::DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>&
54 DGtal::DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>::compute(const Operator& linear_operator)
55 {
56  myLinearAlgebraSolver.compute(linear_operator.myContainer);
57  myCalculus = linear_operator.myCalculus;
58  return *this;
59 }
60 
61 template <typename C, typename S, DGtal::Order order_in, DGtal::Duality duality_in, DGtal::Order order_out, DGtal::Duality duality_out>
62 DGtal::KForm<C, order_in, duality_in>
63 DGtal::DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>::solve(const InputKForm& input_kform) const
64 {
65  ASSERT( myCalculus == input_kform.myCalculus );
66  SolutionKForm solution(*input_kform.myCalculus, myLinearAlgebraSolver.solve(input_kform.myContainer));
67  return solution;
68 }
69 
70 template <typename C, typename S, DGtal::Order order_in, DGtal::Duality duality_in, DGtal::Order order_out, DGtal::Duality duality_out>
71 bool
72 DGtal::DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>::isValid() const
73 {
74  if (myCalculus == NULL) return false;
75  return myLinearAlgebraSolver.info() == 0;
76 }
77 
78 ///////////////////////////////////////////////////////////////////////////////
79 // Implementation of inline functions //
80 
81 template <typename C, typename S, DGtal::Order order_in, DGtal::Duality duality_in, DGtal::Order order_out, DGtal::Duality duality_out>
82 std::ostream&
83 DGtal::operator<<(std::ostream& out, const DiscreteExteriorCalculusSolver<C, S, order_in, duality_in, order_out, duality_out>& object)
84 {
85  object.selfDisplay(out);
86  return out;
87 }
88 
89 // //
90 ///////////////////////////////////////////////////////////////////////////////