17 return v.stableNorm();
59 Scalar
s = v.array().abs().maxCoeff();
60 return s*(v/
s).norm();
66 return v.stableNorm();
87 #ifdef EIGEN_VECTORIZE 100 #ifndef EIGEN_VECTORIZE 106 static Scalar
b1,
b2, s1m, s2m, overfl, rbig,
relerr;
111 int nbig, ibeta, it, iemin, iemax, iexp;
116 it = std::numeric_limits<Scalar>::digits;
117 iemin = std::numeric_limits<Scalar>::min_exponent;
118 iemax = std::numeric_limits<Scalar>::max_exponent;
122 if(iemin > 1 - 2*it || 1+it>iemax || (it==2 && ibeta<5)
123 || (it<=4 && ibeta <= 3 ) || it<2)
125 eigen_assert(
false &&
"the algorithm cannot be guaranteed on this computer");
127 iexp = -((1-iemin)/2);
129 iexp = (iemax + 1 - it)/2;
134 iexp = - ((iemax+it)/2);
140 abig = 1.0/eps - 1.0;
141 if (
Scalar(nbig)>abig) nmax = abig;
147 Packet pasml = internal::pset1<Packet>(
Scalar(0));
148 Packet pamed = internal::pset1<Packet>(
Scalar(0));
149 Packet pabig = internal::pset1<Packet>(
Scalar(0));
150 Packet ps2m = internal::pset1<Packet>(s2m);
151 Packet ps1m = internal::pset1<Packet>(s1m);
152 Packet pb2 = internal::pset1<Packet>(
b2);
153 Packet pb1 = internal::pset1<Packet>(
b1);
154 for(
int j=0;
j<v.size();
j+=
ps)
159 Packet maskBig = internal::plt(pb2,ax);
160 Packet maskSml = internal::plt(ax,pb1);
218 if(asml <= abig*relerr)
225 #define BENCH_PERF(NRM) { \ 226 float af = 0; double ad = 0; std::complex<float> ac = 0; \ 227 Eigen::BenchTimer tf, td, tcf; tf.reset(); td.reset(); tcf.reset();\ 228 for (int k=0; k<tries; ++k) { \ 230 for (int i=0; i<iters; ++i) { af += NRM(vf); } \ 233 for (int k=0; k<tries; ++k) { \ 235 for (int i=0; i<iters; ++i) { ad += NRM(vd); } \ 243 std::cout << #NRM << "\t" << tf.value() << " " << td.value() << " " << tcf.value() << "\n"; \ 248 double yf = basef *
std::abs(internal::random<double>());
249 double yd = based *
std::abs(internal::random<double>());
250 VectorXf vf = VectorXf::Ones(s) * yf;
251 VectorXd vd = VectorXd::Ones(s) * yd;
253 std::cout <<
"reference\t" <<
std::sqrt(
double(s))*yf <<
"\t" <<
std::sqrt(
double(s))*yd <<
"\n";
267 for (
int i=0;
i<
s; ++
i)
269 vf[
i] =
std::abs(internal::random<double>()) *
std::pow(
double(10), internal::random<int>(ef0,ef1));
270 vd[
i] =
std::abs(internal::random<double>()) *
std::pow(
double(10), internal::random<int>(ed0,ed1));
276 std::cout <<
"blueNorm\t" <<
blueNorm(vf) <<
"\t" <<
blueNorm(vd) <<
"\t" <<
blueNorm(vf.cast<
long double>()) <<
"\t" <<
blueNorm(vd.cast<
long double>()) <<
"\n";
283 int main(
int argc,
char** argv)
287 double y = 1.1345743233455785456788e12 * internal::random<double>();
288 VectorXf
v = VectorXf::Ones(1024) *
y;
292 double basef_ok = 1.1345743233455785456788e15;
293 double based_ok = 1.1345743233455785456788e95;
295 double basef_under = 1.1345743233455785456788e-27;
296 double based_under = 1.1345743233455785456788e-303;
298 double basef_over = 1.1345743233455785456788e+27;
299 double based_over = 1.1345743233455785456788e+302;
301 std::cout.precision(20);
303 std::cerr <<
"\nNo under/overflow:\n";
306 std::cerr <<
"\nUnderflow:\n";
309 std::cerr <<
"\nOverflow:\n";
312 std::cerr <<
"\nVarying (over):\n";
313 for (
int k=0; k<1; ++k)
319 std::cerr <<
"\nVarying (under):\n";
320 for (
int k=0; k<1; ++k)
327 std::cout.precision(4);
328 int s1 = 1024*1024*32;
329 std::cerr <<
"Performance (out of cache, " << s1 <<
"):\n";
332 VectorXf vf = VectorXf::Random(s1) *
y;
333 VectorXd vd = VectorXd::Random(s1) *
y;
334 VectorXcf vcf = VectorXcf::Random(s1) *
y;
345 std::cerr <<
"\nPerformance (in cache, " << 512 <<
"):\n";
348 VectorXf vf = VectorXf::Random(512) *
y;
349 VectorXd vd = VectorXd::Random(512) *
y;
350 VectorXcf vcf = VectorXcf::Random(512) *
y;
internal::packet_traits< Scalar >::type Packet
void check_accuracy_var(int ef0, int ef1, int ed0, int ed1, int s)
EIGEN_DONT_INLINE T::Scalar twopassNorm(T &v)
EIGEN_DONT_INLINE T::Scalar pblueNorm(const T &v)
EIGEN_DONT_INLINE T::Scalar hypotNorm(T &v)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux(const Packet &a)
Derived::RealScalar relerr(const MatrixBase< Derived > &A, const MatrixBase< OtherDerived > &B)
int RealScalar int RealScalar int RealScalar RealScalar * ps
#define EIGEN_DONT_INLINE
EIGEN_DEVICE_FUNC Packet padd(const Packet &a, const Packet &b)
EIGEN_DONT_INLINE T::Scalar divacNorm(T &v)
EIGEN_DONT_INLINE T::Scalar bl2passNorm(T &v)
EIGEN_DONT_INLINE T::Scalar lapackNorm(T &v)
EIGEN_DONT_INLINE T::Scalar sqsumNorm(T &v)
EIGEN_DONT_INLINE T::Scalar stableNorm(T &v)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
int main(int argc, char **argv)
EIGEN_DEVICE_FUNC Packet pandnot(const Packet &a, const Packet &b)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics scale
void check_accuracy(double basef, double based, int s)
EIGEN_DONT_INLINE T::Scalar blueNorm(T &v)
Jet< T, N > pow(const Jet< T, N > &f, double g)
EIGEN_DEVICE_FUNC Packet pmul(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC Packet pand(const Packet &a, const Packet &b)
EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f &a)