vendredi 31 juillet 2015

Fortran array Index

I am migrating the Fortran code to C. I would like to know what will be the c equivalent for the following statements T is 2d array dim T (D,D) and T_indices is array of indices in T , T_indices(E) where E< D.

T(T_indices(:),:) = 1/(A/B)*T(T_indices(:),:)

T(:,T_indices(:)) = 1/(A/B)*T(:,T_indices(:))  

C interpretation

for (i=0 ; i < E ; i++){
 for (j=0 ; j< B ; j++){
  T[T_indices[i] * B + j] = 1/(A/B)* T[T_indices[i] * B + j];
  T[J * B + T_indices[i]] = 1/(A/B)* T[J * B + T_indices[i]];
 }
}

Is this valid interpretation ?

Aucun commentaire:

Enregistrer un commentaire