mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 04:05:19 +08:00
* fix a couple of warnings (patch from Armin Berres)
* allow Map to map null data
This commit is contained in:
parent
5015e48361
commit
1ed17b037d
@ -6,12 +6,12 @@
|
|||||||
//
|
//
|
||||||
// Eigen is free software; you can redistribute it and/or
|
// Eigen is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
// License as published by the Free Software Foundation; either
|
// License as published by the Free Software Foundation; either
|
||||||
// version 3 of the License, or (at your option) any later version.
|
// version 3 of the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Alternatively, you can redistribute it and/or
|
// Alternatively, you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License as
|
// modify it under the terms of the GNU General Public License as
|
||||||
// published by the Free Software Foundation; either version 2 of
|
// published by the Free Software Foundation; either version 2 of
|
||||||
// the License, or (at your option) any later version.
|
// the License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
@ -19,7 +19,7 @@
|
|||||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ struct IOFormat
|
|||||||
coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags)
|
coeffSeparator(_coeffSeparator), precision(_precision), flags(_flags)
|
||||||
{
|
{
|
||||||
rowSpacer = "";
|
rowSpacer = "";
|
||||||
int i=matSuffix.length()-1;
|
int i = int(matSuffix.length())-1;
|
||||||
while (i>=0 && matSuffix[i]!='\n')
|
while (i>=0 && matSuffix[i]!='\n')
|
||||||
{
|
{
|
||||||
rowSpacer += ' ';
|
rowSpacer += ' ';
|
||||||
@ -81,7 +81,7 @@ struct IOFormat
|
|||||||
* This class represents an expression with stream operators controlled by a given IOFormat.
|
* This class represents an expression with stream operators controlled by a given IOFormat.
|
||||||
* It is the return type of MatrixBase::format()
|
* It is the return type of MatrixBase::format()
|
||||||
* and most of the time this is the only way it is used.
|
* and most of the time this is the only way it is used.
|
||||||
*
|
*
|
||||||
* See class IOFormat for some examples.
|
* See class IOFormat for some examples.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::format(), class IOFormat
|
* \sa MatrixBase::format(), class IOFormat
|
||||||
@ -135,7 +135,7 @@ std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase<Derived> & _m,
|
|||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr.precision(fmt.precision);
|
sstr.precision(fmt.precision);
|
||||||
sstr << m.coeff(i,j);
|
sstr << m.coeff(i,j);
|
||||||
width = std::max<int>(width, sstr.str().length());
|
width = std::max<int>(width, int(sstr.str().length()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.precision(fmt.precision);
|
s.precision(fmt.precision);
|
||||||
|
@ -53,7 +53,7 @@ template<typename Derived> class MapBase
|
|||||||
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
|
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
|
||||||
SizeAtCompileTime = Base::SizeAtCompileTime
|
SizeAtCompileTime = Base::SizeAtCompileTime
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef typename ei_traits<Derived>::AlignedDerivedType AlignedDerivedType;
|
typedef typename ei_traits<Derived>::AlignedDerivedType AlignedDerivedType;
|
||||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||||
typedef typename Base::PacketScalar PacketScalar;
|
typedef typename Base::PacketScalar PacketScalar;
|
||||||
@ -83,7 +83,7 @@ template<typename Derived> class MapBase
|
|||||||
else // column-major
|
else // column-major
|
||||||
return const_cast<Scalar*>(m_data)[row + col * stride()];
|
return const_cast<Scalar*>(m_data)[row + col * stride()];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Scalar coeff(int index) const
|
inline const Scalar coeff(int index) const
|
||||||
{
|
{
|
||||||
ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
|
ei_assert(Derived::IsVectorAtCompileTime || (ei_traits<Derived>::Flags & LinearAccessBit));
|
||||||
@ -138,28 +138,29 @@ template<typename Derived> class MapBase
|
|||||||
m_cols(ColsAtCompileTime == Dynamic ? size : ColsAtCompileTime)
|
m_cols(ColsAtCompileTime == Dynamic ? size : ColsAtCompileTime)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||||
ei_assert(size > 0);
|
ei_assert(size > 0 || data == 0);
|
||||||
ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size);
|
ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline MapBase(const Scalar* data, int rows, int cols)
|
inline MapBase(const Scalar* data, int rows, int cols)
|
||||||
: m_data(data), m_rows(rows), m_cols(cols)
|
: m_data(data), m_rows(rows), m_cols(cols)
|
||||||
{
|
{
|
||||||
ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
|
ei_assert( (data == 0)
|
||||||
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
|
|| ( rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
|
||||||
|
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator+=(const MatrixBase<OtherDerived>& other)
|
Derived& operator+=(const MatrixBase<OtherDerived>& other)
|
||||||
{ return derived() = forceAligned() + other; }
|
{ return derived() = forceAligned() + other; }
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator-=(const MatrixBase<OtherDerived>& other)
|
Derived& operator-=(const MatrixBase<OtherDerived>& other)
|
||||||
{ return derived() = forceAligned() - other; }
|
{ return derived() = forceAligned() - other; }
|
||||||
|
|
||||||
Derived& operator*=(const Scalar& other)
|
Derived& operator*=(const Scalar& other)
|
||||||
{ return derived() = forceAligned() * other; }
|
{ return derived() = forceAligned() * other; }
|
||||||
|
|
||||||
Derived& operator/=(const Scalar& other)
|
Derived& operator/=(const Scalar& other)
|
||||||
{ return derived() = forceAligned() / other; }
|
{ return derived() = forceAligned() / other; }
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ inline int ei_sin(int) { ei_assert(false); return 0; }
|
|||||||
inline int ei_cos(int) { ei_assert(false); return 0; }
|
inline int ei_cos(int) { ei_assert(false); return 0; }
|
||||||
|
|
||||||
#if EIGEN_GNUC_AT_LEAST(4,3)
|
#if EIGEN_GNUC_AT_LEAST(4,3)
|
||||||
inline int ei_pow(int x, int y) { return std::pow(x, y); }
|
inline int ei_pow(int x, int y) { return int(std::pow(x, y)); }
|
||||||
#else
|
#else
|
||||||
inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); }
|
inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); }
|
||||||
#endif
|
#endif
|
||||||
@ -103,7 +103,7 @@ template<> inline float ei_random(float a, float b)
|
|||||||
} while(i==0);
|
} while(i==0);
|
||||||
return i/256.f;
|
return i/256.f;
|
||||||
#else
|
#else
|
||||||
return a + (b-a) * std::rand() / RAND_MAX;
|
return a + (b-a) * float(std::rand()) / float(RAND_MAX);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
template<> inline float ei_random()
|
template<> inline float ei_random()
|
||||||
@ -254,7 +254,7 @@ inline long double ei_pow(long double x, long double y) { return std::pow(x, y)
|
|||||||
|
|
||||||
template<> inline long double ei_random(long double a, long double b)
|
template<> inline long double ei_random(long double a, long double b)
|
||||||
{
|
{
|
||||||
return ei_random<double>(a,b);
|
return static_cast<long double>(ei_random<double>(a,b));
|
||||||
}
|
}
|
||||||
template<> inline long double ei_random()
|
template<> inline long double ei_random()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user