1 /****************************************************************************
2 * VCGLib                                                            o o     *
3 * Visual and Computer Graphics Library                            o     o   *
4 *                                                                _   O  _   *
5 * Copyright(C) 2004-2016                                           \/)\/    *
6 * Visual Computing Lab                                            /\/|      *
7 * ISTI - Italian National Research Council                           |      *
8 *                                                                    \      *
9 * All rights reserved.                                                      *
10 *                                                                           *
11 * This program is free software; you can redistribute it and/or modify      *
12 * it under the terms of the GNU General Public License as published by      *
13 * the Free Software Foundation; either version 2 of the License, or         *
14 * (at your option) any later version.                                       *
15 *                                                                           *
16 * This program is distributed in the hope that it will be useful,           *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
20 * for more details.                                                         *
21 *                                                                           *
22 ****************************************************************************/
23 
24 #ifdef __GNUC__
25 #warning You are including deprecated math stuff
26 #endif
27 
28 typedef Scalar ScalarType;
29 
30 /*! \deprecated use cols() */
ColumnsNumber()31 EIGEN_DEPRECATED inline unsigned int ColumnsNumber() const { return cols(); };
32 
33 
34 /*! \deprecated use rows() */
RowsNumber()35 EIGEN_DEPRECATED inline unsigned int RowsNumber() const { return rows(); };
36 
37 /*!
38 *	\deprecated use *this(i,j) (or *this.coeff(i,j))
39 * Return the element stored in the <I>i</I>-th rows at the <I>j</I>-th column
40 *	\param i the row index
41 *	\param j the column index
42 *	\return the element
43 */
ElementAt(unsigned int i,unsigned int j)44 EIGEN_DEPRECATED inline Scalar ElementAt(unsigned int i, unsigned int j) const { return (*this)(i,j); };
ElementAt(unsigned int i,unsigned int j)45 EIGEN_DEPRECATED inline Scalar& ElementAt(unsigned int i, unsigned int j) { return (*this)(i,j); };
V(int i)46 EIGEN_DEPRECATED inline Scalar V(int i) const { return (*this)[i]; };
V(int i)47 EIGEN_DEPRECATED inline Scalar& V(int i) { return (*this)[i]; };
48 
49 /*!
50 *	\deprecated use *this.determinant() (or *this.lu().determinant() for large matrices)
51 *	Calculate and return the matrix determinant (Laplace)
52 *	\return	the matrix determinant
53 */
Determinant()54 EIGEN_DEPRECATED Scalar Determinant() const { return determinant(); };
55 
56 /*!
57 *	Return the cofactor <I>A<SUB>i,j</SUB></I> of the <I>a<SUB>i,j</SUB></I> element
58 *	\return	...
59 */
Cofactor(unsigned int i,unsigned int j)60 EIGEN_DEPRECATED Scalar Cofactor(unsigned int i, unsigned int j) const
61 {
62 	assert(rows() == cols());
63 	assert(rows()>2);
64 	return (((i+j)%2==0) ? 1. : -1.) * minor(i,j).determinant();
65 };
66 
67 /*! \deprecated use *this.col(j) */
GetColumn(const unsigned int j)68 EIGEN_DEPRECATED ColXpr GetColumn(const unsigned int j) { return col(j); };
69 
70 /*! \deprecated use *this.row(i) */
GetRow(const unsigned int i)71 EIGEN_DEPRECATED RowXpr GetRow(const unsigned int i) { return row(i); };
72 
73 /*! \deprecated use m1.col(i).swap(m1.col(j)); */
SwapColumns(const unsigned int i,const unsigned int j)74 EIGEN_DEPRECATED void SwapColumns(const unsigned int i, const unsigned int j)
75 {
76 	if (i==j) return;
77 	col(i).swap(col(j));
78 };
79 
80 /*! \deprecated use m1.col(i).swap(m1.col(j)) */
SwapRows(const unsigned int i,const unsigned int j)81 EIGEN_DEPRECATED void SwapRows(const unsigned int i, const unsigned int j)
82 {
83 	if (i==j) return;
84 	row(i).swap(row(j));
85 };
86 
87 /*!
88 *	\deprecated use *this.cwise() += k
89 *	(Modifier) Add to each element of this matrix the scalar constant <I>k</I>.
90 * \param k	the scalar constant
91 *	\return		the modified matrix
92 */
93 EIGEN_DEPRECATED Derived& operator+=(const Scalar k)
94 {
95 	cwise() += k;
96 	return *this;
97 };
98 
99 /*!
100 *	\deprecated use *this.cwise() -= k
101 *	(Modifier) Subtract from each element of this matrix the scalar constant <I>k</I>.
102 * \param k	the scalar constant
103 *	\return		the modified matrix
104 */
105 EIGEN_DEPRECATED Derived& operator-=(const Scalar k)
106 {
107 	cwise() -= k;
108 	return *this;
109 };
110 
111 /*!
112 *	\deprecated use *this.dot
113 *	Matrix multiplication: calculates the cross product.
114 *	\param	reference to the matrix to multiply by
115 *	\return the matrix product
116 */
117 // template <int N,int M>
118 // EIGEN_DEPRECATED void DotProduct(Point<N,Scalar> &m,Point<M,Scalar> &result)
119 // {
120 // 	unsigned int i, j;
121 // 	for (i=0; i<M; i++)
122 // 	{ result[i]=0;
123 // 		for (j=0; j<N; j++)
124 // 			result[i]+=(*this)[i][j]*m[j];
125 // 	}
126 // };
127 
128 
129 /*! \deprecated use *this = a * b.transpose() (or *this = a * b.adjoint() for complexes) */
130 template <typename OtherDerived1, typename OtherDerived2>
OuterProduct(const MatrixBase<OtherDerived1> & a,const MatrixBase<OtherDerived2> & b)131 EIGEN_DEPRECATED void OuterProduct(const MatrixBase<OtherDerived1>& a, const MatrixBase<OtherDerived2>& b)
132 { *this = a * b.adjoint(); }
133 
134 typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived> ScalarAddReturnType;
135 
136 /*! \deprecated use *this.cwise() + k */
137 EIGEN_DEPRECATED const ScalarAddReturnType operator+(const Scalar k) { return cwise() + k; }
138 
139 /*! \deprecated use *this.cwise() - k */
140 EIGEN_DEPRECATED const ScalarAddReturnType operator-(const Scalar k) { return cwise() - k; }
141 
142 /*! \deprecated use *this.setZero() or *this = MatrixType::Zero(rows,cols), etc. */
SetZero()143 EIGEN_DEPRECATED void SetZero() { setZero(); };
144 
145 /*! \deprecated use *this.setIdentity() or *this = MatrixType::Identity(rows,cols), etc. */
SetIdentity()146 EIGEN_DEPRECATED void SetIdentity() { setIdentity(); };
147 
148 /*! \deprecated use *this.col(j) = expression */
SetColumn(unsigned int j,Scalar * v)149 EIGEN_DEPRECATED void SetColumn(unsigned int j, Scalar* v)
150 { col(j) = Map<Matrix<Scalar,RowsAtCompileTime,1> >(v,cols(),1); };
151 
152 /** \deprecated use *this.col(i) = other */
153 template<typename OtherDerived>
SetColumn(unsigned int j,const MatrixBase<OtherDerived> & other)154 EIGEN_DEPRECATED void SetColumn(unsigned int j, const MatrixBase<OtherDerived>& other)
155 { col(j) = other; };
156 
157 /*! \deprecated use *this.row(i) = expression */
SetRow(unsigned int i,Scalar * v)158 EIGEN_DEPRECATED void SetRow(unsigned int i, Scalar* v)
159 { row(i) = Map<Matrix<Scalar,1,ColsAtCompileTime> >(v,1,rows()); };
160 
161 /** \deprecated use *this.row(i) = other */
162 template<typename OtherDerived>
SetRow(unsigned int j,const MatrixBase<OtherDerived> & other)163 EIGEN_DEPRECATED void SetRow(unsigned int j, const MatrixBase<OtherDerived>& other)
164 { row(j) = other; };
165 
166 /*! \deprecated use *this.diagonal() = expression */
SetDiagonal(Scalar * v)167 EIGEN_DEPRECATED void SetDiagonal(Scalar *v)
168 {
169 	assert(rows() == cols());
170 	diagonal() = Map<Matrix<Scalar,RowsAtCompileTime,1> >(v,cols(),1);
171 }
172 
173 /** \deprecated use trace() */
Trace()174 EIGEN_DEPRECATED Scalar Trace() const { return trace(); }
175 
176 /*! \deprecated use ostream << *this or even ostream << *this.withFormat(...) */
Dump()177 EIGEN_DEPRECATED void Dump()
178 {
179 	unsigned int i, j;
180 	for (i=0; i<rows(); ++i)
181 	{
182 		printf("[\t");
183 		for (j=0; j<cols(); j++)
184 			printf("%f\t", coeff(i,j));
185 		printf("]\n");
186 	}
187 	printf("\n");
188 }
189 
190 /** \deprecated use norm() */
Norm()191 EIGEN_DEPRECATED inline Scalar Norm() const { return norm(); };
192 /** \deprecated use squaredNorm() */
SquaredNorm()193 EIGEN_DEPRECATED inline Scalar SquaredNorm() const { return squaredNorm(); };
194 /** \deprecated use normalize() or normalized() */
Normalize()195 EIGEN_DEPRECATED inline Derived& Normalize() { normalize(); return derived(); };
196 /** \deprecated use normalized() */
Normalize()197 EIGEN_DEPRECATED inline const PlainMatrixType Normalize() const { return normalized(); };
198 
199 /** \deprecated use transposeInPlace() or transpose() */
Transpose()200 EIGEN_DEPRECATED inline Derived& Transpose() { transposeInPlace(); return derived(); };
201 /** \deprecated use transpose() */
Transpose()202 EIGEN_DEPRECATED inline const Eigen::Transpose<Derived> Transpose() const { return transpose(); };
203 
204 /** \deprecated use .cross(p) */
205 EIGEN_DEPRECATED inline PlainMatrixType operator ^ (const Derived& p ) const { return this->cross(p); }
206 
207 /// Homogeneous normalization (division by W)
HomoNormalize()208 inline Derived& HomoNormalize()
209 {
210 	EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
211 	enum {
212 	 SubRows = (int(Flags)&RowMajorBit) ? 1 : (RowsAtCompileTime==Dynamic ? Dynamic : RowsAtCompileTime-1),
213 	 SubCols = (int(Flags)&RowMajorBit) ? (ColsAtCompileTime==Dynamic ? Dynamic : ColsAtCompileTime-1) : 1,
214 	};
215 	Scalar& last = coeffRef(size()-2);
216 	if (last!=Scalar(0))
217 	{
218 		Block<Derived,SubRows,SubCols>(derived(),0,0,
219 			(int(Flags)&RowMajorBit) ? size()-1 : 1,
220 			(int(Flags)&RowMajorBit) ? 1 : (size()-1)) / last;
221 		last = Scalar(1.0);
222 	}
223 	return *this;
224 }
225 
HomoNormalize()226 inline const PlainMatrixType HomoNormalize() const
227 {
228 	PlainMatrixType res = derived();
229 	return res.HomoNormalize();
230 }
231 
232 /// norm infinity: largest absolute value of compoenet
NormInfinity()233 EIGEN_DEPRECATED inline Scalar NormInfinity() const { return derived().cwise().abs().maxCoeff(); }
234 /// norm 1: sum of absolute values of components
NormOne()235 EIGEN_DEPRECATED inline Scalar NormOne() const { return derived().cwise().abs().sum(); }
236 
237 
238 /// the sum of the components
Sum()239 EIGEN_DEPRECATED inline Scalar Sum() const { return sum(); }
240 /// returns the biggest component
Max()241 EIGEN_DEPRECATED inline Scalar Max() const { return maxCoeff(); }
242 /// returns the smallest component
Min()243 EIGEN_DEPRECATED inline Scalar Min() const { return minCoeff(); }
244 /// returns the index of the biggest component
MaxI()245 EIGEN_DEPRECATED inline int MaxI() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); int i; maxCoeff(&i,0); return i; }
246 /// returns the index of the smallest component
MinI()247 EIGEN_DEPRECATED inline int MinI() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); int i; minCoeff(&i,0); return i; }
248 
249 
250 /// Padding function: give a default 0 value to all the elements that are not in the [0..2] range.
251 /// Useful for managing in a consistent way object that could have point2 / point3 / point4
Ext(const int i)252 inline Scalar Ext( const int i ) const
253 {
254 	EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
255 	EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
256 
257 	if(i>=0 && i<SizeAtCompileTime)
258 		return coeff(i);
259 	else
260 		return Scalar(0);
261 }
262 
263 
264 /// Per component scaling
265 template<typename OtherDerived>
Scale(const MatrixBase<OtherDerived> & other)266 EIGEN_DEPRECATED inline Derived& Scale(const MatrixBase<OtherDerived>& other)
267 { this->cwise() *= other; return derived; }
268 
269 template<typename OtherDerived>
270 EIGEN_DEPRECATED inline
271 CwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived, OtherDerived>
Scale(const MatrixBase<OtherDerived> & other)272 Scale(const MatrixBase<OtherDerived>& other) const
273 { return this->cwise() * other; }
274 
275 
276 template<typename OtherDerived>
277 EIGEN_DEPRECATED inline bool operator <  (const MatrixBase<OtherDerived>& other) const {
278 	EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
279 	EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived);
280 	return ei_lexi_comparison<Derived,OtherDerived,SizeAtCompileTime>::less(derived(),other.derived());
281 }
282 
283 template<typename OtherDerived>
284 EIGEN_DEPRECATED inline bool operator >  (const MatrixBase<OtherDerived>& other) const {
285 	EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
286 	EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived);
287 	return ei_lexi_comparison<Derived,OtherDerived,SizeAtCompileTime>::geater(derived(),other.derived());
288 }
289 
290 template<typename OtherDerived>
291 EIGEN_DEPRECATED inline bool operator <=  (const MatrixBase<OtherDerived>& other) const {
292 	EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
293 	EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived);
294 	return ei_lexi_comparison<Derived,OtherDerived,SizeAtCompileTime>::lessEqual(derived(),other.derived());
295 }
296 
297 template<typename OtherDerived>
298 EIGEN_DEPRECATED inline bool operator >=  (const MatrixBase<OtherDerived>& other) const {
299 	EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
300 	EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived);
301 	return ei_lexi_comparison<Derived,OtherDerived,SizeAtCompileTime>::greaterEqual(derived(),other.derived());
302 }
303