static void dfrexpsTest ( void ) { int i = 0 ; double out = 0 ; double dexp = 0 ; double result = 0; double in[] = DMATRIX_TEST ; for ( i = 0 ; i < SIZE; i++ ) { out = dfrexps ( in[i] , &dexp ) ; result = out * dpows( 2 , dexp) ; printf ( "\t\t %d in :%e %e\tresult : %e\tassert : %e \n" , i , dexp, in[i] , result , fabs( in[i] - result) / fabs( in[i]) ) ; assert ( fabs ( in[i] - result) / fabs( in[i]) < 3e-16 ) ; } }
/*--------------------------------------------------------------------------*/ int sci_frexp(char *fname, void *pvApiCtx) { SciErr sciErr; int i; int iRows = 0; int iCols = 0; int iType = 0; int *piAddr = NULL; double *pdblReal = NULL; double *pdblCoef = NULL; double *pdblExp = NULL; CheckRhs(1, 1); CheckLhs(2, 2); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = getVarType(pvApiCtx, piAddr, &iType); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } if (iType != sci_matrix) { OverLoad(1); return 0; } if (isVarComplex(pvApiCtx, piAddr)) { Scierror(999, _("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 1); return 0; } sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 1, iRows, iCols, &pdblCoef); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = allocMatrixOfDouble(pvApiCtx, Rhs + 2, iRows, iCols, &pdblExp); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } for (i = 0; i < iRows * iCols; i++) { pdblCoef[i] = dfrexps(pdblReal[i], &pdblExp[i]); } LhsVar(1) = Rhs + 1; LhsVar(2) = Rhs + 2; PutLhsVar(); return 0; }