From 5277ea01f1f41db72868eb334e6aa7ea5e48e434 Mon Sep 17 00:00:00 2001 From: Olivier Coulaud <Olivier.Coulaud@inria.fr> Date: Tue, 12 Jun 2018 20:13:29 +0200 Subject: [PATCH] use real and imag functions --- Src/Kernels/Rotation/FRotationKernel.hpp | 30 ++++----- .../Spherical/FAbstractSphericalKernel.hpp | 62 +++++++++---------- Src/Kernels/Spherical/FHarmonic.hpp | 24 +++---- .../Spherical/FSphericalBlasKernel.hpp | 8 +-- .../Spherical/FSphericalBlockBlasKernel.hpp | 8 +-- Src/Kernels/Spherical/FSphericalKernel.hpp | 24 +++---- .../Spherical/FSphericalRotationKernel.hpp | 58 ++++++++--------- Src/Utils/FComplex.hpp | 21 +++---- Src/Utils/FMpi.hpp | 2 +- Tests/Kernels/testSphericalProcAlgorithm.cpp | 8 +-- Tests/Utils/testCompareIOTree.cpp | 28 ++++----- UTests/utestSphericalWithPrevious.cpp | 16 ++--- 12 files changed, 143 insertions(+), 146 deletions(-) diff --git a/Src/Kernels/Rotation/FRotationKernel.hpp b/Src/Kernels/Rotation/FRotationKernel.hpp index 191d07e64..aada34efd 100644 --- a/Src/Kernels/Rotation/FRotationKernel.hpp +++ b/Src/Kernels/Rotation/FRotationKernel.hpp @@ -996,8 +996,8 @@ public: int index_l_minus_j = l-m; // get l-j continuously for(int j = m ; j <= l ; ++j, --index_l_minus_j, index_jm += j ){ //const coef = (b^l-j) / (l-j)!; - w_lm_real += coef[index_l_minus_j] * source_w[index_jm].getReal(); - w_lm_imag += coef[index_l_minus_j] * source_w[index_jm].getImag(); + w_lm_real += coef[index_l_minus_j] * source_w[index_jm].real(); + w_lm_imag += coef[index_l_minus_j] * source_w[index_jm].imag(); } target_w[index_lm].setRealImag(w_lm_real,w_lm_imag); } @@ -1057,8 +1057,8 @@ public: for(int j = m ; j <= P-l ; ++j, ++index_jl, index_jm += j ){ // coef = (j+l)!/b^(j+l+1) // because {l,-m} => {l,m} conjugate -1^m with -i - u_lm_real += minus_1_pow_m * coef[index_jl] * source_w[index_jm].getReal(); - u_lm_imag -= minus_1_pow_m * coef[index_jl] * source_w[index_jm].getImag(); + u_lm_real += minus_1_pow_m * coef[index_jl] * source_w[index_jm].real(); + u_lm_imag -= minus_1_pow_m * coef[index_jl] * source_w[index_jm].imag(); } target_u[index_lm].setRealImag(u_lm_real,u_lm_imag); minus_1_pow_m = -minus_1_pow_m; @@ -1112,8 +1112,8 @@ public: for(int j = m ; j <= P-l ; ++j, ++index_jl, index_jm += j ){ // coef = (j+l)!/b^(j+l+1) // because {l,-m} => {l,m} conjugate -1^m with -i - u_lm_real += minus_1_pow_m * coef[index_jl] * source_w[index_jm].getReal(); - u_lm_imag -= minus_1_pow_m * coef[index_jl] * source_w[index_jm].getImag(); + u_lm_real += minus_1_pow_m * coef[index_jl] * source_w[index_jm].real(); + u_lm_imag -= minus_1_pow_m * coef[index_jl] * source_w[index_jm].imag(); } target_u[index_lm].setRealImag(u_lm_real,u_lm_imag); minus_1_pow_m = -minus_1_pow_m; @@ -1173,8 +1173,8 @@ public: int index_j_minus_l = 0; // get l-j continously for(int j = l ; j <= P ; ++j, ++index_j_minus_l, index_jm += j){ // coef = b^j-l/j-l! - u_lm_real += coef[index_j_minus_l] * source_u[index_jm].getReal(); - u_lm_imag += coef[index_j_minus_l] * source_u[index_jm].getImag(); + u_lm_real += coef[index_j_minus_l] * source_u[index_jm].real(); + u_lm_imag += coef[index_j_minus_l] * source_u[index_jm].imag(); } target_u[atLm(l,m)].setRealImag(u_lm_real,u_lm_imag); } @@ -1279,14 +1279,14 @@ public: for(int l = 1 ; l <= P ; ++l, ++fl){ // first m == 0 { - Fr += fl * u[index_lm].getReal() * minus_r_pow_l_legendre_div_fact_lm[index_lm]; + Fr += fl * u[index_lm].real() * minus_r_pow_l_legendre_div_fact_lm[index_lm]; } { const FReal coef = minus_r_pow_l_div_fact_lm[index_lm] * (fl * (sph.getCosTheta()*legendre[index_lm] - legendre[index_lm-l]) / sph.getSinTheta()); const FReal dI_real = coef; // F(O) += 2 * Real(L dI/dO) - FO += u[index_lm].getReal() * dI_real; + FO += u[index_lm].real() * dI_real; } ++index_lm; // then 0 < m @@ -1296,9 +1296,9 @@ public: const FReal I_real = coef * cos_m_phi_i_pow_m[m]; const FReal I_imag = coef * sin_m_phi_i_pow_m[m]; // F(r) += 2 x l x Real(LI) - Fr += 2 * fl * (u[index_lm].getReal() * I_real - u[index_lm].getImag() * I_imag); + Fr += 2 * fl * (u[index_lm].real() * I_real - u[index_lm].imag() * I_imag); // F(p) += -2 x m x Imag(LI) - Fp -= 2 * FReal(m) * (u[index_lm].getReal() * I_imag + u[index_lm].getImag() * I_real); + Fp -= 2 * FReal(m) * (u[index_lm].real() * I_imag + u[index_lm].imag() * I_real); } { const FReal legendre_l_minus_1 = (m == l) ? FReal(0.0) : FReal(l+m)*legendre[index_lm-l]; @@ -1307,7 +1307,7 @@ public: const FReal dI_real = coef * cos_m_phi_i_pow_m[m]; const FReal dI_imag = coef * sin_m_phi_i_pow_m[m]; // F(O) += 2 * Real(L dI/dO) - FO += FReal(2.0) * (u[index_lm].getReal() * dI_real - u[index_lm].getImag() * dI_imag); + FO += FReal(2.0) * (u[index_lm].real() * dI_real - u[index_lm].imag() * dI_imag); } } } @@ -1349,14 +1349,14 @@ public: for(int l = 0 ; l <= P ; ++l ){ {//for m == 0 // (l-|m|)! * P{l,0} / r^(l+1) - magnitude += u[index_lm].getReal() * minus_r_pow_l_legendre_div_fact_lm[index_lm]; + magnitude += u[index_lm].real() * minus_r_pow_l_legendre_div_fact_lm[index_lm]; ++index_lm; } for(int m = 1 ; m <= l ; ++m, ++index_lm ){ const FReal coef = minus_r_pow_l_legendre_div_fact_lm[index_lm]; const FReal I_real = coef * cos_m_phi_i_pow_m[m]; const FReal I_imag = coef * sin_m_phi_i_pow_m[m]; - magnitude += FReal(2.0) * ( u[index_lm].getReal() * I_real - u[index_lm].getImag() * I_imag ); + magnitude += FReal(2.0) * ( u[index_lm].real() * I_real - u[index_lm].imag() * I_imag ); } } // inc potential diff --git a/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp b/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp index 54a6c6602..5c38dc8a2 100644 --- a/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp +++ b/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp @@ -357,11 +357,11 @@ private: const FComplex<FReal> I_j_n__k_l = M2M_Inner_transfer[index_j_n + k - l]; multipole_exp_target[index_j + k].incReal( pow_of_minus_1_for_l * - ((M_n__n_l.getReal() * I_j_n__k_l.getReal()) + - (M_n__n_l.getImag() * I_j_n__k_l.getImag()))); + ((M_n__n_l.real() * I_j_n__k_l.real()) + + (M_n__n_l.imag() * I_j_n__k_l.imag()))); multipole_exp_target[index_j + k].incImag( pow_of_minus_1_for_l * - ((M_n__n_l.getReal() * I_j_n__k_l.getImag()) - - (M_n__n_l.getImag() * I_j_n__k_l.getReal()))); + ((M_n__n_l.real() * I_j_n__k_l.imag()) - + (M_n__n_l.imag() * I_j_n__k_l.real()))); } // for k } // for j @@ -388,11 +388,11 @@ private: const FComplex<FReal> I_j_n__l_k = M2M_Inner_transfer[index_j_n + l - k]; multipole_exp_target[index_j + k].incReal( pow_of_minus_1_for_k * pow_of_minus_1_for_l * - ((M_n__n_l.getReal() * I_j_n__l_k.getReal()) + - (M_n__n_l.getImag() * I_j_n__l_k.getImag()))); + ((M_n__n_l.real() * I_j_n__l_k.real()) + + (M_n__n_l.imag() * I_j_n__l_k.imag()))); multipole_exp_target[index_j + k].incImag(pow_of_minus_1_for_k * pow_of_minus_1_for_l * - ((M_n__n_l.getImag() * I_j_n__l_k.getReal()) - - (M_n__n_l.getReal() * I_j_n__l_k.getImag()))); + ((M_n__n_l.imag() * I_j_n__l_k.real()) - + (M_n__n_l.real() * I_j_n__l_k.imag()))); pow_of_minus_1_for_k = -pow_of_minus_1_for_k; } // for k @@ -401,11 +401,11 @@ private: const FComplex<FReal> I_j_n__k_l = M2M_Inner_transfer[index_j_n + k - l]; multipole_exp_target[index_j + k].incReal( - (M_n__n_l.getReal() * I_j_n__k_l.getReal()) - - (M_n__n_l.getImag() * I_j_n__k_l.getImag())); + (M_n__n_l.real() * I_j_n__k_l.real()) - + (M_n__n_l.imag() * I_j_n__k_l.imag())); multipole_exp_target[index_j + k].incImag( - (M_n__n_l.getImag() * I_j_n__k_l.getReal()) + - (M_n__n_l.getReal() * I_j_n__k_l.getImag())); + (M_n__n_l.imag() * I_j_n__k_l.real()) + + (M_n__n_l.real() * I_j_n__k_l.imag())); } // for k } // for j @@ -457,10 +457,10 @@ private: const FComplex<FReal> L_j_l = local_exp_src[index_n + l]; const FComplex<FReal> I_l_j__l_k = L2L_tranfer[index_n_j + l - k]; - L_j_k.incReal( (L_j_l.getReal() * I_l_j__l_k.getReal()) - - (L_j_l.getImag() * I_l_j__l_k.getImag())); - L_j_k.incImag( (L_j_l.getImag() * I_l_j__l_k.getReal()) + - (L_j_l.getReal() * I_l_j__l_k.getImag())); + L_j_k.incReal( (L_j_l.real() * I_l_j__l_k.real()) - + (L_j_l.imag() * I_l_j__l_k.imag())); + L_j_k.incImag( (L_j_l.imag() * I_l_j__l_k.real()) + + (L_j_l.real() * I_l_j__l_k.imag())); } @@ -471,11 +471,11 @@ private: const FComplex<FReal> I_l_j__l_k = L2L_tranfer[index_n_j - l + k]; L_j_k.incReal( pow_of_minus_1_for_l * pow_of_minus_1_for_k * - ((L_j_l.getReal() * I_l_j__l_k.getReal()) + - (L_j_l.getImag() * I_l_j__l_k.getImag()))); + ((L_j_l.real() * I_l_j__l_k.real()) + + (L_j_l.imag() * I_l_j__l_k.imag()))); L_j_k.incImag( pow_of_minus_1_for_l * pow_of_minus_1_for_k * - ((L_j_l.getImag() * I_l_j__l_k.getReal()) - - (L_j_l.getReal() * I_l_j__l_k.getImag()))); + ((L_j_l.imag() * I_l_j__l_k.real()) - + (L_j_l.real() * I_l_j__l_k.imag()))); pow_of_minus_1_for_l = -pow_of_minus_1_for_l; } @@ -486,11 +486,11 @@ private: const FComplex<FReal> I_l_j__l_k = L2L_tranfer[index_n_j - l + k]; L_j_k.incReal( pow_of_minus_1_for_k * - ((L_j_l.getReal() * I_l_j__l_k.getReal()) - - (L_j_l.getImag() * I_l_j__l_k.getImag()))); + ((L_j_l.real() * I_l_j__l_k.real()) - + (L_j_l.imag() * I_l_j__l_k.imag()))); L_j_k.decImag( pow_of_minus_1_for_k * - ((L_j_l.getImag() * I_l_j__l_k.getReal()) + - (L_j_l.getReal() * I_l_j__l_k.getImag()))); + ((L_j_l.imag() * I_l_j__l_k.real()) + + (L_j_l.real() * I_l_j__l_k.imag()))); } @@ -529,14 +529,14 @@ private: { // k=0: // F_r: - const FReal exp_term_aux_real = ( (harmonic.result(index_j_k).getReal() * local_exp[index_j_k].getReal()) - (harmonic.result(index_j_k).getImag() * local_exp[index_j_k].getImag()) ); + const FReal exp_term_aux_real = ( (harmonic.result(index_j_k).real() * local_exp[index_j_k].real()) - (harmonic.result(index_j_k).imag() * local_exp[index_j_k].imag()) ); //const FReal exp_term_aux_imag = ( (harmonic.result(index_j_k).getReal() * local_exp[index_j_k].getImag()) + harmonic.result(index_j_k).getImag() * local_exp[index_j_k].getReal()) ); force_vector_in_local_base_x = ( force_vector_in_local_base_x + FReal(j) * exp_term_aux_real ); } { // F_phi: k=0 => nothing to do for F_phi // F_theta: - const FReal exp_term_aux_real = ( (harmonic.resultThetaDerivated(index_j_k).getReal() * local_exp[index_j_k].getReal()) - (harmonic.resultThetaDerivated(index_j_k).getImag() * local_exp[index_j_k].getImag()) ); + const FReal exp_term_aux_real = ( (harmonic.resultThetaDerivated(index_j_k).real() * local_exp[index_j_k].real()) - (harmonic.resultThetaDerivated(index_j_k).imag() * local_exp[index_j_k].imag()) ); //const FReal exp_term_aux_imag = ( (harmonic.resultThetaDerivated(index_j_k).getReal() * local_exp[index_j_k].getImag()) + (harmonic.resultThetaDerivated(index_j_k).getImag() * local_exp[index_j_k].getReal()) ); force_vector_in_local_base_y = ( force_vector_in_local_base_y + exp_term_aux_real ); } @@ -547,15 +547,15 @@ private: for (int k=1; k<=j ;++k, ++index_j_k){ { // F_r: - const FReal exp_term_aux_real = ( (harmonic.result(index_j_k).getReal() * local_exp[index_j_k].getReal()) - (harmonic.result(index_j_k).getImag() * local_exp[index_j_k].getImag()) ); - const FReal exp_term_aux_imag = ( (harmonic.result(index_j_k).getReal() * local_exp[index_j_k].getImag()) + (harmonic.result(index_j_k).getImag() * local_exp[index_j_k].getReal()) ); + const FReal exp_term_aux_real = ( (harmonic.result(index_j_k).real() * local_exp[index_j_k].real()) - (harmonic.result(index_j_k).imag() * local_exp[index_j_k].imag()) ); + const FReal exp_term_aux_imag = ( (harmonic.result(index_j_k).real() * local_exp[index_j_k].imag()) + (harmonic.result(index_j_k).imag() * local_exp[index_j_k].real()) ); force_vector_in_local_base_x = (force_vector_in_local_base_x + FReal(2 * j) * exp_term_aux_real ); // F_phi: force_vector_in_local_base_z = ( force_vector_in_local_base_z - FReal(2 * k) * exp_term_aux_imag); } { // F_theta: - const FReal exp_term_aux_real = ( (harmonic.resultThetaDerivated(index_j_k).getReal() * local_exp[index_j_k].getReal()) - (harmonic.resultThetaDerivated(index_j_k).getImag() * local_exp[index_j_k].getImag()) ); + const FReal exp_term_aux_real = ( (harmonic.resultThetaDerivated(index_j_k).real() * local_exp[index_j_k].real()) - (harmonic.resultThetaDerivated(index_j_k).imag() * local_exp[index_j_k].imag()) ); //const FReal exp_term_aux_imag = ( (harmonic.resultThetaDerivated(index_j_k).getReal() * local_exp[index_j_k].getImag()) + (harmonic.resultThetaDerivated(index_j_k).getImag() * local_exp[index_j_k].getReal()) ); force_vector_in_local_base_y = (force_vector_in_local_base_y + FReal(2.0) * exp_term_aux_real ); } @@ -636,14 +636,14 @@ private: for(int j = 0 ; j<= devP ; ++j){ // k=0 harmonic.result(index_j_k) *= local_exp[index_j_k]; - result += harmonic.result(index_j_k).getReal(); + result += harmonic.result(index_j_k).real(); ++index_j_k; // k>0 for (int k = 1 ; k <= j ; ++k, ++index_j_k){ harmonic.result(index_j_k) *= local_exp[index_j_k]; - result += 2 * harmonic.result(index_j_k).getReal(); + result += 2 * harmonic.result(index_j_k).real(); } } diff --git a/Src/Kernels/Spherical/FHarmonic.hpp b/Src/Kernels/Spherical/FHarmonic.hpp index c06d217ce..bab498f01 100644 --- a/Src/Kernels/Spherical/FHarmonic.hpp +++ b/Src/Kernels/Spherical/FHarmonic.hpp @@ -218,8 +218,8 @@ public: for(int l = 0; l <= devP ; ++l){ for(int m = 0 ; m <= l ; ++m){ const FReal magnitude = sphereHarmoInnerCoef[index_l_m] * r_pow_l * legendre[index_l_m]; - harmonic[index_l_m].setReal( magnitude * cosSin[m].getReal() ); - harmonic[index_l_m].setImag( magnitude * cosSin[m].getImag() ); + harmonic[index_l_m].setReal( magnitude * cosSin[m].real() ); + harmonic[index_l_m].setImag( magnitude * cosSin[m].imag() ); ++index_l_m; } @@ -260,8 +260,8 @@ public: for(int l = 0 ; l <= devP ; ++l){ for(int m = 0 ; m <= l ; ++m){ const FReal magnitude = sphereHarmoOuterCoef[l-m] * invR_pow_l1 * legendre[index_l_m]; - harmonic[index_l_m].setReal( magnitude * cosSin[m].getReal() ); - harmonic[index_l_m].setImag( magnitude * cosSin[m].getImag() ); + harmonic[index_l_m].setReal( magnitude * cosSin[m].real() ); + harmonic[index_l_m].setImag( magnitude * cosSin[m].imag() ); ++index_l_m; } @@ -319,14 +319,14 @@ public: magnitude = sphereHarmoInnerCoef[index_l_m] * r_pow_l * legendre[index_l_m]; // Computation of Inner_l^m(r, theta, phi): - harmonic[index_l_m].setReal( magnitude * cosSin[m].getReal()); - harmonic[index_l_m].setImag( magnitude * cosSin[m].getImag()); + harmonic[index_l_m].setReal( magnitude * cosSin[m].real()); + harmonic[index_l_m].setImag( magnitude * cosSin[m].imag()); // Computation of {\partial Inner_l^m(r, theta, phi)}/{\partial theta}: magnitude = sphereHarmoInnerCoef[index_l_m] * r_pow_l * ((FReal(l)*inSphere.getCosTheta()*legendre[index_l_m] - FReal(l+m)*(legendre[getPreExpRedirJ(l-1) + m])) / inSphere.getSinTheta()); - thetaDerivatedResult[index_l_m].setReal(magnitude * cosSin[m].getReal()); - thetaDerivatedResult[index_l_m].setImag(magnitude * cosSin[m].getImag()); + thetaDerivatedResult[index_l_m].setReal(magnitude * cosSin[m].real()); + thetaDerivatedResult[index_l_m].setImag(magnitude * cosSin[m].imag()); ++index_l_m; } @@ -334,13 +334,13 @@ public: // m=l: // Computation of Inner_m^m(r, theta, phi): magnitude = sphereHarmoInnerCoef[index_l_m] * r_pow_l * legendre[index_l_m]; - harmonic[index_l_m].setReal(magnitude * cosSin[m].getReal()); - harmonic[index_l_m].setImag(magnitude * cosSin[m].getImag()); + harmonic[index_l_m].setReal(magnitude * cosSin[m].real()); + harmonic[index_l_m].setImag(magnitude * cosSin[m].imag()); // Computation of {\partial Inner_m^m(r, theta, phi)}/{\partial theta}: magnitude = sphereHarmoInnerCoef[index_l_m] * r_pow_l * (FReal(m) * inSphere.getCosTheta() * legendre[index_l_m] / inSphere.getSinTheta()); - thetaDerivatedResult[index_l_m].setReal(magnitude * cosSin[m].getReal()); - thetaDerivatedResult[index_l_m].setImag(magnitude * cosSin[m].getImag()); + thetaDerivatedResult[index_l_m].setReal(magnitude * cosSin[m].real()); + thetaDerivatedResult[index_l_m].setImag(magnitude * cosSin[m].imag()); r_pow_l *= inSphere.getR(); ++index_l_m; diff --git a/Src/Kernels/Spherical/FSphericalBlasKernel.hpp b/Src/Kernels/Spherical/FSphericalBlasKernel.hpp index 0e686e4d9..0def1f4ea 100644 --- a/Src/Kernels/Spherical/FSphericalBlasKernel.hpp +++ b/Src/Kernels/Spherical/FSphericalBlasKernel.hpp @@ -65,8 +65,8 @@ protected: const int k = N-n-m; if (k < 0){ const FReal pow_of_minus_1 = FReal((k&1) ? -1 : 1); - fillTransfer->setReal( pow_of_minus_1 * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].getReal()); - fillTransfer->setImag((-pow_of_minus_1) * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].getImag()); + fillTransfer->setReal( pow_of_minus_1 * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].real()); + fillTransfer->setImag((-pow_of_minus_1) * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].imag()); } else{ (*fillTransfer) = blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)+k]; @@ -205,8 +205,8 @@ public: // Negative orders: FReal minus_1_pow_k = FReal( j&1 ? -1 : 1); for(int k = -j ; k < 0 ; ++k ){ - exp[j_j1 + k].setReal(minus_1_pow_k * exp[j_j1 + (-k)].getReal()); - exp[j_j1 + k].setImag((-minus_1_pow_k) * exp[j_j1 + (-k)].getImag()); + exp[j_j1 + k].setReal(minus_1_pow_k * exp[j_j1 + (-k)].real()); + exp[j_j1 + k].setImag((-minus_1_pow_k) * exp[j_j1 + (-k)].imag()); minus_1_pow_k = -minus_1_pow_k; } } diff --git a/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp b/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp index b3704b674..134af3696 100644 --- a/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp +++ b/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp @@ -80,8 +80,8 @@ protected: const int k = N-n-m; if (k < 0){ const FReal pow_of_minus_1 = FReal((k&1) ? -1 : 1); - fillTransfer->setReal( pow_of_minus_1 * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].getReal()); - fillTransfer->setImag((-pow_of_minus_1) * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].getImag()); + fillTransfer->setReal( pow_of_minus_1 * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].real()); + fillTransfer->setImag((-pow_of_minus_1) * blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)-k].imag()); } else{ (*fillTransfer) = blasHarmonic.result()[blasHarmonic.getPreExpRedirJ(M+N)+k]; @@ -212,8 +212,8 @@ public: // Negative orders: FReal minus_1_pow_k = FReal( j&1 ? -1 : 1); for(int k = -j ; k < 0 ; ++k ){ - exp[j_j1 + k].setReal(minus_1_pow_k * exp[j_j1 + (-k)].getReal()); - exp[j_j1 + k].setImag((-minus_1_pow_k) * exp[j_j1 + (-k)].getImag()); + exp[j_j1 + k].setReal(minus_1_pow_k * exp[j_j1 + (-k)].real()); + exp[j_j1 + k].setImag((-minus_1_pow_k) * exp[j_j1 + (-k)].imag()); minus_1_pow_k = -minus_1_pow_k; } } diff --git a/Src/Kernels/Spherical/FSphericalKernel.hpp b/Src/Kernels/Spherical/FSphericalKernel.hpp index 99b423a5f..01b34d7b6 100644 --- a/Src/Kernels/Spherical/FSphericalKernel.hpp +++ b/Src/Kernels/Spherical/FSphericalKernel.hpp @@ -152,11 +152,11 @@ public: const FComplex<FReal> O_n_j__k_l = M2L_Outer_transfer[index_n_j + k + l]; L_j_k.incReal( pow_of_minus_1_for_l * pow_of_minus_1_for_k * - ((M_n_l.getReal() * O_n_j__k_l.getReal()) + - (M_n_l.getImag() * O_n_j__k_l.getImag()))); + ((M_n_l.real() * O_n_j__k_l.real()) + + (M_n_l.imag() * O_n_j__k_l.imag()))); L_j_k.incImag( pow_of_minus_1_for_l * pow_of_minus_1_for_k * - ((M_n_l.getImag() * O_n_j__k_l.getReal()) - - (M_n_l.getReal() * O_n_j__k_l.getImag()))); + ((M_n_l.imag() * O_n_j__k_l.real()) - + (M_n_l.real() * O_n_j__k_l.imag()))); pow_of_minus_1_for_l = -pow_of_minus_1_for_l; } @@ -166,11 +166,11 @@ public: const FComplex<FReal> O_n_j__k_l = M2L_Outer_transfer[index_n_j + k + l]; L_j_k.incReal( pow_of_minus_1_for_k * - ((M_n_l.getReal() * O_n_j__k_l.getReal()) - - (M_n_l.getImag() * O_n_j__k_l.getImag()))); + ((M_n_l.real() * O_n_j__k_l.real()) - + (M_n_l.imag() * O_n_j__k_l.imag()))); L_j_k.decImag( pow_of_minus_1_for_k * - ((M_n_l.getImag() * O_n_j__k_l.getReal()) + - (M_n_l.getReal() * O_n_j__k_l.getImag()))); + ((M_n_l.imag() * O_n_j__k_l.real()) + + (M_n_l.real() * O_n_j__k_l.imag()))); pow_of_minus_1_for_l = -pow_of_minus_1_for_l; } @@ -180,11 +180,11 @@ public: const FComplex<FReal> O_n_j__k_l = M2L_Outer_transfer[index_n_j - (k + l)]; L_j_k.incReal( pow_of_minus_1_for_l * - ((M_n_l.getReal() * O_n_j__k_l.getReal()) + - (M_n_l.getImag() * O_n_j__k_l.getImag()))); + ((M_n_l.real() * O_n_j__k_l.real()) + + (M_n_l.imag() * O_n_j__k_l.imag()))); L_j_k.incImag( pow_of_minus_1_for_l * - ((M_n_l.getReal() * O_n_j__k_l.getImag()) - - (M_n_l.getImag() * O_n_j__k_l.getReal()))); + ((M_n_l.real() * O_n_j__k_l.imag()) - + (M_n_l.imag() * O_n_j__k_l.real()))); pow_of_minus_1_for_l = -pow_of_minus_1_for_l; } diff --git a/Src/Kernels/Spherical/FSphericalRotationKernel.hpp b/Src/Kernels/Spherical/FSphericalRotationKernel.hpp index 4af2637a7..b43bd9edc 100644 --- a/Src/Kernels/Spherical/FSphericalRotationKernel.hpp +++ b/Src/Kernels/Spherical/FSphericalRotationKernel.hpp @@ -240,16 +240,16 @@ protected: const FReal H_nu_minus_1 = ( nu-1 <= -n ? FReal(0.0) : (cos_gamma +1) * rotation_info.rotation_b[getRotationB(n, -nu)] - * rcc_tmp_transposed[n-1][getTranspRotationCoefP(n-1, nu-1, m-1)].getReal()); + * rcc_tmp_transposed[n-1][getTranspRotationCoefP(n-1, nu-1, m-1)].real()); const FReal H_nu_plus_1 = ( nu+1 >= n ? FReal(0.0) : (cos_gamma -1) * rotation_info.rotation_b[getRotationB(n, nu)] - * rcc_tmp_transposed[n-1][getTranspRotationCoefP(n-1, nu+1, m-1)].getReal()); + * rcc_tmp_transposed[n-1][getTranspRotationCoefP(n-1, nu+1, m-1)].real()); const FReal H_nu = ( FMath::Abs(nu) >= n ? FReal(0.0) : sin_gamma * rotation_info.rotation_a[getRotationA(n-1, nu)] - * rcc_tmp_transposed[n-1][getTranspRotationCoefP(n-1, nu, m-1)].getReal() ); + * rcc_tmp_transposed[n-1][getTranspRotationCoefP(n-1, nu, m-1)].real() ); rcc_tmp_transposed[n][getTranspRotationCoefP(n, nu, m)].setReal( (FReal(0.5) * (-H_nu_minus_1 - H_nu_plus_1) - H_nu) @@ -456,11 +456,11 @@ public: for(int k = -j ; k < 0 ; ++k){ /* k < 0 */ p_rot_multipole_exp->incReal( minus_1_pow_k * - ((p_multipole_exp->getReal() * p_rcc_outer->getReal()) + - (p_multipole_exp->getImag() * p_rcc_outer->getImag())) ); + ((p_multipole_exp->real() * p_rcc_outer->real()) + + (p_multipole_exp->imag() * p_rcc_outer->imag())) ); p_rot_multipole_exp->incImag( minus_1_pow_k * - ((p_multipole_exp->getReal() * p_rcc_outer->getImag()) - - (p_multipole_exp->getImag() * p_rcc_outer->getReal())) ); + ((p_multipole_exp->real() * p_rcc_outer->imag()) - + (p_multipole_exp->imag() * p_rcc_outer->real())) ); minus_1_pow_k = -minus_1_pow_k; --p_rcc_outer; @@ -469,11 +469,11 @@ public: for(int k = 0; k <= j ; ++k){ /* k >= 0 */ p_rot_multipole_exp->incReal( - ((p_multipole_exp->getReal() * p_rcc_outer->getReal()) - - (p_multipole_exp->getImag() * p_rcc_outer->getImag())) ); + ((p_multipole_exp->real() * p_rcc_outer->real()) - + (p_multipole_exp->imag() * p_rcc_outer->imag())) ); p_rot_multipole_exp->incImag( - ((p_multipole_exp->getReal() * p_rcc_outer->getImag()) + - (p_multipole_exp->getImag() * p_rcc_outer->getReal())) ); + ((p_multipole_exp->real() * p_rcc_outer->imag()) + + (p_multipole_exp->imag() * p_rcc_outer->real())) ); --p_rcc_outer; ++p_multipole_exp; @@ -497,8 +497,8 @@ public: for(int k = 0 ; k <= min_j ; ++k){ const FComplex<FReal>* p_rot_multipole_exp = rot_multipole_exp + k * (Parent::devP + 2 - k); for(int n = k ; n <= stop_for_n ; ++n){ - p_rot_local_exp->incReal(p_rot_multipole_exp->getReal() * p_outer_array_j[n]); - p_rot_local_exp->incImag(p_rot_multipole_exp->getImag() * p_outer_array_j[n]); + p_rot_local_exp->incReal(p_rot_multipole_exp->real() * p_outer_array_j[n]); + p_rot_local_exp->incImag(p_rot_multipole_exp->imag() * p_outer_array_j[n]); ++p_rot_multipole_exp; } /* for n */ ++p_rot_local_exp; @@ -525,11 +525,11 @@ public: for(int k = -min_j ; k < 0 ; ++k){ /* k < 0 */ p_local_exp->incReal( minus_1_pow_k * - ((p_rot_local_exp->getReal() * p_rcc_inner->getReal()) + - (p_rot_local_exp->getImag() * p_rcc_inner->getImag()))); + ((p_rot_local_exp->real() * p_rcc_inner->real()) + + (p_rot_local_exp->imag() * p_rcc_inner->imag()))); p_local_exp->incImag( minus_1_pow_k * - ((p_rot_local_exp->getReal() * p_rcc_inner->getImag()) - - (p_rot_local_exp->getImag() * p_rcc_inner->getReal()))); + ((p_rot_local_exp->real() * p_rcc_inner->imag()) - + (p_rot_local_exp->imag() * p_rcc_inner->real()))); minus_1_pow_k = -minus_1_pow_k; --p_rot_local_exp; @@ -538,11 +538,11 @@ public: for(int k = 0; k <= min_j ; ++k){ /* k >= 0 */ p_local_exp->incReal( - ((p_rot_local_exp->getReal() * p_rcc_inner->getReal()) - - (p_rot_local_exp->getImag() * p_rcc_inner->getImag()))); + ((p_rot_local_exp->real() * p_rcc_inner->real()) - + (p_rot_local_exp->imag() * p_rcc_inner->imag()))); p_local_exp->incImag( - ((p_rot_local_exp->getReal() * p_rcc_inner->getImag()) + - (p_rot_local_exp->getImag() * p_rcc_inner->getReal()))); + ((p_rot_local_exp->real() * p_rcc_inner->imag()) + + (p_rot_local_exp->imag() * p_rcc_inner->real()))); ++p_rot_local_exp; ++p_rcc_inner; @@ -566,11 +566,11 @@ public: for(int k = -min_j ; k < 0; ++k){ /* k < 0 */ p_local_exp->incReal( minus_1_pow_k * - ((p_rot_local_exp->getReal() * p_rcc_inner->getReal()) + - (p_rot_local_exp->getImag() * p_rcc_inner->getImag()))); + ((p_rot_local_exp->real() * p_rcc_inner->real()) + + (p_rot_local_exp->imag() * p_rcc_inner->imag()))); p_local_exp->incImag( minus_1_pow_k * - ((p_rot_local_exp->getReal() * p_rcc_inner->getImag()) - - (p_rot_local_exp->getImag() * p_rcc_inner->getReal()))); + ((p_rot_local_exp->real() * p_rcc_inner->imag()) - + (p_rot_local_exp->imag() * p_rcc_inner->real()))); minus_1_pow_k = -minus_1_pow_k; --p_rot_local_exp; @@ -578,11 +578,11 @@ public: } /* for k */ for(int k = 0; k<=min_j; ++k){ /* k >= 0 */ p_local_exp->incReal( - ((p_rot_local_exp->getReal() * p_rcc_inner->getReal()) - - (p_rot_local_exp->getImag() * p_rcc_inner->getImag()))); + ((p_rot_local_exp->real() * p_rcc_inner->real()) - + (p_rot_local_exp->imag() * p_rcc_inner->imag()))); p_local_exp->incImag( - ((p_rot_local_exp->getReal() * p_rcc_inner->getImag()) + - (p_rot_local_exp->getImag() * p_rcc_inner->getReal()))); + ((p_rot_local_exp->real() * p_rcc_inner->imag()) + + (p_rot_local_exp->imag() * p_rcc_inner->real()))); ++p_rot_local_exp; ++p_rcc_inner; diff --git a/Src/Utils/FComplex.hpp b/Src/Utils/FComplex.hpp index bff474c16..cc4a730ab 100644 --- a/Src/Utils/FComplex.hpp +++ b/Src/Utils/FComplex.hpp @@ -58,7 +58,11 @@ public: complex[0] = other.complex[0]; complex[1] = other.complex[1]; } - + /** Move constructor */ + FComplex<FReal>(FComplex<FReal> &&c) + { + std::move(std::begin(c.complex), std::end(c.complex), complex); + } /** Copy operator */ FComplex<FReal>& operator=(const FComplex<FReal>& other){ this->complex[0] = other.complex[0]; @@ -77,23 +81,16 @@ public: return !(*this == other); } + /** Get imaginary */ FReal imag() const{ return this->complex[1]; } - /** Get imaginary */ - FReal getImag() const{ - return this->complex[1]; - } /** Get complex[0] */ FReal real() const{ return this->complex[0]; } - /** Get complex[0] */ - FReal getReal() const{ - return this->complex[0]; - } /** Set Imaginary */ void setImag(const FReal inImag) { @@ -245,7 +242,7 @@ public: */ template <class StreamClass> friend StreamClass& operator<<(StreamClass& output, const FComplex<FReal>& inC){ - output << "(" << inC.getReal() << ", " << inC.getImag() << ")"; + output << "(" << inC.real() << ", " << inC.imag() << ")"; return output; // for multiple << operators. } @@ -255,8 +252,8 @@ public: template <class FReal> inline FComplex<FReal> operator*=(const FComplex<FReal>& first, const FComplex<FReal>& second){ return FComplex<FReal>( - (first.getReal() * second.getImag()) + (first.getImag() * second.getReal()), - (first.getReal() * second.getReal()) - (first.getImag() * second.getImag()) + (first.real() * second.imag()) + (first.imag() * second.real()), + (first.real() * second.real()) - (first.imag() * second.imag()) ); } diff --git a/Src/Utils/FMpi.hpp b/Src/Utils/FMpi.hpp index a4a047296..1b30d5552 100644 --- a/Src/Utils/FMpi.hpp +++ b/Src/Utils/FMpi.hpp @@ -422,7 +422,7 @@ public: /// Get the MPI datatype corresponding to a variable. template <class FReal> static MPI_Datatype GetType(const FComplex<FReal>& a){ - return GetType(a.getReal()); + return GetType(a.real()); } template <class FReal> diff --git a/Tests/Kernels/testSphericalProcAlgorithm.cpp b/Tests/Kernels/testSphericalProcAlgorithm.cpp index 81968888a..e1c0a13a3 100644 --- a/Tests/Kernels/testSphericalProcAlgorithm.cpp +++ b/Tests/Kernels/testSphericalProcAlgorithm.cpp @@ -58,8 +58,8 @@ template <class CellClass> bool isEqualPole(const CellClass& me, const CellClass& other, FReal*const cumul){ FMath::FAccurater<FReal> accurate; for(int idx = 0; idx < CellClass::multipole_t::Size; ++idx){ - accurate.add(me.getMultipoleData().get()[idx].getImag(),other.getMultipoleData().get()[idx].getImag()); - accurate.add(me.getMultipoleData().get()[idx].getReal(),other.getMultipoleData().get()[idx].getReal()); + accurate.add(me.getMultipoleData().get()[idx].imag(),other.getMultipoleData().get()[idx].imag()); + accurate.add(me.getMultipoleData().get()[idx].real(),other.getMultipoleData().get()[idx].real()); } *cumul = accurate.getInfNorm()+ accurate.getL2Norm(); return accurate.getInfNorm() < Epsilon && accurate.getL2Norm() < Epsilon;//FMath::LookEqual(cumul,FReal(0.0)); @@ -69,8 +69,8 @@ bool isEqualPole(const CellClass& me, const CellClass& other, FReal*const cumul) bool isEqualLocal(const FSphericalCell<FReal>& me, const FSphericalCell<FReal>& other,FReal*const cumul){ FMath::FAccurater<FReal> accurate; for(int idx = 0; idx < FSphericalCell<FReal>::local_expansion_t::Size; ++idx){ - accurate.add(me.getLocalExpansionData().get()[idx].getImag(),other.getLocalExpansionData().get()[idx].getImag()); - accurate.add(me.getLocalExpansionData().get()[idx].getReal(),other.getLocalExpansionData().get()[idx].getReal()); + accurate.add(me.getLocalExpansionData().get()[idx].imag(),other.getLocalExpansionData().get()[idx].imag()); + accurate.add(me.getLocalExpansionData().get()[idx].real(),other.getLocalExpansionData().get()[idx].real()); } *cumul = accurate.getInfNorm()+ accurate.getL2Norm(); return accurate.getInfNorm() < Epsilon && accurate.getL2Norm() < Epsilon;//FMath::LookEqual(cumul,FReal(0.0)); diff --git a/Tests/Utils/testCompareIOTree.cpp b/Tests/Utils/testCompareIOTree.cpp index 795b58348..d439cbf2d 100644 --- a/Tests/Utils/testCompareIOTree.cpp +++ b/Tests/Utils/testCompareIOTree.cpp @@ -5,21 +5,21 @@ #include <cstdio> #include <cstdlib> -#include "../../Src/Utils/FTic.hpp" -#include "../../Src/Utils/FParameters.hpp" +#include "Utils/FTic.hpp" +#include "Utils/FParameters.hpp" -#include "../../Src/Containers/FOctree.hpp" -#include "../../Src/Containers/FVector.hpp" +#include "Containers/FOctree.hpp" +#include "Containers/FVector.hpp" -#include "../../Src/Files/FTreeIO.hpp" +#include "Files/FTreeIO.hpp" -#include "../../Src/Kernels/Spherical/FSphericalCell.hpp" -#include "../../Src/Components/FSimpleLeaf.hpp" +#include "Kernels/Spherical/FSphericalCell.hpp" +#include "Components/FSimpleLeaf.hpp" -#include "../../Src/Components/FSimpleLeaf.hpp" -#include "../../Src/Kernels/P2P/FP2PParticleContainer.hpp" +#include "Components/FSimpleLeaf.hpp" +#include "Kernels/P2P/FP2PParticleContainer.hpp" -#include "../../Src/Utils/FParameterNames.hpp" +#include "Utils/FParameterNames.hpp" // Simply create particles and try the kernels int main(int argc, char ** argv){ @@ -117,8 +117,8 @@ int main(int argc, char ** argv){ FReal cumul = 0; for(int idx = 0; idx < FSphericalCell<FReal>::multipole_t::getSize(); ++idx){ - cumul += FMath::Abs( cell1->getMultipoleData().get()[idx].getImag() - cell2->getMultipoleData().get()[idx].getImag() ); - cumul += FMath::Abs( cell1->getMultipoleData().get()[idx].getReal() - cell2->getMultipoleData().get()[idx].getReal() ); + cumul += FMath::Abs( cell1->getMultipoleData().get()[idx].imag() - cell2->getMultipoleData().get()[idx].imag() ); + cumul += FMath::Abs( cell1->getMultipoleData().get()[idx].real() - cell2->getMultipoleData().get()[idx].real() ); } if( cumul > 0.00001 || FMath::IsNan(cumul)){ std::cout << "Pole Data are different. Cumul " << cumul << " at level " << idxLevel @@ -126,8 +126,8 @@ int main(int argc, char ** argv){ } cumul = 0; for(int idx = 0; idx < FSphericalCell<FReal>::local_expansion_t::getSize(); ++idx){ - cumul += FMath::Abs( cell1->getLocalExpansionData().get()[idx].getImag() - cell2->getLocalExpansionData().get()[idx].getImag() ); - cumul += FMath::Abs( cell1->getLocalExpansionData().get()[idx].getReal() - cell2->getLocalExpansionData().get()[idx].getReal() ); + cumul += FMath::Abs( cell1->getLocalExpansionData().get()[idx].imag() - cell2->getLocalExpansionData().get()[idx].imag() ); + cumul += FMath::Abs( cell1->getLocalExpansionData().get()[idx].real() - cell2->getLocalExpansionData().get()[idx].real() ); } if( cumul > 0.00001 || FMath::IsNan(cumul)){ std::cout << "Local Data are different. Cumul " << cumul << " at level " << idxLevel diff --git a/UTests/utestSphericalWithPrevious.cpp b/UTests/utestSphericalWithPrevious.cpp index 54c007234..6c9972ad3 100644 --- a/UTests/utestSphericalWithPrevious.cpp +++ b/UTests/utestSphericalWithPrevious.cpp @@ -162,17 +162,17 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { } for(int idxLocal = 0 ; idxLocal < CellClass::local_expansion_t::getSize() ; ++idxLocal){ - IsSimilar(testOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getReal(), - goodOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getReal()); - IsSimilar(testOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getImag(), - goodOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getImag()); + IsSimilar(testOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].real(), + goodOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].real()); + IsSimilar(testOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].imag(), + goodOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].imag()); } for(int idxPole = 0 ; idxPole < CellClass::multipole_t::getSize() ; ++idxPole){ - IsSimilar(testOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getReal(), - goodOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getReal()); - IsSimilar(testOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getImag(), - goodOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getImag()); + IsSimilar(testOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].real(), + goodOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].real()); + IsSimilar(testOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].imag(), + goodOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].imag()); } if(!testOctreeIterator.moveRight()){ -- GitLab