Complex Wave used in real expression

Hello,
When running the following function I always get a "Complex Wave used in real expression". The debugger shows that this happens in one of the if statements.
What is the problem?
Function getOmegaRsqr(rootWave,outputwave)
    Wave/C rootWave
    Wave outputwave
    NVAR alpha,betaa,bigOmega, omega0sqr
    Variable c1,c2,force
    variable j = 0
    for(j=0;j<dimSize(rootWave,0);j+=1)
        force = pnt2x(rootWave,j)
        c1 = (alpha*force^2)/(2*bigOmega^2)
        c2 = omega0sqr + (3*betaa*force^2)/(2*bigOmega^2)

        make/o/d/n=2 rootsTEMP
        variable count =0
        variable i=0
        for(i=0;i<3;i+=1)
            if((abs(imag(rootWave[j][i])/sqrt(magsqr(rootWave[j][i]))))<0.00000001)     //"Complex Wave used in real expression"
                if(c2+2*alpha*rootWave[j][i] + 3*betaa*(rootWave[j][i])^2 > 0)         //or possibly here
                    rootsTEMP[count]=real(rootWave[j][i])
                    count+=1
                endif  
            elseif((abs(sqrt(magsqr(rootWave[j][i]))))<0.0000000000000001)              //"Complex Wave used in real expression"
                if(c2+2*alpha*rootWave[j][i] + 3*betaa*(rootWave[j][i])^2 > 0)       //or possibly here
                    rootsTEMP[count]=real(rootWave[j][i])
                    count+=1
                endif  
            endif
        Endfor
        Variable root
        if(count == 0)
            print force
        endif
        if(count ==1)
            root = rootsTEMP[0]
        elseif(count == 2)
            //print rootsTEMP
            if(alpha>0)
                root = wavemax(rootsTEMP)
            else
                root = wavemin(rootsTEMP)
            endif
        endif
        //print root
        outputwave[j] = c2 + 2*alpha*root+ 3*betaa*root^2
    Endfor
    killwaves rootsTEMP
End
Must be these constructs:
if(c2+2*alpha*rootWave[j][i] + 3*betaa*(rootWave[j][i])^2 > 0)  

since the "if" commands expects a real value and the compiler is told ("/C") that rootwave is complex.
There is some "magsqr", "real", "imag", etc missing (like you used them in the line just above :-) )

HJ
HJDrescher wrote:
Must be these constructs:
if(c2+2*alpha*rootWave[j][i] + 3*betaa*(rootWave[j][i])^2 > 0)  

since the "if" commands expects a real value and the compiler is told ("/C") that rootwave is complex.
There is some "magsqr", "real", "imag", etc missing (like you used them in the line just above :-) )

HJ



You are right, thanks. The first "if" checks if the number is real so I assumed that the value is "real".