int main(void) { a = INIT_A; b = INIT_B; c = INIT_C; d = INIT_D; e = INIT_E; printf("a = %d b = %d c = %d d = %d e = %d\n", a, b, c, d, e); printf("Le résultat devrait être le même les 3 fois :\n\n"); func_c(); printf("Version en langage C : %i\n", a); a = INIT_A; b = INIT_B; c = INIT_C; d = INIT_D; e = INIT_E; func_s(); printf("Version en assembleur : %i\n", a); a = INIT_A; b = INIT_B; c = INIT_C; d = INIT_D; e = INIT_E; func_c(); printf("Version en langage C : %i\n", a); return 0; }
double c_correction(float mass, int snapnum) { double c_original, c_new, Omega_new, Omega_original, ratio; c_original = 5 * pow(mass/10000., -0.1); Omega_new = Omega * 1./pow3(AA[snapnum]) / (Omega * 1./pow3(AA[snapnum]) + OmegaLambda); Omega_original = Omega_OriginalCosm * 1./pow3(AA_OriginalCosm[snapnum]) / (Omega_OriginalCosm * 1./pow3(AA_OriginalCosm[snapnum]) + OmegaLambda_OriginalCosm); ratio = Omega_original/ Omega_new; c_new = find_c(c_original, ratio); return func_c(c_new) / func_c(c_original); }
types::Double* trigo(types::Double* in, func_real func_r, func_complex func_c, bool forceComplex) { bool isComplex = in->isComplex() || forceComplex; types::Double* out = new types::Double(in->getDims(), in->getDimsArray(), isComplex); int size = in->getSize(); double* pInR = in->get(); double* pOutR = out->get(); if (isComplex) { double* pInI = in->getImg(); double* pOutI = out->getImg(); std::complex<double> d; for (int i = 0; i < size; ++i) { d.real(pInR[i]); d.imag(pInI[i]); std::complex<double> res = func_c(d); pOutR[i] = res.real(); pOutI[i] = res.imag(); } } else { for (int i = 0; i < size; ++i) { pOutR[i] = func_r(pInR[i]); } } return out; }
int func_a() { int a_val = (0xa << 4); a_val |= func_c(); a_val <<= 4; a_val |= func_d(); return a_val; }
double find_c(double c_ori, double ratio) { double x1, x2, xx, constant; x1 = 1.; x2 = 50.; xx = (x1 + x2) / 2.; constant = ratio * func_c(c_ori)/c_ori/c_ori/c_ori; do { if((func_c(xx)/xx/xx/xx - constant) * (func_c(x1)/x1/x1/x1 - constant) > 0) x1 = xx; else x2 = xx; xx = (x1 + x2 )/ 2.; } while(fabs(func_c(xx)/xx/xx/xx- constant) > 1.e-8); return xx; }
void func_call() { func_a ( 1, 2, 3); func_b ( 4, 5, 6 ); func_c ( 7, 8, 9 ); func_d ( "aaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccc" ); }
void func_b() { func_c(); }