0
 int row,col,i,j,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7;
 if(M==64&&N==64){
    for(row=0;row<N;row+=8){
        for(col=0;col<M;col+=8){
             for(j=0;j<2;j++){
                for(i=row;i<row+4;i++){
                    tmp0=A[i+4j][col+0];
                    tmp1=A[i+4j][col+1];
                    tmp2=A[i+4j][col+2];
                    tmp3=A[i+4j][col+3];
                    tmp4=A[i+4j][col+4];
                    tmp5=A[i+4j][col+5];
                    tmp6=A[i+4j][col+6];
                    tmp7=A[i+4j][col+7];

                    B[col+0+4j][i]=tmp0;
                    B[col+1+4j][i]=tmp1;
                    B[col+2+4j][i]=tmp2;
                    B[col+3+4j][i]=tmp3;
                    B[col+0+4j][i+4]=tmp4;
                    B[col+1+4j][i+4]=tmp5;
                    B[col+2+4j][i+4]=tmp6;
                    B[col+3+4j][i+4]=tmp7;

                }

but I got the code the error: array subscript is not an integer. But I don't know why. Could someone have a look at and tell me why? I do not think I use other type in the array besides int.

2
  • 1
    Replace all those 4j with 4*j and try again. Commented Feb 27, 2014 at 10:25
  • What is 4j in all those lines? Commented Feb 27, 2014 at 10:25

4 Answers 4

3

C does not support implicit multiplication like you commonly see in math. It obviously wouldn't work, since variable names can be more than one letter, it would create a huge amount of parsing confusion.

By your (implied) logic, an expression such as row < N should then be the same as r * o * w < N, which is clearly not what you really think.

Thus, multiplication must always be done explicitly using the * binary operator: 4j is a parse error, you meant 4 * j.

Sign up to request clarification or add additional context in comments.

Comments

1
 int row,col,i,j,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7;
  if(M==64&&N==64){
    for(row=0;row<N;row+=8){
        for(col=0;col<M;col+=8){
         for(j=0;j<2;j++){
            for(i=row;i<row+4;i++){
                tmp0=A[i+4*j][col+0];
                tmp1=A[i+4*j][col+1];
                tmp2=A[i+4*j][col+2];
                tmp3=A[i+4*j][col+3];
                tmp4=A[i+4*j][col+4];
                tmp5=A[i+4*j][col+5];
                tmp6=A[i+4*j][col+6];
                tmp7=A[i+4*j][col+7];

                B[col+0+4*j][i]=tmp0;
                B[col+1+4*j][i]=tmp1;
                B[col+2+4*j][i]=tmp2;
                B[col+3+4*j][i]=tmp3;
                B[col+0+4*j][i+4]=tmp4;
                B[col+1+4*j][i+4]=tmp5;
                B[col+2+4*j][i+4]=tmp6;
                B[col+3+4*j][i+4]=tmp7;

            }

Comments

0
tmp0=A[i+4j][col+0];

It should be

tmp0=A[i+4*j][col+0];

replace at all places

Comments

0

Multiplication should be called explicitly: in your case, 4*j instead of 4j.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.