Exemple #1
0
/**IsEqualOverloaded
* Used to call the overloading function when testing unknown data type  for equality
* @param double *d1: pointer on the beginning of the first variable structure
* @param int n1: memory size used by the first variable, only used for overloading
* @param double *d2: pointer on the beginning of the first variable structure
* @param int n2: memory size used by the second variable, only used for overloading
* @return 0 is the variables differ and 1 if they are identical, -1 for recursion purpose
* @author Serge Steer
* @see IsEqualVar
*/
int IsEqualOverloaded(double *d1, int n1, double *d2, int n2)
{
    int *id1 = (int *) d1;
    int *id2 = (int *) d2;
    int il, lw;
    int l1, l2;

    initStackParameters();

    if (Rstk[Pt] == 914 || Rstk[Pt] == 915) /* coming back after evaluation of overloading function */
    {
        /* Get the computed value */
        il = iadr(*Lstk(Top));
        Top--;
        Pt--;
        return  *istk(il + 3);
    }

    /* Prepare stack for calling overloading function */
    /* put references to d1 and d2 variable at the top of the stack */
    l1 = *Lstk(1) + (int)(d1 - stk(*Lstk(1))); /*compute index in stk from absolute adress value */
    l2 = *Lstk(1) + (int)(d2 - stk(*Lstk(1))); /*compute index in stk from absolute adress value */

    Top = Top + 1;

    il = iadr(*Lstk(Top));
    *istk(il) = -id1[0];
    *istk(il + 1) = l1; /* index othe first element of the variable in stk */
    *istk(il + 2) = 0; /* variable number unknown */
    *istk(il + 3) = n1; /* variable memory size  */
    *Lstk(Top + 1) = *Lstk(Top) + 2;

    Top = Top + 1;
    il = iadr(*Lstk(Top));
    *istk(il) = -id2[0];
    *istk(il + 1) = l2; /* index othe first element of the variable in stk */
    *istk(il + 2) = 0; /*variable number unknown */
    *istk(il + 3) = n2; /*variable memory size */
    *Lstk(Top + 1) = *Lstk(Top) + 2;

    Ptover(1);
    Rhs = 2;
    lw = Top - 1;

    if ( GetDoubleCompMode() == 0)
    {
        C2F(overload)(&lw, "isequalbitwise", 14L);
        Rstk[Pt] = 914;
    }
    else
    {
        C2F(overload)(&lw, "isequal", 7L);
        Rstk[Pt] = 915;
    }

    /*DEBUG_OVERLOADING("IsEqualVar Overloaded calls the parser Top=%d, Rhs=%d, Pt=%d\n",Top,Rhs,Pt);*/

    return -1;
}
/**IsEqualDoubleArray
* compare if two double precision arrays of size n, are identical.
* If the arrays conatins NaN the meaning depends on the value of the global flag IEEE_comp
*  - if DoubleCompMode==1, double numbers are compared using "==", so Nan != NaN.
*  - if DoubleCompMode==0, double numbers are compared bitwize.
* @param int n: array size
* @param double *d1: pointer on the beginning of the first array
* @param double *d2: pointer on the beginning of the second array
* @return 0 is the arrays differ and 1 if they are identical
* @author Serge Steer
*/
int IsEqualDoubleArray(int n, double *d1, double *d2)
{
    if ( GetDoubleCompMode()) {
        return IsEqualDoubleArrayIEEE(n, d1, d2);
    }
    else {
        return IsEqualDoubleArrayBinary(n, d1, d2);
    }
}