mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 02:33:59 +08:00
Silenced type conversion warnings.
This commit is contained in:
parent
05837be8fb
commit
1a77334d54
@ -50,8 +50,8 @@ template<typename VectorType>
|
|||||||
void testVectorType(const VectorType& base)
|
void testVectorType(const VectorType& base)
|
||||||
{
|
{
|
||||||
typedef typename ei_traits<VectorType>::Scalar Scalar;
|
typedef typename ei_traits<VectorType>::Scalar Scalar;
|
||||||
Scalar low = ei_random(-500,500);
|
Scalar low = ei_random<Scalar>(-500,500);
|
||||||
Scalar high = ei_random(-500,500);
|
Scalar high = ei_random<Scalar>(-500,500);
|
||||||
if (low>high) std::swap(low,high);
|
if (low>high) std::swap(low,high);
|
||||||
const int size = base.size();
|
const int size = base.size();
|
||||||
const Scalar step = (high-low)/(size-1);
|
const Scalar step = (high-low)/(size-1);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
template<typename MatrixType> void matrixRedux(const MatrixType& m)
|
template<typename MatrixType> void matrixRedux(const MatrixType& m)
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename MatrixType::RealScalar RealScalar;
|
||||||
|
|
||||||
int rows = m.rows();
|
int rows = m.rows();
|
||||||
int cols = m.cols();
|
int cols = m.cols();
|
||||||
@ -44,7 +45,7 @@ template<typename MatrixType> void matrixRedux(const MatrixType& m)
|
|||||||
minc = std::min(ei_real(minc), ei_real(m1(i,j)));
|
minc = std::min(ei_real(minc), ei_real(m1(i,j)));
|
||||||
maxc = std::max(ei_real(maxc), ei_real(m1(i,j)));
|
maxc = std::max(ei_real(maxc), ei_real(m1(i,j)));
|
||||||
}
|
}
|
||||||
const Scalar mean = s/Scalar(rows*cols);
|
const Scalar mean = s/Scalar(RealScalar(rows*cols));
|
||||||
|
|
||||||
VERIFY_IS_APPROX(m1.sum(), s);
|
VERIFY_IS_APPROX(m1.sum(), s);
|
||||||
VERIFY_IS_APPROX(m1.mean(), mean);
|
VERIFY_IS_APPROX(m1.mean(), mean);
|
||||||
|
@ -187,7 +187,7 @@ class FFT
|
|||||||
{
|
{
|
||||||
m_impl.inv( dst,src,nfft );
|
m_impl.inv( dst,src,nfft );
|
||||||
if ( HasFlag( Unscaled ) == false)
|
if ( HasFlag( Unscaled ) == false)
|
||||||
scale(dst,1./nfft,nfft);
|
scale(dst,_Scalar(1./nfft),nfft);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@ -237,8 +237,14 @@ class FFT
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
template <typename _It,typename _Val>
|
template <typename _It,typename _Val>
|
||||||
inline
|
inline void scale(_It x,_Val s,int nx)
|
||||||
void scale(_It x,_Val s,int nx)
|
{
|
||||||
|
for (int k=0;k<nx;++k)
|
||||||
|
*x++ *= _Scalar(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename _Val>
|
||||||
|
inline void scale(std::complex<_Val>* x,_Val s,int nx)
|
||||||
{
|
{
|
||||||
for (int k=0;k<nx;++k)
|
for (int k=0;k<nx;++k)
|
||||||
*x++ *= s;
|
*x++ *= s;
|
||||||
|
@ -85,7 +85,7 @@ MatrixType MatrixFunctionAtomic<MatrixType>::compute(const MatrixType& A)
|
|||||||
{
|
{
|
||||||
// TODO: Use that A is upper triangular
|
// TODO: Use that A is upper triangular
|
||||||
m_Arows = A.rows();
|
m_Arows = A.rows();
|
||||||
m_avgEival = A.trace() / Scalar(m_Arows);
|
m_avgEival = A.trace() / Scalar(RealScalar(m_Arows));
|
||||||
m_Ashifted = A - m_avgEival * MatrixType::Identity(m_Arows, m_Arows);
|
m_Ashifted = A - m_avgEival * MatrixType::Identity(m_Arows, m_Arows);
|
||||||
computeMu();
|
computeMu();
|
||||||
MatrixType F = m_f(m_avgEival, 0) * MatrixType::Identity(m_Arows, m_Arows);
|
MatrixType F = m_f(m_avgEival, 0) * MatrixType::Identity(m_Arows, m_Arows);
|
||||||
@ -94,7 +94,7 @@ MatrixType MatrixFunctionAtomic<MatrixType>::compute(const MatrixType& A)
|
|||||||
for (int s = 1; s < 1.1 * m_Arows + 10; s++) { // upper limit is fairly arbitrary
|
for (int s = 1; s < 1.1 * m_Arows + 10; s++) { // upper limit is fairly arbitrary
|
||||||
Fincr = m_f(m_avgEival, s) * P;
|
Fincr = m_f(m_avgEival, s) * P;
|
||||||
F += Fincr;
|
F += Fincr;
|
||||||
P = (1/(s + 1.0)) * P * m_Ashifted;
|
P = Scalar(RealScalar(1.0/(s + 1))) * P * m_Ashifted;
|
||||||
if (taylorConverged(s, F, Fincr, P)) {
|
if (taylorConverged(s, F, Fincr, P)) {
|
||||||
return F;
|
return F;
|
||||||
}
|
}
|
||||||
@ -127,9 +127,9 @@ bool MatrixFunctionAtomic<MatrixType>::taylorConverged(int s, const MatrixType&
|
|||||||
for (int r = 0; r < n; r++) {
|
for (int r = 0; r < n; r++) {
|
||||||
RealScalar mx = 0;
|
RealScalar mx = 0;
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
mx = std::max(mx, std::abs(m_f(m_Ashifted(i, i) + m_avgEival, s+r)));
|
mx = std::max(mx, std::abs(m_f(m_Ashifted(i, i) + m_avgEival, s+r)));
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
rfactorial *= r;
|
rfactorial *= RealScalar(r);
|
||||||
delta = std::max(delta, mx / rfactorial);
|
delta = std::max(delta, mx / rfactorial);
|
||||||
}
|
}
|
||||||
const RealScalar P_norm = P.cwiseAbs().rowwise().sum().maxCoeff();
|
const RealScalar P_norm = P.cwiseAbs().rowwise().sum().maxCoeff();
|
||||||
|
@ -46,10 +46,10 @@ complex<long double> promote(long double x) { return complex<long double>( x);
|
|||||||
long double difpower=0;
|
long double difpower=0;
|
||||||
cerr <<"idx\ttruth\t\tvalue\t|dif|=\n";
|
cerr <<"idx\ttruth\t\tvalue\t|dif|=\n";
|
||||||
long double pi = acos((long double)-1);
|
long double pi = acos((long double)-1);
|
||||||
for (int k0=0;k0<fftbuf.size();++k0) {
|
for (int k0=0;k0<static_cast<int>(fftbuf.size());++k0) {
|
||||||
complex<long double> acc = 0;
|
complex<long double> acc = 0;
|
||||||
long double phinc = -2.*k0* pi / timebuf.size();
|
long double phinc = -2.*k0* pi / timebuf.size();
|
||||||
for (int k1=0;k1<timebuf.size();++k1) {
|
for (int k1=0;k1<static_cast<int>(timebuf.size());++k1) {
|
||||||
acc += promote( timebuf[k1] ) * exp( complex<long double>(0,k1*phinc) );
|
acc += promote( timebuf[k1] ) * exp( complex<long double>(0,k1*phinc) );
|
||||||
}
|
}
|
||||||
totalpower += norm(acc);
|
totalpower += norm(acc);
|
||||||
|
@ -33,14 +33,15 @@ template<typename MatrixType>
|
|||||||
MatrixType createRandomMatrix(const int size)
|
MatrixType createRandomMatrix(const int size)
|
||||||
{
|
{
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
typedef typename MatrixType::RealScalar RealScalar;
|
||||||
MatrixType result;
|
MatrixType result;
|
||||||
if (ei_random<int>(0,1) == 0) {
|
if (ei_random<int>(0,1) == 0) {
|
||||||
result = MatrixType::Random(size, size);
|
result = MatrixType::Random(size, size);
|
||||||
} else {
|
} else {
|
||||||
MatrixType diag = MatrixType::Zero(size, size);
|
MatrixType diag = MatrixType::Zero(size, size);
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
diag(i, i) = static_cast<Scalar>(ei_random<int>(0,2))
|
diag(i, i) = Scalar(RealScalar(ei_random<int>(0,2)))
|
||||||
+ ei_random<Scalar>() * static_cast<Scalar>(0.01);
|
+ ei_random<Scalar>() * Scalar(RealScalar(0.01));
|
||||||
}
|
}
|
||||||
MatrixType A = MatrixType::Random(size, size);
|
MatrixType A = MatrixType::Random(size, size);
|
||||||
result = A.inverse() * diag * A;
|
result = A.inverse() * diag * A;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user