/**IsEqualDoubleMat * Used to test a couple of Scilab variable of type 1 (matrix of floating point numbers) * or 9 (graphic handles) for equality* * @param double *d1: pointer on the beginning of the first variable structure * @param double *d2: pointer on the beginning of the first variable structure * @return 0 is the variables differ and 1 if they are identical * @author Serge Steer * @see IsEqualVar */ int IsEqualDoubleMat(double *d1, double *d2) { int n; int *id1 = (int *) d1; int *id2 = (int *) d2; /* Check the type */ if ((id1[0] != id2[0])) return 0; /* Check the number of rows */ if (id1[1] != id2[1]) return 0; /* Check the number of columns */ if (id1[2] != id2[2]) return 0; /* Check the real/complex flag */ if (id1[3] != id2[3]) return 0; n = id1[1]*id1[2]*(id1[3]+1); /* number of double precision floating point numbers */ /* check the array of numbers */ if (!IsEqualDoubleArray(n, d1+2, d2+2)) return 0; return 1; }
/**IsEqualPolyMat * Used to test a couple of Scilab variable of type 2 (matrix of polynomials) for equality * @param double *d1: pointer on the beginning of the first variable structure * @param double *d2: pointer on the beginning of the first variable structure * @return 0 is the variables differ and 1 if they are identical * @author Serge Steer * @see IsEqualVar */ int IsEqualPolyMat(double *d1, double *d2) { int l,n; int *id1 = (int *) d1; int *id2 = (int *) d2; /* Check the type */ if ((id1[0] != id2[0])) return 0; /* Check the number of rows */ if (id1[1] != id2[1]) return 0; /* Check the number of columns */ if (id1[2] != id2[2]) return 0; /* Check the real/complex flag */ if (id1[3] != id2[3]) return 0; /* Check the formal variable name */ if ( !IsEqualIntegerArray(4, id1+4, id2+4) ) return 0; /* Check the array of "pointers" */ n = id1[1]*id1[2]; if ( !IsEqualIntegerArray(n, id1+8, id2+8) ) return 0; /* Check the array of double precision numbers */ l = (n + 10)/2;/* the beginning of first field in th double array */ /* check the array of numbers */ if ( !IsEqualDoubleArray(id1[8+n]-1, d1+l, d2+l) ) return 0; return 1; }
/**IsEqualMatlabSparseMat * Used to test a couple of Scilab variable of type 7 (Matlab sparse matrix) for equality * @param double *d1: pointer on the beginning of the first variable structure * @param double *d2: pointer on the beginning of the first variable structure * @return 0 is the variables differ and 1 if they are identical * @author Serge Steer * @see IsEqualVar */ int IsEqualMatlabSparseMat(double *d1, double *d2) /* a faire */ { int l, nel; int *id1 = (int *) d1; int *id2 = (int *) d2; /* Check the type */ if ((id1[0] != id2[0])) { return 0; } /* Check the number of rows */ if (id1[1] != id2[1]) { return 0; } /* Check the number of columns */ if (id1[2] != id2[2]) { return 0; } /* Check the real/complex flag */ if (id1[3] != id2[3]) { return 0; } /* Check the number of non zero elements */ if (id1[4] != id2[4]) { return 0; } nel = id1[4]; l = 5; /* Check the array of number of non zero element per column */ if ( !IsEqualIntegerArray(id1[2], id1 + l, id2 + l) ) { return 0; } l += id1[2]; /* Check the column index of non zero elements */ if ( !IsEqualIntegerArray(nel, id1 + l, id2 + l) ) { return 0; } l += nel; /* Check the non zero elements */ l = (l + 1) / 2; if ( !IsEqualDoubleArray(nel * (id1[3] + 1), d1 + l, d2 + l) ) { return 0; } return 1; }