Fortran array Index

时间:2015-07-31 20:54:09

标签: c arrays fortran fortran90

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 a 2d array of dimension (B,B) and T_indices is an array of indices in T , T_indices(E) where E < B. Ai and Bi are variables.

T(T_indices(:),:) = 1/(Ai/Bi)*T(T_indices(:),:)

T(:,T_indices(:)) = 1/(Ai/Bi)*T(:,T_indices(:))  

My proposed C translation:

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

Is this a correct translation?

0 个答案:

没有答案