Commit a49eca79 by snuverink_j

### remove loading std functions into global namespace in headers

parent c46e953c
 ... ... @@ -23,6 +23,7 @@ #include "Algebra/Array1D.h" #include "FixedAlgebra/FMatrix.h" #include "FixedAlgebra/FTps.h" #include template class FLieGenerator; ... ... @@ -432,7 +433,7 @@ factorBerzForestIrwin(const FTps &HH) { FMatrix M = makeMatrix(H_2); // Eigenvalues and eigenvectors of M. FVector, 2 * N> mu; // eigenvalues FVector, 2 * N> mu; // eigenvalues FMatrix V; // eigenvectors FMatrix V_inv; // inverse of V { ... ... @@ -473,10 +474,10 @@ factorBerzForestIrwin(const FTps &HH) { R_inv(i + 1, i) = + 1.0; R_inv(i + 1, i + 1) = - 1.0; if(std::abs(imag(mu[i])) > tol) { if(std::abs(std::imag(mu[i])) > tol) { // "stable" eigenvalue pair. double c = cos(imag(mu[i])); double s = sin(imag(mu[i])); double c = std::cos(std::imag(mu[i])); double s = std::sin(std::imag(mu[i])); Rot(i, i) = + c; Rot(i, i + 1) = + s; Rot(i + 1, i) = - s; ... ... @@ -485,8 +486,8 @@ factorBerzForestIrwin(const FTps &HH) { I_dir(i + 1, i) = 1.0; } else { // "unstable" eigenvalue pair. double ch = cosh(real(mu[i])); double sh = sinh(real(mu[i])); double ch = std::cosh(std::real(mu[i])); double sh = std::sinh(std::real(mu[i])); Rot(i, i) = + ch; Rot(i, i + 1) = - sh; Rot(i + 1, i) = - sh; ... ... @@ -515,22 +516,22 @@ factorBerzForestIrwin(const FTps &HH) { for(int m = f.getBottomIndex(); m < f.getTopIndex(); m++) { const FMonomial<2 * N> &index = FTpsData<2 * N>::getExponents(m); complex factor = 0.0; std::complex factor = 0.0; int count = 0; for(int j = 0; j < 2 * modes; j += 2) { if(std::abs(imag(mu[j])) > tol) count += index[j+1]; if(std::abs(std::imag(mu[j])) > tol) count += index[j+1]; factor += double(index[j]) * mu[j] + double(index[j+1]) * mu[j+1]; } if(std::abs(factor) > tol) { // Term can be removed. factor = 1.0 / factor; a[m] = real(factor); b[m] = imag(factor); a[m] = std::real(factor); b[m] = std::imag(factor); } pi[m] = pow(- 1.0, (count + 1) / 2); pi[m] = std::pow(- 1.0, (count + 1) / 2); } // Compute cal_T^(-1) * f. ... ... @@ -1084,7 +1085,7 @@ catenateZero(const DragtFinnMap &g) const { h.assign(g_mat * f_mat); // Extract the generators. int order = max(getOrder(), g.getOrder()); int order = std::max(getOrder(), g.getOrder()); FMatrix g_inv = FLUMatrix(g_mat).inverse(); FTps f_gen = itsGenerators.filter(2, itsGenerators.getMaxOrder()).substitute(g_inv) ... ... @@ -1355,12 +1356,12 @@ move_g_1(DragtFinnMap &f, DragtFinnMap &g) { template int DragtFinnMap:: orderModes(FMatrix &V, FVector, 2 * N> &mu) { orderModes(FMatrix &V, FVector, 2 * N> &mu) { // Static constant. static const double tol = 1.0e-12; FMatrix tmat(V); FVector, 2 * N> tmu(mu); FVector, 2 * N> tmu(mu); int nDim = 2 * N; int n_c = 0; int n_r = 0; ... ... @@ -1373,7 +1374,7 @@ orderModes(FMatrix &V, FVector, 2 * N> &mu for(int j = 0; j < 2 * N; ++j) V(j, nDim) = 0.0; V(nDim, nDim) = 1.0; i++; } else if(std::abs(imag(tmu[i])) < tol) { } else if(std::abs(std::imag(tmu[i])) < tol) { // Collect "unstable" modes in lower indices of tmat. if(n_r != i) { tmu[n_r] = tmu[i]; ... ... @@ -1417,14 +1418,14 @@ orderModes(FMatrix &V, FVector, 2 * N> &mu // Swap values to make pair. if(m != i + 1) { swap(tmu[m], tmu[i+1]); std::swap(tmu[m], tmu[i+1]); tmat.swapColumns(m, i + 1); } // Take positive eigenvalue first. int i1 = i; int i2 = i; if(real(tmu[i]) > 0.0) { if(std::real(tmu[i]) > 0.0) { ++i2; } else { ++i1; ... ... @@ -1466,8 +1467,8 @@ orderModes(FMatrix &V, FVector, 2 * N> &mu if(k != i) { // Move eigenvector pair to its place. swap(mu[i], mu[k]); swap(mu[i+1], mu[k+1]); std::swap(mu[i], mu[k]); std::swap(mu[i+1], mu[k+1]); V.swapColumns(i, k); V.swapColumns(i + 1, k + 1); } ... ...
 ... ... @@ -24,14 +24,6 @@ #include #include using std::complex; using std::abs; using std::arg; using std::imag; using std::pow; using std::real; using std::swap; template class DragtFinnMap; template class FLieGenerator; template class FMatrix; ... ... @@ -77,7 +69,7 @@ public: const DragtFinnMap &normalisingMap() const; /// Get eigenvalues of the linear part as a complex vector. const FVector, 2 * N> &eigenValues() const; const FVector, 2 * N> &eigenValues() const; /// Get eigenvectors of the linear part in packed form. const FMatrix &eigenVectors() const; ... ... @@ -91,7 +83,7 @@ public: protected: // Order the modes of the map and associate them to the planes. void orderModes(FVector, 2 * N>, FMatrix); void orderModes(FVector, 2 * N>, FMatrix); private: ... ... @@ -110,7 +102,7 @@ private: DragtFinnMap N_scr; // The vector of eigenvalues. FVector, 2 * N> lambda; FVector, 2 * N> lambda; // The matrix of eigenvectors. FMatrix V; ... ... @@ -175,18 +167,18 @@ DragtFinnNormalForm::DragtFinnNormalForm(const DragtFinnMap &map): R_inv(i, i) = R_inv(i, i + 1) = R_inv(i + 1, i) = 1.0; R_inv(i + 1, i + 1) = -1.0; if(std::abs(imag(lambda[i])) > tol) { if(std::abs(std::imag(lambda[i])) > tol) { // Complex eigenvalue pair. Rot(i, i) = Rot(i + 1, i + 1) = real(lambda[i]); Rot(i, i + 1) = imag(lambda[i]); Rot(i + 1, i) = - imag(lambda[i]); Rot(i, i) = Rot(i + 1, i + 1) = std::real(lambda[i]); Rot(i, i + 1) = std::imag(lambda[i]); Rot(i + 1, i) = - std::imag(lambda[i]); I_dir(i, i) = I_dir(i + 1, i + 1) = 0.0; I_dir(i, i + 1) = I_dir(i + 1, i) = 1.0; } else { // Real eigenvalue pair. Rot(i, i) = Rot(i + 1, i + 1) = real(lambda[i] + lambda[i+1]) * 0.5; Rot(i, i + 1) = Rot(i + 1, i) = real(lambda[i] - lambda[i+1]) * 0.5; Rot(i, i) = Rot(i + 1, i + 1) = std::real(lambda[i] + lambda[i+1]) * 0.5; Rot(i, i + 1) = Rot(i + 1, i) = std::real(lambda[i] - lambda[i+1]) * 0.5; } } ... ... @@ -210,12 +202,12 @@ DragtFinnNormalForm::DragtFinnNormalForm(const DragtFinnMap &map): for(int m = f.getBottomIndex(); m < f.getTopIndex(); ++m) { const FMonomial<2 * N> &index = FTpsData<2 * N>::getExponents(m); complex factor = 1.0; std::complex factor = 1.0; int count = 0; for(int j = 0; j < 2 * freedom; j += 2) { if(std::abs(imag(lambda[j])) > tol) count += index[j+1]; factor *= (pow(lambda[j], index[j]) * pow(lambda[j+1], index[j+1])); if(std::abs(std::imag(lambda[j])) > tol) count += index[j+1]; factor *= (std::pow(lambda[j], index[j]) * std::pow(lambda[j+1], index[j+1])); } if(std::abs(1.0 - factor) < tol) { ... ... @@ -224,11 +216,11 @@ DragtFinnNormalForm::DragtFinnNormalForm(const DragtFinnMap &map): } else { // Term can be removed. factor = 1.0 / (1.0 - factor); a[m] = real(factor); b[m] = imag(factor); a[m] = std::real(factor); b[m] = std::imag(factor); } pi[m] = pow(-1.0, int(count + 1) / 2); pi[m] = std::pow(-1.0, int(count + 1) / 2); } // Compute cal_T^(-1) * f and T_omega. ... ... @@ -299,7 +291,7 @@ FLieGenerator DragtFinnNormalForm::invariant(int mode) const { b[j+2] = V(j, 2 * mode + 1); } if(std::abs(imag(lambda[2*mode])) > tol) { if(std::abs(std::imag(lambda[2*mode])) > tol) { return (a * a + b * b); } else { return (a * a - b * b); ... ... @@ -320,7 +312,7 @@ const DragtFinnMap &DragtFinnNormalForm::normalisingMap() const { template const FVector, 2 * N> &DragtFinnNormalForm::eigenValues() const { const FVector, 2 * N> &DragtFinnNormalForm::eigenValues() const { return lambda; } ... ... @@ -333,7 +325,7 @@ const FMatrix &DragtFinnNormalForm::eigenVectors() cons template void DragtFinnNormalForm::orderModes (FVector, 2 * N> tlam, FMatrix tmat) { (FVector, 2 * N> tlam, FMatrix tmat) { // Static constant. int nDim = 2 * N; int n_c = 0; ... ... @@ -347,7 +339,7 @@ void DragtFinnNormalForm::orderModes std::fill(V.col_begin(nDim), V.col_end(nDim), 0.0); V(nDim, nDim) = 1.0; i++; } else if(std::abs(imag(tlam[i])) < tol) { } else if(std::abs(std::imag(tlam[i])) < tol) { // Collect "unstable" modes in lower indices of tmat. if(n_r != i) { tlam[n_r] = tlam[i]; ... ... @@ -399,7 +391,7 @@ void DragtFinnNormalForm::orderModes // Swap values to make pair. if(m != i + 1) { swap(tlam[m], tlam[i+1]); std::swap(tlam[m], tlam[i+1]); tmat.swapColumns(m, i + 1); } ... ... @@ -453,21 +445,21 @@ void DragtFinnNormalForm::orderModes if(k != i) { // Move eigenvector pair to its place. swap(lambda[i], lambda[k]); swap(lambda[i+1], lambda[k+1]); std::swap(lambda[i], lambda[k]); std::swap(lambda[i+1], lambda[k+1]); V.swapColumns(i, k); V.swapColumns(i + 1, k + 1); } if(std::abs(imag(lambda[i])) > tol) { if(std::abs(std::imag(lambda[i])) > tol) { // Rotate complex eigenvectors to make their main components real. double re = V(i, i) / sqrt(V(i, i) * V(i, i) + V(i, i + 1) * V(i, i + 1)); double re = V(i, i) / sqrt(V(i, i) * V(i, i) + V(i, i + 1) * V(i, i + 1)); double im = V(i, i + 1) / sqrt(V(i, i) * V(i, i) + V(i, i + 1) * V(i, i + 1)); for(int j = 0; j < 2 * N; j++) { double real_part = re * V(j, i) + im * V(j, i + 1); double real_part = re * V(j, i) + im * V(j, i + 1); double imag_part = re * V(j, i + 1) - im * V(j, i); V(j, i) = real_part; V(j, i) = real_part; V(j, i + 1) = imag_part; } } ... ...
 ... ... @@ -24,14 +24,6 @@ #include "FixedAlgebra/FVector.h" #include using std::complex; using std::abs; using std::imag; using std::max; using std::real; using std::swap; // Class FDoubleEigen // ------------------------------------------------------------------------ /// Eigenvalues and eigenvectors for a real general matrix. ... ... @@ -55,11 +47,11 @@ public: /// Get eigenvalues. // Return eigenvalues as a complex vector. FVector, N> eigenValues() const; FVector, N> eigenValues() const; /// Get eigenvectors. // Return eigenvectors as a complex matrix. FMatrix, N, N> eigenVectors() const; FMatrix, N, N> eigenVectors() const; /// Get eigenvectors. // Return eigenvectors packed in a real matrix. ... ... @@ -95,7 +87,7 @@ private: void balbak(int low, int high, double scale[N]); // Representation of the eigenvalues and eigenvectors. FVector, N> lambda; FVector, N> lambda; FMatrix vectors; }; ... ... @@ -188,7 +180,7 @@ FDoubleEigen::~FDoubleEigen() template FVector, N> FDoubleEigen::eigenValues() const FVector, N> FDoubleEigen::eigenValues() const // Return Eigenvalues as complex vector. { return lambda; ... ... @@ -196,22 +188,22 @@ FVector, N> FDoubleEigen::eigenValues() const template FMatrix, N, N> FDoubleEigen::eigenVectors() const FMatrix, N, N> FDoubleEigen::eigenVectors() const // Return eigenvectors as a complex matrix. { FMatrix, N, N> R; FMatrix, N, N> R; for(int i = 0; i < N; i++) { if(imag(lambda[i]) == 0.0) { if(std::imag(lambda[i]) == 0.0) { // One real eigenvector. for(int j = 0; j < N; j++) { R[j][i] = complex(vectors[j][i]); R[j][i] = std::complex(vectors[j][i]); } } else { // Two complex eigenvectors. for(int j = 0; j < N; j++) { R[j][i] = complex(vectors[j][i], + vectors[j][i+1]); R[j][i+1] = complex(vectors[j][i], - vectors[j][i+1]); R[j][i] = std::complex(vectors[j][i], + vectors[j][i+1]); R[j][i+1] = std::complex(vectors[j][i], - vectors[j][i+1]); } i++; } ... ... @@ -439,8 +431,8 @@ void FDoubleEigen::elmhes(FMatrix ©, int low, index[m] = i; if(i != m) { for(int j = m - 1; j < N; j++) swap(copy[i][j], copy[m][j]); for(int j = 0; j <= upp; j++) swap(copy[j][i], copy[j][m]); for(int j = m - 1; j < N; j++) std::swap(copy[i][j], copy[m][j]); for(int j = 0; j <= upp; j++) std::swap(copy[j][i], copy[j][m]); } if(x != 0.0) { ... ... @@ -508,8 +500,8 @@ template void FDoubleEigen::exchange(FMatrix ©, int j, int m, int low, int upp) { if(j != m) { for(int i = 0; i <= upp; i++) swap(copy[i][j], copy[i][m]); for(int i = low; i < N; i++) swap(copy[j][i], copy[m][i]); for(int i = 0; i <= upp; i++) std::swap(copy[i][j], copy[i][m]); for(int i = low; i < N; i++) std::swap(copy[j][i], copy[m][i]); } } ... ... @@ -550,8 +542,8 @@ int FDoubleEigen::hqr(FMatrix &h, int low, int upp) // while the j-th eigenvalue is being sought. { // Store roots isolated by "balance". for(int i = 0; i < low; i++) lambda[i] = complex(h[i][i]); for(int i = upp + 1; i < N; i++) lambda[i] = complex(h[i][i]); for(int i = 0; i < low; i++) lambda[i] = std::complex(h[i][i]); for(int i = upp + 1; i < N; i++) lambda[i] = std::complex(h[i][i]); // Compute matrix norm. double norm = 0.0; ... ... @@ -680,7 +672,7 @@ int FDoubleEigen::hqr(FMatrix &h, int low, int upp) } one_root: lambda[en] = complex(x + t); lambda[en] = std::complex(x + t); continue; two_roots: ... ... @@ -692,12 +684,12 @@ two_roots: if(q >= 0.0) { // Real pair. z = (p > 0.0) ? (p + z) : (p - z); lambda[en-1] = complex(x + z); lambda[en] = complex((z != 0.0) ? (x - w / z) : x + z); lambda[en-1] = std::complex(x + z); lambda[en] = std::complex((z != 0.0) ? (x - w / z) : x + z); } else { // Complex pair. lambda[en-1] = complex(x + p, + z); lambda[en] = complex(x + p, - z); lambda[en-1] = std::complex(x + p, + z); lambda[en] = std::complex(x + p, - z); } en--; ... ... @@ -759,8 +751,8 @@ int FDoubleEigen::hqr2(FMatrix &h, int low, int upp) double tst1, tst2; // Store roots isolated by "balance". for(int i = 0; i < low; i++) lambda[i] = complex(h[i][i]); for(int i = upp + 1; i < N; i++) lambda[i] = complex(h[i][i]); for(int i = 0; i < low; i++) lambda[i] = std::complex(h[i][i]); for(int i = upp + 1; i < N; i++) lambda[i] = std::complex(h[i][i]); // Compute matrix norm. double norm = 0.0; ... ... @@ -900,7 +892,7 @@ int FDoubleEigen::hqr2(FMatrix &h, int low, int upp) } one_root: lambda[en] = complex(h[en][en] = x + t); lambda[en] = std::complex(h[en][en] = x + t); continue; two_roots: ... ... @@ -945,8 +937,8 @@ two_roots: } } else { // Complex pair. lambda[en-1] = complex(x + p, + z); lambda[en] = complex(x + p, - z); lambda[en-1] = std::complex(x + p, + z); lambda[en] = std::complex(x + p, - z); } en--; ... ... @@ -957,8 +949,8 @@ two_roots: if(norm == 0.0) return 0; for(int en = N; en-- > 0;) { p = real(lambda[en]); q = imag(lambda[en]); p = std::real(lambda[en]); q = std::imag(lambda[en]); if(q < 0.0) { // Complex vector. ... ... @@ -988,21 +980,21 @@ two_roots: sa += h[i][j] * h[j][en]; } if(imag(lambda[i]) < 0.0) { if(std::imag(lambda[i]) < 0.0) { z = w; r = ra; s = sa; } else { m = i; if(imag(lambda[i]) == 0.0) { if(std::imag(lambda[i]) == 0.0) { cdiv(- ra, -sa, w, q, h[i][en-1], h[i][en]); } else { // Solve complex equations. x = h[i][i+1]; y = h[i+1][i]; double vr = (real(lambda[i]) - p) * (real(lambda[i]) - p) + imag(lambda[i]) * imag(lambda[i]) - q * q; double vi = real(lambda[i] - p) * 2.0 * q; double vr = (std::real(lambda[i]) - p) * (std::real(lambda[i]) - p) + std::imag(lambda[i]) * std::imag(lambda[i]) - q * q; double vi = std::real(lambda[i] - p) * 2.0 * q; if(vr == 0.0 && vi == 0.0) { tst1 = ... ... @@ -1028,7 +1020,7 @@ two_roots: } // Overflow control. t = max(std::abs(h[i][en-1]), std::abs(h[i][en])); t = std::max(std::abs(h[i][en-1]), std::abs(h[i][en])); if(t != 0.0 && (t + 1.0 / t) <= t) { for(int j = i; j <= en; j++) { ... ... @@ -1051,12 +1043,12 @@ two_roots: r = 0.0; for(int j = m; j <= en; j++) r += h[i][j] * h[j][en]; if(imag(lambda[i]) < 0.0) { if(std::imag(lambda[i]) < 0.0) { z = w; s = r; } else { m = i; if(imag(lambda[i]) == 0.0) { if(std::imag(lambda[i]) == 0.0) { t = w; if(t == 0.0) { t = tst1 = norm; ... ... @@ -1072,8 +1064,8 @@ two_roots: // Solve real equations. x = h[i][i+1]; y = h[i+1][i]; q = (real(lambda[i]) - p) * (real(lambda[i]) - p) + imag(lambda[i]) * imag(lambda[i]); q = (std::real(lambda[i]) - p) * (std::real(lambda[i]) - p) + std::imag(lambda[i]) * std::imag(lambda[i]); t = (x * s - z * r) / q; h[i][en] = t; h[i+1][en] = (std::abs(x) > std::abs(z)) ? ... ...
 ... ... @@ -25,14 +25,6 @@ #include #include using std::complex; using std::abs; using std::arg; using std::imag; using std::pow; using std::real; using std::swap; template class FMatrix; template class FTps; template class FVps; ... ... @@ -78,7 +70,7 @@ public: const FTps &normalisingMap() const; /// Get eigenvalues of the linear part as a complex vector. const FVector, N> &eigenValues() const; const FVector, N> &eigenValues() const; /// Get eigenvectors of the linear part in packed form. const FMatrix &eigenVectors() const; ... ... @@ -92,7 +84,7 @@ public: protected: // Order the modes of the map and associate them to the planes. void orderModes(FVector, N>, FMatrix); void orderModes(FVector, N>, FMatrix); private: ... ... @@ -111,7 +103,7 @@ private: FTps N_Lie; // The vector of eigenvalues. FVector, N> lambda; FVector, N> lambda; // The matrix of eigenvectors. FMatrix V; ... ... @@ -180,8 +172,8 @@ FNormalForm::FNormalForm(const FVps &M_scr): // Store linear part of normal form. double c1, c2; if(std::abs(imag(lambda[i])) > tol) { c1 = c2 = arg(lambda[i]) / 2.0; if(std::abs(std::imag(lambda[i])) > tol) { c1 = c2 = std::arg(lambda[i]) / 2.0; } else { c1 = log(std::abs(lambda[i])) / 2.0;