/*--------------------------------------------------------------------------*/ SciErr getVarAddressFromPosition(void *_pvCtx, int _iVar, int **_piAddress) { SciErr sciErr = getinternalVarAddress(_pvCtx, _iVar, _piAddress); //sciprint("type : %d(%c)\n", (*_piAddress)[0], intersci_.ntypes[_iVar - 1]); //update variable state to "read intersci_.ntypes[_iVar - 1] = '$'; return sciErr; }
/*--------------------------------------------------------------------------*/ int getRhsFromAddress(void *_pvCtx, int *_piAddress) { int i = 0; int *piAddr = NULL; for (i = 0; i < Rhs; i++) { //sciprint("getRhsFromAddress ->"); getinternalVarAddress(_pvCtx, i + 1, &piAddr); if (_piAddress == piAddr) { return i + 1; } } return 0; }
/*--------------------------------------------------------------------------*/ int getInputArgumentType(void* _pvCtx, int _iVar) { int* piAddr = NULL; int iType = 0; //sciprint("getInputArgumentType ->"); SciErr sciErr = getinternalVarAddress(_pvCtx, _iVar, &piAddr); if (sciErr.iErr) { return 0; } sciErr = getVarType(_pvCtx, piAddr, &iType); if (sciErr.iErr) { return 0; } return iType; }
/*--------------------------------------------------------------------------*/ SciErr getProcessMode(void *_pvCtx, int _iPos, int *_piAddRef, int *_piMode) { SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0; int iRows1 = 0; int iCols1 = 0; int iRows2 = 0; int iCols2 = 0; int iType2 = 0; int iMode = 0; int *piAddr2 = NULL; sciErr = getVarDimension(_pvCtx, _piAddRef, &iRows1, &iCols1); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get argument dimension"), "getProcessMode"); return sciErr; } //sciprint("getProcessMode ->"); sciErr = getinternalVarAddress(_pvCtx, _iPos, &piAddr2); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get variable address"), "getProcessMode"); return sciErr; } sciErr = getVarType(_pvCtx, piAddr2, &iType2); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get argument type"), "getProcessMode"); return sciErr; } if (iType2 == sci_matrix && !isVarComplex(_pvCtx, piAddr2)) { double *pdblReal2 = NULL; sciErr = getMatrixOfDouble(_pvCtx, piAddr2, &iRows2, &iCols2, &pdblReal2); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get argument data"), "getProcessMode"); return sciErr; } if (iRows2 != 1 || iCols2 != 1) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Wrong size for argument %d: (%d,%d) expected.\n"), "getProcessMode", _iPos, 1, 1); return sciErr; } iMode = (int)pdblReal2[0]; } else if (iType2 == sci_strings) { int iLen = 0; char *pstMode[1] = { "" }; sciErr = getVarDimension(_pvCtx, piAddr2, &iRows2, &iCols2); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get argument dimension"), "getProcessMode"); return sciErr; } if (iRows2 != 1 || iCols2 != 1) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Wrong size for argument %d: (%d,%d) expected.\n"), "getProcessMode", _iPos, 1, 1); return sciErr; } sciErr = getMatrixOfString(_pvCtx, piAddr2, &iRows2, &iCols2, &iLen, NULL); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get argument data"), "getProcessMode"); return sciErr; } pstMode[0] = (char *)MALLOC(sizeof(char) * (iLen + 1)); //+1 for null termination sciErr = getMatrixOfString(_pvCtx, piAddr2, &iRows2, &iCols2, &iLen, pstMode); if (sciErr.iErr) { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Unable to get argument data"), "getProcessMode"); return sciErr; } iMode = (int)pstMode[0][0]; FREE(pstMode[0]); } else { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Wrong type for input argument #%d: A string or a scalar expected.\n"), "getProcessMode", _iPos); return sciErr; } if (iMode == ROW_LETTER || iMode == BY_ROWS) { *_piMode = BY_ROWS; } else if (iMode == COL_LETTER || iMode == BY_COLS) { *_piMode = BY_COLS; } else if (iMode == STAR_LETTER || iMode == BY_ALL) { *_piMode = BY_ALL; } else if (iMode == MTLB_LETTER || iMode == BY_MTLB) { *_piMode = 0; if (iRows1 > 1) { *_piMode = 1; } else if (iCols1 > 1) { *_piMode = 2; } } else { addErrorMessage(&sciErr, API_ERROR_GET_PROCESSMODE, _("%s: Wrong value for input argument #%d: '%s' or '%s' expected.\n"), "getProcessMode", _iPos, "'*', 'r', 'c', 'm', '0', '1', '2'", "-1"); return sciErr; } return sciErr; }