- //TODO: affec = apply(gam, 1,which.max) à traduire, et retourner affec aussi.
+ //affec = apply(gam, 1, which.max)
+ for (int i=0; i<n; i++)
+ {
+ Real rowMax = 0.;
+ affec[i] = 0;
+ for (int j=0; j<k; j++)
+ {
+ if (gam[mi(i,j,n,k)] > rowMax)
+ {
+ affec[i] = j+1; //R indices start at 1
+ rowMax = gam[mi(i,j,n,k)];
+ }
+ }
+ }