/*--------------------------------------------------------------------------*/ static int getCommonAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg) { SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0; sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, NULL, NULL, NULL); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols); sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols); for (int i = 0 ; i < *_piRows * *_piCols ; i++) { (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]); } if (_iComplex) { *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols); for (int i = 0 ; i < *_piRows * *_piCols ; i++) { (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * (*_piNbCoef)[i]); } } sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, _pdblImg == NULL ? NULL : *_pdblImg); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } return 0; }
/*--------------------------------------------------------------------------*/ static int getCommonAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg) { SciErr sciErr = sciErrInit(); int iRows = 0; int iCols = 0; double* pdblReal = NULL; double* pdblImg = NULL; if (isScalar(_pvCtx, _piAddress) == 0) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, NULL, NULL); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } *_pdblReal = (double*)MALLOC(sizeof(double) **_piNbCoef); if (_iComplex) { *_pdblImg = (double*)MALLOC(sizeof(double) **_piNbCoef); } sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, _pdblReal, _pdblImg); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress)); printError(&sciErr, 0); return sciErr.iErr; } return 0; }
SciErr getComplexMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg) { return getCommonMatrixOfPoly(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg); }
SciErr getMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal) { return getCommonMatrixOfPoly(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL); }