DGtal 1.3.0
Loading...
Searching...
No Matches
Simple2x2DetComputer.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 Simple2x2DetComputer.ih
19 * @author Tristan Roussillon (\c tristan.roussillon@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
21 *
22 * @date 2013/11/18
23 *
24 * Implementation of inline methods defined in Simple2x2DetComputer.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29
30//////////////////////////////////////////////////////////////////////////////
31#include <cstdlib>
32//////////////////////////////////////////////////////////////////////////////
33
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
37
38///////////////////////////////////////////////////////////////////////////////
39// ---------------------------------------------------------------------------
40template <typename TI, typename TO>
41inline
42DGtal::Simple2x2DetComputer<TI,TO>::Simple2x2DetComputer()
43 : myA (NumberTraits<ResultInteger>::ZERO),
44 myB (NumberTraits<ResultInteger>::ZERO),
45 myAY (NumberTraits<ResultInteger>::ZERO),
46 myBX (NumberTraits<ResultInteger>::ZERO)
47{
48}
49
50// ---------------------------------------------------------------------------
51template <typename TI, typename TO>
52inline
53DGtal::Simple2x2DetComputer<TI,TO>::Simple2x2DetComputer(const DGtal::Simple2x2DetComputer<TI,TO>& aOther)
54 : myA (aOther.myA),
55 myB (aOther.myB),
56 myAY (aOther.myAY),
57 myBX (aOther.myBX)
58{
59}
60
61// ---------------------------------------------------------------------------
62template <typename TI, typename TO>
63inline
64DGtal::Simple2x2DetComputer<TI,TO>&
65DGtal::Simple2x2DetComputer<TI,TO>::operator=(const DGtal::Simple2x2DetComputer<TI,TO>& aOther)
66{
67 if (this != &aOther)
68 {
69 myA = aOther.myA;
70 myB = aOther.myB;
71 myAY = aOther.myAY;
72 myBX = aOther.myBX;
73 }
74 return *this;
75}
76
77// ---------------------------------------------------------------------------
78template <typename TI, typename TO>
79inline
80DGtal::Simple2x2DetComputer<TI,TO>::~Simple2x2DetComputer()
81{
82}
83
84// ---------------------------------------------------------------------------
85template <typename TI, typename TO>
86inline
87void
88DGtal::Simple2x2DetComputer<TI,TO>::init(const ArgumentInteger& aA, const ArgumentInteger& aB)
89{
90 myA = static_cast<ResultInteger>(aA);
91 myB = static_cast<ResultInteger>(aB);
92}
93
94// ---------------------------------------------------------------------------
95template <typename TI, typename TO>
96inline
97typename DGtal::Simple2x2DetComputer<TI,TO>::ResultInteger
98DGtal::Simple2x2DetComputer<TI,TO>::operator()(const ArgumentInteger& aX, const ArgumentInteger& aY) const
99{
100 myAY = myA * static_cast<ResultInteger>(aY);
101 myBX = myB * static_cast<ResultInteger>(aX);
102 return myAY - myBX;
103}
104
105// ---------------------------------------------------------------------------
106template <typename TI, typename TO>
107inline
108typename DGtal::Simple2x2DetComputer<TI,TO>::ResultInteger
109DGtal::Simple2x2DetComputer<TI,TO>::operator()(const ArgumentInteger& aA, const ArgumentInteger& aB,
110 const ArgumentInteger& aX, const ArgumentInteger& aY)
111{
112 init(aA,aB);
113 return operator()(aX, aY);
114}
115
116// ---------------------------------------------------------------------------
117template <typename TI, typename TO>
118inline
119void
120DGtal::Simple2x2DetComputer<TI,TO>::selfDisplay ( std::ostream & out ) const
121{
122 out << "[Simple2x2DetComputer]";
123}
124
125// ---------------------------------------------------------------------------
126template <typename TI, typename TO>
127inline
128bool
129DGtal::Simple2x2DetComputer<TI,TO>::isValid() const
130{
131 return true;
132}
133
134
135
136///////////////////////////////////////////////////////////////////////////////
137// Implementation of inline functions //
138
139template <typename TI, typename TO>
140inline
141std::ostream&
142DGtal::operator<< ( std::ostream & out,
143 const Simple2x2DetComputer<TI,TO> & object )
144{
145 object.selfDisplay( out );
146 return out;
147}
148
149// //
150///////////////////////////////////////////////////////////////////////////////
151
152