//Lecture d'une matrice et transformation en arêtes. static void readMatrixAndCreateEdges(Matrix m){ // On crée un tableau contenant toutes les arêtes. ensemble = malloc(sizeof(Edge)*somme(getMatrixLength(m))); tailleEnsemble = somme(getMatrixLength(m)); int numCase = 0; Edge tmp; caseActuelleEnsemble = 0; for (int i=0; i<getMatrixLength(m); i++){ for (int j=i+1; j<getMatrixLength(m); j++){ ensemble[numCase] = createEdge(i, j, getMatrixValue(m, i, j)); if (numCase > 0){ // Si la case actuelle a un poids plus léger que la précédente if (ensemble[numCase]->weightEdge < ensemble[numCase-1]->weightEdge){ int n = numCase; // On la fait reculer tant qu'elle est plus légère que la case précédente, qui effectue un tri du tableau en le remplissant. while (n > 0 && ensemble[n]->weightEdge < ensemble[n-1]->weightEdge){ tmp = ensemble[n]; ensemble[n] = ensemble[n-1]; ensemble[n-1] = tmp; n--; } } } numCase++; } } //Affiche le tableau des arêtes de la matrice, trié. //for (int i=0; i<tailleEnsemble; i++){ // printEdgeValues(ensemble[i]); //} }
int somme(Arbre *a) { if (a == NULL) return 0; else return somme(a->g) + somme(a->d) + a->x; }
int somme(sabr *a) { if(a==NULL) { return 0; } else { return somme(a -> g) + somme(a -> d) + a -> e; } }
int amis(int n, int m) { int sn, sm; //somme des div de n et somme des div de m int i; sn = somme(n);// Somme de tout les diviseurs de n sauf lui meme sm = somme(m);// Somme de tout les diviseurs de m sauf lui meme if ( (sn == m) && (sm == n) ) {return 1;} else return 0; }
//OK //Même principe que la hauteur int somme(Arbre* racine) { static int ressomme=0; if(racine!=NULL) { somme(racine->gauche); ressomme+=racine->valeur; somme(racine->droit); } return ressomme; }
/* --------------------------------------------------------- */ int calc_otsu_threshold_v0_ui32vector(uint32 *H, int i0, int i1) /* ---------------------------------------------------------- */ { // http://www.labbookpages.co.uk/software/imgProc/otsuThreshold.html // slow version (exact implementation of Otsu's original algorithm int t, threshold = i0; float32 Stot; float32 bS, bSx, bSxx; float32 fS, fSx, fSxx; float32 sb, wb, ub, vb; float32 sf, wf, uf, vf; float32 v, vmin = 1e39; Stot = somme(H, i0, i1); for(t=i0; t<=i1; t++) { bS = somme (H, i0, t-1); fS = somme (H, t, i1); bSx = somme_prod_i (H, i0, t-1); fSx = somme_prod_i (H, t, i1); bSxx = somme_prod_i2(H, i0, t-1); fSxx = somme_prod_i2(H, t, i1); if((bS == 0.0f) || (fS == 0.0f)) continue; sb = bS; sf = fS; wb = sb / Stot; wf = sf / Stot; ub = bSx / bS; uf = fSx / fS; vb = (bS*bSxx - bSx*bSx) / (bS*bS); vf = (fS*fSxx - fSx*fSx) / (fS*fS); v = wb * vb + wf * vf; //printf("t = %d v = %.4f\n", t, v); if(v < vmin) { vmin = v; threshold = t; } } return threshold; }
int main(int ac, char **av) { if (debut(ac, av[1]) == 0 && atoi(av[1]) > 0 && (av[2][0] >= 49 && av[2][0] <= 57)) { srand(time(NULL)); int a = atoi(av[2]); int b = rand()%(9+10)-9; int tabA[a], tabB[a] , tabAB[a], tabMult[a]; printf("Vecteur A:\t"); nbrAlea(a, tabA); affiche(tabA, a); printf("\n"); if (atoi(av[1]) != 2) { printf("Vecteur B:\t"); nbrAlea(a, tabB); affiche(tabB, a); printf("\n"); } if (atoi(av[1]) == 1) { printf("Vecteur A+B:\t"); somme(a, tabA, tabB, tabAB); affiche(tabAB, a); } else if (atoi(av[1]) == 2) { printf(" B: %d\nVecteur A*B:\t", b); multi(a, tabA, tabMult, b); affiche(tabMult, a); } else if (atoi(av[1]) == 3) { printf("Produit Scalaire AB:\t"); printf("%d", scal(a, tabA, tabB)); } else if (atoi(av[1]) == 4) { printf("Norme Euclidienne A.B:\t"); somme(a, tabA, tabB, tabAB); printf("%.3f", sqrt(norme(a, tabAB))); } printf("\n"); } else printf("Veuillez entrer en argument un nombre compris entre 1 et 4 suivi du nombre de coordonnee que vous voulez \n"); return (0); }
double Statistic::moyenne(QVector<int> &tab,int n) { double moyenne = double(somme(tab,n))/n; return (moyenne); }
int main( int argc, char** argv) { int compteur; compteur = somme(argv, argc); printf("%d\n", compteur); return 0; }
double Statistic::moyenne(QVector<double> &tab,int n) { double moyenne = somme(tab,n)/n; return (moyenne); }
int main( int argc, char *argv[] ) { // On obtient les arguments du programme. assert( argc >= 3 ); int n = atoi( argv[1] ); assert( n > 0 ); int nb_threads = atoi( argv[2] ); assert( nb_threads > 0 ); // On fixe le nombre de threads a utiliser. omp_set_dynamic(0); omp_set_num_threads( nb_threads ); // On calcule la somme avec la fonction recursive. int res; { res = somme( 1, n ); } // On imprime le resultat. printf( "\n" ); printf( "1 + 2 + ... + %d (%d threads) = %d\n", n, nb_threads, res ); // On verifie le resultat. assert( res == (n * (n+1) / 2) ); return( 0 ); }
void outPut::gen_normalMap() { coords3d<float> somme(0,0,0), contribution; coords3d<float> vert_normal(0,0,1); vert_normal.normalize(); for(int x = 0; x < _dimensions.x; x++) { for(int y = 0; y < _dimensions.y; y++) { somme = coords3d<float>::retournercoords3d(0,0,0); /* 0,1 -1,1 +--+--+ |\2|\*| |1\|3\| -1,0 +--+--+ 1,0 |\4|\6| |*\|5\| +--+--+ 1,-1 0,-1 */ somme+= coords3d<float>::cross(getVertex<float>(x,y)-getVertex<float>(x-1,y), getVertex<float>(x-1,y+1)-getVertex<float>(x-1,y)); //1 somme+= coords3d<float>::cross(getVertex<float>(x-1,y+1)-getVertex<float>(x,y+1), getVertex<float>(x,y)-getVertex<float>(x,y+1)); //2 somme+= coords3d<float>::cross(getVertex<float>(x+1,y)-getVertex<float>(x,y), getVertex<float>(x,y+1)-getVertex<float>(x,y)); //3 somme+= coords3d<float>::cross(getVertex<float>(x-1,y)-getVertex<float>(x,y), getVertex<float>(x,y-1)-getVertex<float>(x,y)); //4 somme+= coords3d<float>::cross(getVertex<float>(x+1,y-1)-getVertex<float>(x,y-1), getVertex<float>(x,y)-getVertex<float>(x,y-1)); //5 somme+= coords3d<float>::cross(getVertex<float>(x,y)-getVertex<float>(x+1,y), getVertex<float>(x+1,y-1)-getVertex<float>(x+1,y)); //6 somme.normalize(); _scene3d.normalMap[x][y] = somme; } } }
int somme( int i, int j ) { omp_get_thread_num(); printf( "Thread %2d: somme( %4d, %4d )\n", omp_get_thread_num(), i, j ); if ( i == j ) { return( i ); } else { int mid = (i + j) / 2; int r1, r2; r1 = somme( i, mid ); r2 = somme( mid+1, j ); printf( "Thread %2d: somme( %4d, %4d ) => %4d \n", omp_get_thread_num(), i, j, r1+r2 ); return( r1 + r2 ); } }
//fonction principale int main(){ int n,i; double k,c; k=0.000001; c=1; while(c>k) { printf("donnez un entier positif:\n"); scanf("%d",&n); c=somme(n+1)-somme(n); printf("\nSomme(%d+1)-Somme (%d) vaut :%f \n",n,n,c); printf("La precision vaut:%f \n",k); } printf("La somme de %d vaut :%f",n,somme(n)); }
int main() { int t[4]; t[0] = 12; t[1] = 3; t[2] = -5; t[3] = 10; printf("résultat de la somme : %d\n",somme(t,4)); printf("résultat du max : %d\n",max(t,4)); printf("résultat du dernier : %d\n",dernier(t,4)); printf("résultat nombre de nombres pairs : %d\n",pairs(t,4)); return 0; }
int main() { int n=0; printf("\nVeuillez entrer un nombre entier positif : "); scanf("%i",&n); int copiedux=n; printf("\nLa somme des %i premier entiers est : %i\n",copiedux,somme(n)); }
liste fibonacci(int n){ liste actuel = entier_vers_grand_entier(0); liste suivant = entier_vers_grand_entier(1); liste tmp; while(n--){ tmp = ecriture_canonique_grand_entier(somme(actuel, suivant)); actuel = suivant; suivant = tmp; } return actuel; }
void init(tab cmd){ if (!strcmp(cmd, "addition")) { int a,b; printf("Enter two integers :\n"); scanf("%d %d", &a, &b); printf("%d + %d = %d \n", a, b, addition(a, b)); } else if (!strcmp(cmd, "pgcd")) { int a,b; printf("Enter two integers :\n"); scanf("%d %d", &a, &b); printf("pgcd (%d, %d) = %d \n", a, b, pgcd(a, b)); } else if (!strcmp(cmd, "somme")) { int a; printf("Enter one integer :\n"); scanf("%d", &a); printf("Somme des %d premiers entiers = %d \n", a, somme(a)); } else if (!strcmp(cmd, "factorielle")) { int a; printf("Enter one integers :\n"); scanf("%d", &a); printf("(%d)! = %d \n", a, factorielle(a)); } else if (!strcmp(cmd, "puissance")) { float a,b; printf("Enter two floats :\n"); scanf("%f %f", &a, &b); printf("(%g ^ %g) = %g \n", a, b, puissance(a, b)); } else if (!strcmp(cmd, "isocele")) { int a; printf("Enter one integer :\n"); scanf("%d", &a); isocele(a); } else if (!strcmp(cmd, "cercle")) { int a; printf("Enter one integer :\n"); scanf("%d", &a); cercle(a); } else { printf("Command not found \n"); printf("Running listAll ... ? \n"); } return ; }
int somme(int p) { int c=0; if (p<10) return c + p; if (p>=10) { c += p%10; p = p/10; return c + somme(p); } }
//fonction principale int main(){ int a, b; srand(time(NULL)); a = rand() % 8 + 2; b = factorielle(a); printf("\nFactorielle de %d vaut %d\n\n", a, b); a = rand() % 100; b = somme(a); printf("\nLa somme des entiers de 1 a %d vaut %d\n\n", a, b); a = rand() % 100; b = rand() % 100; printf("\nLe maximum entre %d et %d vaut %d\n\n", a, b, maximum(a,b)); return 0; }
void Dijkstra(graphe* pg, int i0, int p[], int lambda[]){ int i, j; int s; int lambdamin; int listeSommets[MAX_VERTEX_NUM]; p[i0] = -1; lambda[i0] = 0; for(i=0; i<pg->n; i++){ lambda[i] = LMDMAX; listeSommets[i]=0; } listeSommets[i0]=1; lambda[i0]=0; i = i0; while(somme(listeSommets,pg->n)!=pg->n){ j= successeur(i , -1, pg); printf("Premier successeur de %d = %d\n", i, j); while(j != -1){ if(listeSommets[j] == 0){ printf("->%d, courant lambda[%d] = %d\n", j, j, lambda[j]); printf("lambda[%d](%d) + val(%d -> %d)(%d) = %d\n", i, lambda[i], i, j, pg->tab[i][j], lambda[i] + pg->tab[i][j]); if(lambda[j]>lambda[i] + pg->tab[i][j]){ lambda[j]=lambda[i] + pg->tab[i][j]; p[j] = i; printf("->%d, nouveau labmda[%d] = %d\n", j, j, lambda[j]); } } j=successeur(i, j, pg); } printf("\n"); lambdamin=1+pg->n*LMDMAX; i=-1; for(s=0; s<pg->n; s++){ if(listeSommets[s] == 0 && lambda[s] < lambdamin){ i=s; lambdamin=lambda[i]; } } printf("On sélectionne le sommet %d de marque minimum lambda = %d\n", i, lambdamin); listeSommets[i]=1; } }
int main(int argc, char *argv[]) { int N; printf("Nombre: "); scanf("%i",&N); /* while (N>10) { S+= N%10; N/=10; } S+=N; */ printf("Somme: %i\n",somme(N)); system("pause"); return 0; }
void regression(float Xi[],float Yi[],int N,float result[],float ProduitXiYi[],float carre_ecart_a_moyenne_Xi[],float carre_ecart_a_moyenne_Yi[]) { float SommeXi; float SommeYi; float MoyenneXi; float MoyenneYi; float SommeProduitXiYi; float SommeCarreXiMoinMoyenneXi; float SommeCarreYiMoinMoyenneYi; float a; float b; double r; float tab_ecart_a_moyenne[MAX]; float ecart_a_moyenne_Xi[MAX]; float ecart_a_moyenne_Yi[MAX]; int i=1; /*Calcul de la somme des Xi et Yi*/ SommeXi= somme(Xi,N); SommeYi= somme(Yi,N); /*Calcul des moyennes des Xi et Yi*/ MoyenneXi = moyenne(SommeXi,N); MoyenneYi = moyenne(SommeYi,N); /*Calcul de de la pente "a"de la droite et de l'ordonee à l'origine "b" */ /*Somme des Xi*Yi*/ produittab(Xi,Yi,ProduitXiYi,N); SommeProduitXiYi = somme(ProduitXiYi,N); /*calcul des (Xi- MoyenneXi)² et (Yi- MoyenneYi)² */ ecart_a_moyenne(Xi,tab_ecart_a_moyenne,MoyenneXi,N); i=1; while (i<(N+1)) { ecart_a_moyenne_Xi[i] = tab_ecart_a_moyenne[i]; carre_ecart_a_moyenne_Xi[i] = ((ecart_a_moyenne_Xi[i])*(ecart_a_moyenne_Xi[i]));i++; }; ecart_a_moyenne(Yi,tab_ecart_a_moyenne,MoyenneYi,N); i=1; while (i<(N+1)) { ecart_a_moyenne_Yi[i] = tab_ecart_a_moyenne[i]; carre_ecart_a_moyenne_Yi[i] = ((ecart_a_moyenne_Yi[i])*(ecart_a_moyenne_Yi[i]));i++; }; /*Somme des (Xi- MoyenneXi)²*/ SommeCarreXiMoinMoyenneXi = somme(carre_ecart_a_moyenne_Xi,N); SommeCarreYiMoinMoyenneYi = somme(carre_ecart_a_moyenne_Yi,N); /*Appel de la fonction de calcul de la pente "a" de la droite*/ a=pente(SommeProduitXiYi,MoyenneXi,MoyenneYi,SommeCarreXiMoinMoyenneXi,N); /*Appel de la fonction de calcul de l'ordonee a l'orrigine "b"*/ b=ordonee(MoyenneXi,MoyenneYi,a); /*Calcul du coefficient de corrélation "r"*/ r=corr(SommeCarreXiMoinMoyenneXi,SommeCarreYiMoinMoyenneYi,a); /*Stockage des résultats dans une tableau de varialbes*/ result[0]=SommeXi; result[1]=SommeYi; result[2]=MoyenneXi; result[3]=MoyenneYi; result[4]=SommeProduitXiYi; result[5]=SommeCarreXiMoinMoyenneXi; result[6]=SommeCarreYiMoinMoyenneYi; result[7]=a; result[8]=b; result[9]=r; }
double HrPwWindow::moyenne(QVector<int> &tab,int n) { double moyenne = double(somme(tab,n))/n; return (moyenne); }
int somme(int x) { if (x<0) return 0; return (x+somme(x-1)); }
/*! * \brief Calcule la littérale résultante de l'expression */ Litterale* LitteraleExpression::eval() { Interpreteur& inter=Interpreteur::getInstance(); FactoryLitterale& fl=FactoryLitterale::getInstance(); FactoryOperateur& fo=FactoryOperateur::getInstance(); string s(exp); regex e; smatch m; // Traitement des opérateurs unaires s'appliquant à l'expression regex opUnaire("([A-Z](?:[A-Z]|[0-9])*)\\(([^,\\(\\)]+)\\)"); while (std::regex_search (s,m,opUnaire)) { cout<<m[0]<<" "<<m[1]<<" "<<m[2]<<endl; // m[1] l'opérateur et m[2] l'argument if(inter.isOperateur(m[1])) { Litterale* l1 = fl.newLitteraleExpression(m[2])->eval(); Operateur* op= inter.toOperateur(m[1]); return op->applyUnaire(l1); } } // Traitement des opérateurs binaires s'appliquant à l'expression regex opBinaire("([A-Z](?:[A-Z]|[0-9])*)\\(([^,\\(]+),([^,\\(\\)]+)\\)"); while (std::regex_search (s,m,opBinaire)) { //cout<<m[0]<<" "<<m[1]<<" "<<m[2]<<" "<<m[3]<<endl; // m[1] l'opérateur et m[2] l'argument 1 et m[2] l'argument 2 if(inter.isOperateur(m[1])) { Litterale* l1 = fl.newLitteraleExpression(m[2])->eval(); Litterale* l2 = fl.newLitteraleExpression(m[3])->eval(); Operateur* op= inter.toOperateur(m[1]); return op->applyBinaire(l1,l2); } } // Remplacement des variables par leur contenu regex atome("((?:[[:upper:]]{1})(?:[[:upper:]]|[[:digit:]])*)"); while (regex_search(s,m,atome)) { LitteraleAtome* var = LitteraleAtome::getVar(m[1]); if(var) { Litterale* c = var->getValeur(); s.replace(s.find(m[0]), m[0].length(), c->toString()); } } // Traitement des groupes parenthésés // Le but est de ne se retrouver qu'avec // une suite d'opérations arithmétiques sans parenthèses regex paren("\\(([^\\(]*?)\\)"); while (regex_search(s,m,paren)) { //cout<<m[0]<<" va être remplcé par "<<m[1]<<endl; Litterale* c = fl.newLitteraleExpression(m[1])->eval(); //cout<<"av. "<<s<<endl; s.replace(s.find(m[0]), m[0].length(), c->toString()); //cout<<"apr. "<<s<<endl; } // Traitement des + et - regex somme("([^\\+]*[1-9])([\\+-])(.+)"); if (regex_search(s,m,somme)) { //cout<<m[1]<<" "<<m[2]<<" "<<m[3]<<endl; // Conversion en littérale des deux cotés Litterale* l1=fl.newLitteraleExpression(m[1])->eval(); // On converti en littérale la partie gauche Litterale* l2=fl.newLitteraleExpression(m[3])->eval(); // On converti en littérale la partie droite // Création de l'opérateur OperateurNumerique* op=fo.newOperateurNumerique(m[2]); // Application du résultat Litterale* l3=op->applyBinaire(l1, l2); return l3; } // Traitement des * et / regex produit("([^\\+]*[1-9])([\\*/])(.+)"); if (regex_search(s,m,produit)) { //cout<<m[1]<<" "<<m[2]<<" "<<m[3]<<endl; // Conversion en littérale des deux cotés Litterale* l1=fl.newLitteraleExpression(m[1])->eval(); // On converti en littérale la partie gauche Litterale* l2=fl.newLitteraleExpression(m[3])->eval(); // On converti en littérale la partie droite // Création de l'opérateur OperateurNumerique* op=fo.newOperateurNumerique(m[2]); // Application du résultat Litterale* l3=op->applyBinaire(l1, l2); return l3; } // On vérifie que ce n'est pas tout simplement une littérale if(inter.isLitterale(s)) { return inter.toLitterale(s); } return nullptr; }
double HrPwWindow::moyenne(QVector<double> &tab,int n) { double moyenne = somme(tab,n)/n; return (moyenne); }
//OK //No comment int moyenne(Arbre* racine) { return somme(racine)/taille(racine); }
double gmuon_(void) { /*compute the total g-2 from supersymmetry. Parameters are : Mmu : muon mass Mz : Z-boson's mass Mw : W-boson's mass s2thw : sin^2(thw) e : alpha modM1 & argM1 : modulus and argument of M1 modM2 & argM2 : modulus and argument of M2 modmu & argmu : modulus and argument of mu modAmu & argAmu : modulus and argument of Amu */ /*declaration des variables*/ double thw, cb,cw,sw, ymu, g1,masssneutr, g2,gmuo = 0,beta,Mz,Mw,Mmu,e,tbeta; matrix massmatrc,massmatrn,massmatrsmu; matrix Ncomp, Nconj,N,Ucomp,Uconj,U,Vcomp,Vconj,V,X,Xconj,Xcomp; vecteur massen,massec,massesmu; double coeff1 ,coeff2; matrix matrixtemp,matrixtemp2,matrixtemp3,matrixtemp4,matrixtemp5; my_complex nc1,nc2; int i,j; /*Memory Allocation*/ massmatrn=initm(4); massmatrc=initm(2); massmatrsmu=initm(2); Ncomp=initm(4); Nconj=initm(4); N=initm(4); Ucomp=initm(2); Vcomp=initm(2); X=initm(2); U=initm(2); V=initm(2); Uconj=initm(2); Vconj=initm(2); Xcomp=initm(2); Xconj=initm(2); massen=initv(4); massesmu=initv(2); massec=initv(2); matrixtemp=initm(2); matrixtemp2=initm(2); matrixtemp3=initm(4); matrixtemp4=initm(4); matrixtemp5=initm(4); /*Get the values for the masses and mixing matrices*/ e=sqrt(4*M_PI*0.00781653); sw=0.48076; Mz=91.1876; Mmu=0.1057; findVal("tB",&tbeta); beta = atan(tbeta); cb = cos(beta); thw=asin(sw); cw=cos(thw); Mw=Mz*cw; g1 = e/cw; g2 = e/sw; ymu = g2 * Mmu / (sqrt(2)*cb*Mw); findVal("MNE1",&massen.e[0].r); findVal("MNE2",&massen.e[1].r); findVal("MNE3",&massen.e[2].r); findVal("MNE4",&massen.e[3].r); findVal("MC1",&massec.e[0].r); findVal("MC2",&massec.e[1].r); findVal("MSnm",&masssneutr); findVal("Zn11",&Nconj.e[0][0].r); findVal("Zn12",&Nconj.e[1][0].r); findVal("Zn13",&Nconj.e[2][0].r); findVal("Zn14",&Nconj.e[3][0].r); findVal("Zn21",&Nconj.e[0][1].r); findVal("Zn22",&Nconj.e[1][1].r); findVal("Zn23",&Nconj.e[2][1].r); findVal("Zn24",&Nconj.e[3][1].r); findVal("Zn31",&Nconj.e[0][2].r); findVal("Zn32",&Nconj.e[1][2].r); findVal("Zn33",&Nconj.e[2][2].r); findVal("Zn34",&Nconj.e[3][2].r); findVal("Zn41",&Nconj.e[0][3].r); findVal("Zn42",&Nconj.e[1][3].r); findVal("Zn43",&Nconj.e[2][3].r); findVal("Zn44",&Nconj.e[3][3].r); findVal("Zu11",&Uconj.e[0][0].r); findVal("Zu12",&Uconj.e[1][0].r); findVal("Zu21",&Uconj.e[0][1].r); findVal("Zu22",&Uconj.e[1][1].r); findVal("Zv11",&Vcomp.e[0][0].r); findVal("Zv12",&Vcomp.e[0][1].r); findVal("Zv21",&Vcomp.e[1][0].r); findVal("Zv22",&Vcomp.e[1][1].r); { double MSmuLL,MSmuRR,MSmuLR,Am,mu,MSmuth; MSmuLL=findValW("MSmL"); MSmuLL*=MSmuLL; MSmuRR=findValW("MSmR"); MSmuRR*=MSmuRR; Am=findValW("Am"); mu=findValW("mu"); MSmuLR=(Am-mu*tbeta)*Mmu; massesmu.e[0].r=sqrt((MSmuLL+MSmuRR-sqrt((MSmuLL-MSmuRR)*(MSmuLL-MSmuRR)+4*MSmuLR*MSmuLR))/2); massesmu.e[1].r=sqrt((MSmuLL+MSmuRR+sqrt((MSmuLL-MSmuRR)*(MSmuLL-MSmuRR)+4*MSmuLR*MSmuLR))/2); MSmuth=atan2(-2*MSmuLR, -MSmuLL+MSmuRR)/2; X.e[0][0].r=cos(MSmuth); X.e[0][1].r=sin(MSmuth); X.e[1][0].r=-X.e[0][1].r; X.e[1][1].r=X.e[0][0].r; } for(i=0;i<4;i++) if (massen.e[i].r<0) {for(j=0;j<4;j++) {Nconj.e[j][i]=prod(icomp,Nconj.e[j][i]); } massen.e[i].r=-massen.e[i].r; } for(i=0;i<2;i++) {if (massec.e[i].r<0) {for(j=0;j<2;j++) { Uconj.e [j][i]=prod(icomp,Uconj.e[j][i]); Vcomp.e [i][j]=prod(icomp,Vcomp.e[i][j]); } massec.e[i].r=-massec.e[i].r; } if (massesmu.e[i].r<0) {for(j=0;j<2;j++) {X.e [i][j]=prod(icomp,X.e[i][j]); } massesmu.e[i].r=-massesmu.e[i].r; } } N=adj(Nconj); U=adj(Uconj); /*Compute the coefficients entering the formula for the neutral and chargino contribution to g-2_muon and calculates gmuon*/ /*neutralinos*/ for ( i=0;i<4;i=i+1) for ( j=0;j<2;j=j+1) {nc1=somme(prodscal(sqrt(2)*g1,prod(N.e[i][0],X.e[j][1])),prodscal(ymu,prod(N.e[i][2],X.e[j][0]))); nc2=diff(prodscal(1/sqrt(2),prod(somme(prodscal(g2,N.e[i][1]),prodscal(g1,N.e[i][0])),conjug(X.e[j][0]))),prodscal(ymu,prod(N.e[i][2],conjug(X.e[j][1])))); coeff1 =(somme(prod(nc1,conjug(nc1)),prod(nc2,conjug(nc2)))).r; coeff2 = prod(nc1,nc2).r; if (massesmu.e[j].r<1e-8) {return 0; printf("erreur : Mass smuons nul\n");} gmuo=gmuo+calcgmuon (0,Mmu, massen.e[i].r, massesmu.e[j].r,coeff1, coeff2); } /*charginos*/ for (j=0;j<2;j=j+1) { nc1=prodscal(ymu,U.e[j][1]); nc2=prodscal(-g2,conjug(Vcomp.e[j][0])); coeff1 =(somme(prod(nc1,conjug(nc1)),prod(nc2,conjug(nc2)))).r; coeff2 = prod(nc1,nc2).r; if (masssneutr<1e-8) {return 0; printf("erreur : Mass sneutrinos nul\n");} gmuo=gmuo+calcgmuon (1,Mmu, massec.e[j].r, masssneutr,coeff1, coeff2); } return gmuo; }