int sci_sym_solve(char *fname, unsigned long fname_len){ int status=0; //check whether we have no input and one output argument or not CheckInputArgument(pvApiCtx, 0, 0) ;//no input argument CheckOutputArgument(pvApiCtx, 1, 1) ;//one output argument // Check environment if(global_sym_env==NULL) sciprint("Error: Symphony environment is not initialized.\n"); else {// There is an environment opened double time_limit = -1.0; status = sym_get_dbl_param(global_sym_env,"time_limit",&time_limit); if (status == FUNCTION_TERMINATED_NORMALLY) { if ( time_limit < 0.0 ) sciprint("\nNote: There is no limit on time.\n"); else sciprint("\nNote: Time limit has been set to %lf.\n",time_limit); status=process_ret_val(sym_solve(global_sym_env));// Call function } else { sciprint("\nUnable to read time limit.\n"); status = 1; //Error state } } // Return result to scilab return returnDoubleToScilab(status); }
int ScilabGateway::unwrapremove(char * fname, const int envId, void * pvApiCtx) { SciErr err; int * addr = 0; int row = 0, col = 0; int * id = 0; if (Rhs == 0) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong number of arguments : more than 1 argument expected")); } CheckOutputArgument(pvApiCtx, Rhs, Rhs); ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId); ScilabGatewayOptions & options = env.getGatewayOptions(); OptionsHelper::setCopyOccurred(false); ScilabObjects::initialization(env, pvApiCtx); options.setIsNew(false); for (int i = 1; i <= Rhs; i++) { err = getVarAddressFromPosition(pvApiCtx, i, &addr); if (err.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } if (!ScilabObjects::isExternalObj(addr, pvApiCtx)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: An External Object expected."), i); } err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id); if (err.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } if (!ScilabObjects::unwrap(*id, Rhs + i, envId, pvApiCtx)) { try { ScilabObjects::createEnvironmentObjectAtPos(EXTERNAL_OBJECT, Rhs + i, *id, envId, pvApiCtx); } catch (ScilabAbstractEnvironmentException & /*e*/) { } } LhsVar(i) = Rhs + i; env.removeobject(*id); } PutLhsVar(); return 0; }
/** * This function returns the rank of a process within the specified communicator. */ int sci_mpi_comm_rank(char *fname, void* pvApiCtx) { int comm_rank = -1; CheckInputArgument(pvApiCtx, 0, 1); // Check the parameters of the function ... Here 0 or 1 CheckOutputArgument(pvApiCtx, 1, 1); // The output of the function (1 parameter) // return the communicator from optional argument "comm" // if no optional "comm" is given, return MPI_COMM_WORLD MPI_Comm comm = getOptionalComm(pvApiCtx); if (comm == NULL) { Scierror(999, _("%s: Wrong type for input argument #%s: An MPI communicator expected.\n"), fname, "comm"); return 0; } if (comm != MPI_COMM_NULL) { MPI_Comm_rank(comm, &comm_rank); } if (createScalarDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, (double)comm_rank)) { Scierror(999, _("%s: Unable to create variable.\n"), fname); return 0; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; }
int sci_sym_getObjSense(char *fname){ //error management variable SciErr sciErr; int iRet; //data declarations int objSense; //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); return 1; } //code to check arguments and get them CheckInputArgument(pvApiCtx,0,0) ; CheckOutputArgument(pvApiCtx,1,1) ; //code to give output iRet=sym_get_obj_sense(global_sym_env,&objSense); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has a problem been loaded?\n"); return 1; } if(objSense==1) sciprint("Symphony has been set to minimize the objective.\n"); else sciprint("Symphony has been set to maximize the objective.\n"); if(returnDoubleToScilab(objSense)) return 1; return 0; }
/* Function that initializes the symphony environment * Returns 1 on success , 0 on failure */ int sci_sym_open(char *fname, unsigned long fname_len){ // Error management variable SciErr sciErr; double status=0; //check whether we have no input and one output argument or not CheckInputArgument(pvApiCtx, 0, 0) ;//no input argument CheckOutputArgument(pvApiCtx, 1, 1) ;//one output argument //check environment if(global_sym_env!=NULL){ sciprint("Warning: Symphony environment is already initialized.\n"); }else{ global_sym_env = sym_open_environment();//open an environment if (!global_sym_env) sciprint("Error: Unable to create symphony environment.\n"); else{ status=1; //sciprint("Symphony environment is created successfully. Please run 'sym_close()' to close.\n"); //create useful variables for user createNamedScalarDouble(pvApiCtx,"sym_minimize",1); createNamedScalarDouble(pvApiCtx,"sym_maximize",-1); } } /*write satus of function (success-1 or failure-0) as output argument to scilab*/ if(returnDoubleToScilab(status)) return 1; return 0; }
/** * The gateway function for soap_servers() * @param[in] fname the name of the file for the error messages * @return 0 if successful, a negative value otherwise */ int sci_empty_test(char *fname) { SciErr sciErr; // allocate memory for values double dOut = 0; char *cOut = "zero"; // this function does not take input arguments CheckInputArgument(pvApiCtx, 0, 0); // the number of output arguments must be 2 CheckOutputArgument(pvApiCtx, 2, 2); // create results on stack sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 0, 0, &dOut); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 2, 0, 0, &cOut); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2; return 0; }
int sci_sym_set_str_param(char *fname, unsigned long fname_len){ // Error management variable SciErr sciErr1,sciErr2; double status=1.0;//assume error status double num;//to store the value of the double parameter to be set int output;//output return value of the setting of symphony string parameter function int *piAddressVarOne = NULL;//pointer used to access first argument of the function int *piAddressVarTwo=NULL;//pointer used to access second argument of the function char variable_name[100],value[100];//string to hold the name of variable's value to be set and the value to be set is stored in 'value' string char *ptr=variable_name,*valptr=value;//pointer-'ptr' to point to address of the variable name and 'valptr' points to the address of the value to be set to the string parameter CheckInputArgument(pvApiCtx, 2, 2);//Check we have exactly two argument as input or not CheckOutputArgument(pvApiCtx, 1, 1);//Check we have exactly no argument on output side or not //load address of 1st argument into piAddressVarOne sciErr1 = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne); sciErr2 = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo); //check whether there is an error or not. if (sciErr1.iErr){ printError(&sciErr1, 0); return 0; } if (sciErr2.iErr){ printError(&sciErr2, 0); return 0; } //read the value in that pointer pointing to variable name int err1=getAllocatedSingleString(pvApiCtx, piAddressVarOne, &ptr); //read the value of the string variable to be set int err2=getAllocatedSingleString(pvApiCtx, piAddressVarTwo, &valptr); //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); } else { output=sym_set_str_param(global_sym_env,ptr,valptr);//symphony function to set the variable name pointed by the ptr pointer to the double value stored in 'value' variable. if(output==FUNCTION_TERMINATED_NORMALLY){ sciprint("setting of string parameter function executed successfully\n"); status=0.0; } else sciprint("Setting of the string parameter was unsuccessfull...check the input values!!\n"); } int e=createScalarDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,status); if (e){ AssignOutputVariable(pvApiCtx, 1) = 0; return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_dlgamma(char *fname, unsigned long fname_len) { SciErr sciErr; double* lX = NULL; int* piAddrX = NULL; int iType1 = 0; int MX = 0, NX = 0, i = 0; nbInputArgument(pvApiCtx) = Max(0, nbInputArgument(pvApiCtx)); CheckInputArgument(pvApiCtx, 1, 1); CheckOutputArgument(pvApiCtx, 1, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrX); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 1; } sciErr = getVarType(pvApiCtx, piAddrX, &iType1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 1; } if ((iType1 == sci_list) || (iType1 == sci_tlist) || (iType1 == sci_mlist)) { OverLoad(1); return 0; } if (isVarComplex(pvApiCtx, piAddrX)) { Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, 1); return 1; } sciErr = getMatrixOfDouble(pvApiCtx, piAddrX, &MX, &NX, &lX); if (sciErr.iErr) { Scierror(999, _("%s: Wrong type for argument %d: A matrix expected.\n"), fname, 1); } for (i = 0; i < MX * NX; i++) { lX[i] = C2F(psi)(lX + i); } AssignOutputVariable(pvApiCtx, 1) = 1; returnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_getlookandfeel(char *fname, void* pvApiCtx) { CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 1, 1); org_scilab_modules_gui_utils::LookAndFeelManager * lnf = 0; try { lnf = new org_scilab_modules_gui_utils::LookAndFeelManager(getScilabJavaVM()); } catch (const GiwsException::JniException & e) { Scierror(999, _("%s: A Java exception arisen:\n%s"), fname, e.whatStr().c_str()); return 1; } if (lnf) { static int n1 = 0, m1 = 0; char *look = lnf->getCurrentLookAndFeel(); if (look) { m1 = (int)strlen(look); n1 = 1; if (createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, look)) { Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } if (look) { delete[]look; look = NULL; } delete lnf; AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); } else { delete lnf; Scierror(999, _("%s: An error occurred: %s.\n"), fname, _("Impossible to get current look and feel")); return 1; } } else { Scierror(999, _("%s: No more memory.\n"), fname); return 1; } return 0; }
int sci_sym_get_dbl_param(char *fname, unsigned long fname_len){ // Error management variable SciErr sciErr1; double status=1.0;//assume error status int *piAddressVarOne = NULL;//pointer used to access first argument of the function char variable_name[100];//string to hold the name of variable's value to be retrieved char *ptr=variable_name;//pointer to point to address of the variable name int output;//output parameter for the symphony get_dbl_param function CheckInputArgument(pvApiCtx, 1, 1);//Check we have exactly one argument as input or not CheckOutputArgument(pvApiCtx, 1, 1);//Check we have exactly one argument on output side or not //load address of 1st argument into piAddressVarOne sciErr1 = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne); //check whether there is an error or not. if (sciErr1.iErr){ printError(&sciErr1, 0); return 0; } //read the variable name in that pointer pointing to variable name int err1=getAllocatedSingleString(pvApiCtx, piAddressVarOne, &ptr); //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); } else { double a;//local variable to store the value of variable name we want to retrieve output=sym_get_dbl_param(global_sym_env,ptr,&a);//symphony function to get the value of double parameter pointed by ptr pointer and store it in 'a' variable if(output==FUNCTION_TERMINATED_NORMALLY){ sciprint("value of double parameter %s is :: %lf\n",ptr,a); status=1.0; } else{ sciprint("Unable to get the value of the parameter...check the input values!!\n"); status=1.0; } } int e=createScalarDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,status); if (e){ AssignOutputVariable(pvApiCtx, 1) = 0; return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; }
int sci_sym_setVarBound(char *fname){ //error management variable SciErr sciErr; int iRet; //data declarations int *varAddress,varIndex,numVars; double inputDouble,newBound; bool isLower; //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); return 1; } //code to check arguments and get them CheckInputArgument(pvApiCtx,2,2) ; CheckOutputArgument(pvApiCtx,1,1) ; //get argument 1: index of variable whose bound is to be changed if(getUIntFromScilab(1,&varIndex)) return 1; iRet=sym_get_num_cols(global_sym_env,&numVars); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has a problem been loaded?\n"); return 1; }else if(varIndex>=numVars){ Scierror(999, "An error occured. Variable index must be a number between 0 and %d.\n",numVars-1); return 1; } //get argument 2: new bound if(getDoubleFromScilab(2,&newBound)) return 1; //decide which function to execute isLower=(strcmp(fname,"sym_setVarLower")==0); if(isLower) iRet=sym_set_col_lower(global_sym_env,varIndex,newBound); else iRet=sym_set_col_upper(global_sym_env,varIndex,newBound); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has a problem been loaded?\n"); return 1; }else{ sciprint("Bound successfully changed.\n"); } //code to give output if(return0toScilab()) return 1; return 0; }
int sci_sym_setObjSense(char *fname){ //error management variable SciErr sciErr; int iRet; //data declarations int *varAddress; double objSense; //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); return 1; } //code to check arguments and get them CheckInputArgument(pvApiCtx,1,1) ; CheckOutputArgument(pvApiCtx,1,1) ; //code to process input sciErr = getVarAddressFromPosition(pvApiCtx, 1, &varAddress); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if ( !isDoubleType(pvApiCtx,varAddress) || isVarComplex(pvApiCtx,varAddress) ) { Scierror(999, "Wrong type for input argument #1:\nEither 1 (sym_minimize) or -1 (sym_maximize) is expected.\n"); return 1; } iRet = getScalarDouble(pvApiCtx, varAddress, &objSense); if(iRet || (objSense!=-1 && objSense!=1)) { Scierror(999, "Wrong type for input argument #1:\nEither 1 (sym_minimize) or -1 (sym_maximize) is expected.\n"); return 1; } iRet=sym_set_obj_sense(global_sym_env,objSense); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured.\n"); return 1; }else{ if(objSense==1) sciprint("The solver has been set to minimize the objective.\n"); else sciprint("The solver has been set to maximize the objective.\n"); } //code to give output if(return0toScilab()) return 1; return 0; }
int int_legdwavf #ifdef _SCILAB6_ (char *fname, void* pvApiCtx) #else (char *fname) #endif { static int l1, m1, n1, l2, m2, n2; static int minlhs = 1, maxlhs = 1, minrhs = 1, maxrhs = 1; swt_wavelet pWaveStruct; int errCode, family, member; int readFlag; char * input_string1 = NULL; double *output1; CheckInputArgument(pvApiCtx,minrhs, maxrhs); CheckOutputArgument(pvApiCtx,minlhs, maxlhs); legdwavf_form_validate (pvApiCtx, &errCode); if (errCode != SUCCESS) { validate_print (errCode); return 0; } //GetRhsVar (1, "c", &m1, &n1, &l1); readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 1 , &input_string1 ); m1=1;n1=1; if(readFlag==SWT_GWSUPPORT_ERROR) { return 0; } legdwavf_content_validate (pvApiCtx, &errCode,input_string1); if (errCode != SUCCESS) { validate_print (errCode); return 0; } wavelet_parser(input_string1,&family,&member); legendre_synthesis_initialize (member, &pWaveStruct); m2 = 1; n2 = pWaveStruct.length; //CreateVar (2, "d", &m2, &n2, &l2); readFlag = swt_gwsupport_AllocMatrixOfDoubles (pvApiCtx, fname, 1, m2 , n2 , &output1 ); if(readFlag==SWT_GWSUPPORT_ERROR) { return 0; } verbatim_copy (pWaveStruct.pLowPass, m2*n2, output1, m2*n2); filter_clear(); //LhsVar (1) = 2; return 0; }
/*--------------------------------------------------------------------------*/ int sci_TCL_DoOneEvent (char *fname, void* pvApiCtx) { CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 1, 1); // wait for events and invoke event handlers Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
int ScilabGateway::exists(char * fname, const int envId, void * pvApiCtx) { SciErr err; int * addr = 0; int * id = 0; int row = 0; int col = 0; bool exists = false; CheckInputArgument(pvApiCtx, 1, 1); CheckOutputArgument(pvApiCtx, 1, 1); ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId); ScilabGatewayOptions & options = env.getGatewayOptions(); OptionsHelper::setCopyOccured(false); ScilabObjects::initialization(env, pvApiCtx); options.setIsNew(false); err = getVarAddressFromPosition(pvApiCtx, 1, &addr); if (err.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } if (!ScilabObjects::isExternalObjOrClass(addr, pvApiCtx)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: An External Object expected."), 1); return 0; } err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id); if (err.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } try { exists = env.isvalidobject(*id); } catch (std::exception & e) { throw; } createScalarBoolean(pvApiCtx, 1, exists ? 1 : 0); LhsVar(1) = 1; PutLhsVar(); return 0; }
int sci_sym_setObjCoeff(char *fname){ //error management variable SciErr sciErr; int iRet; //data declarations int *varAddress,varIndex,numVars; double inputDouble,newCoeff; //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); return 1; } //code to check arguments and get them CheckInputArgument(pvApiCtx,2,2) ; CheckOutputArgument(pvApiCtx,1,1) ; //get argument 1: index of variable whose coefficient is to be changed if(getUIntFromScilab(1,&varIndex)) return 1; iRet=sym_get_num_cols(global_sym_env,&numVars); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has a problem been loaded?\n"); return 1; }else if(varIndex>=numVars){ Scierror(999, "An error occured. Variable index must be a number between 0 and %d.\n",numVars-1); return 1; } //get argument 2: new coefficient if(getDoubleFromScilab(2,&newCoeff)) return 1; iRet=sym_set_obj_coeff(global_sym_env,varIndex,newCoeff); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has a problem been loaded?\n"); return 1; }else{ sciprint("Coefficient successfully changed.\n"); } //code to give output if(return0toScilab()) return 1; return 0; }
int ScilabGateway::getsetOptions(char * fname, const int envId, ScilabAbstractOptionsSetter & setter, void * pvApiCtx) { SciErr sciErr; int * addr = 0; int val = 0; CheckInputArgument(pvApiCtx, 0, 1); CheckOutputArgument(pvApiCtx, 1, 1); ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId); ScilabGatewayOptions & options = env.getGatewayOptions(); OptionsHelper::setCopyOccured(false); ScilabObjects::initialization(env, pvApiCtx); options.setIsNew(false); if (Rhs == 0) { createScalarBoolean(pvApiCtx, 1, (int)setter.get()); LhsVar(1) = 1; PutLhsVar(); return 0; } sciErr = getVarAddressFromPosition(pvApiCtx, 1, &addr); if (sciErr.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } if (!isBooleanType(pvApiCtx, addr)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: A boolean expected."), 1); } if (!isScalar(pvApiCtx, addr)) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Wrong type for input argument #%d: A single boolean expected."), 1); } getScalarBoolean(pvApiCtx, addr, &val); setter.set(val == 1); LhsVar(1) = 0; PutLhsVar(); return 0; }
int sci_sym_getRowActivity(char *fname){ //error management variable SciErr sciErr; int iRet; //data declarations int numConstr; double *rowAct; //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); return 1; } //code to check arguments and get them CheckInputArgument(pvApiCtx,0,0) ; CheckOutputArgument(pvApiCtx,1,1) ; //code to process input iRet=sym_get_num_rows(global_sym_env,&numConstr); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has the problem been solved? Is the problem feasible?\n"); return 1; } rowAct=new double[numConstr]; iRet=sym_get_row_activity(global_sym_env,rowAct); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has the problem been solved? Is the problem feasible?\n"); delete[] rowAct; return 1; } //code to give output sciErr=createMatrixOfDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,numConstr,1,rowAct); if (sciErr.iErr) { printError(&sciErr, 0); delete[] rowAct; return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; //ReturnArguments(pvApiCtx); delete[] rowAct; return 0; }
int sci_mpi_init(char *fname, void* pvApiCtx) { int flag; CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 1, 1); mpi_init_internal(); MPI_Initialized(&flag); if (!flag) { /* MPI Not yet initialized */ MPI_Init(NULL, NULL); MPI_Comm_create_errhandler(MPIErrHandler, &errhdl); } AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_xlfont(char * fname, unsigned long fname_len) { CheckInputArgument(pvApiCtx, 0, 4); CheckOutputArgument(pvApiCtx, 0, 1); switch (nbInputArgument(pvApiCtx)) { case 0: return xlfont_no_rhs(fname); break; case 1: return xlfont_one_rhs(fname); break; default: return xlfont_n_rhs(fname); break; } return 0; }
int sci_sym_setColSoln(char *fname){ //error management variable SciErr sciErr; int iRet; //data declarations int numVars; double *solution; //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); return 1; } //code to check arguments and get them CheckInputArgument(pvApiCtx,1,1) ; CheckOutputArgument(pvApiCtx,1,1) ; //code to process input iRet=sym_get_num_cols(global_sym_env,&numVars); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. Has a problem been loaded?\n"); return 1; } if(getFixedSizeDoubleMatrixFromScilab(1,1,numVars,&solution)) return 1; iRet=sym_set_col_solution(global_sym_env,solution); if(iRet==FUNCTION_TERMINATED_ABNORMALLY){ Scierror(999, "An error occured. The given solution may be infeasible\nor worse than the current solution.\n"); return 1; } //code to give output if(return0toScilab()) return 1; return 0; }
/*--------------------------------------------------------------------------*/ int C2F(sci_getscilabmode)(char *fname, unsigned long fname_len) { int n1 = 0, m1 = 0; char *output = NULL ; int iRet = 0; SciErr sciErr; CheckInputArgument(pvApiCtx, 0, 0) ; CheckOutputArgument(pvApiCtx, 1, 1) ; switch (getScilabMode()) { case SCILAB_API: default : output = strdup("API"); break; case SCILAB_STD: output = strdup("STD"); break; case SCILAB_NW: output = strdup("NW"); break; case SCILAB_NWNI: output = strdup("NWNI"); break; } /* Create the string matrix as return of the function */ iRet = createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, output); free(output); // Data have been copied into Scilab memory if (iRet) { freeAllocatedSingleString(output); return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; }
int sci_mpi_finalize(char *fname, void* pvApiCtx) { int iRet = 0; CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 1, 1); mpi_finalize_internal(); iRet = MPI_Finalize(); if (iRet != MPI_SUCCESS) { char error_string[MPI_MAX_ERROR_STRING]; int length_of_error_string; MPI_Error_string(iRet, error_string, &length_of_error_string); Scierror(999, _("%s: Could not finalize the MPI instance: %s\n"), fname, error_string); return 0; } // TODO: catch les erreurs AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
//This function is for loading a mps file to symphony int sci_sym_set_defaults(char *fname, unsigned long fname_len){ double status=1.0;//assume error status int *piAddressVarOne = NULL;//pointer used to access argument of the function int output=0;//out parameter for the setting of default values function CheckInputArgument(pvApiCtx, 0, 0);//Check we no argument as input or not CheckOutputArgument(pvApiCtx, 1, 1);//Check we have exactly one argument on output side or not //ensure that environment is active if(global_sym_env==NULL){ sciprint("Error: Symphony environment not initialized. Please run 'sym_open()' first.\n"); } else { output=sym_set_defaults(global_sym_env);//setting all environment variables and parameters in this symphony environment passed to their default values if(output==FUNCTION_TERMINATED_ABNORMALLY) { status=1.0;//function did not invoke successfully sciprint("Function terminated abnormally,didnot execute"); } else if(output==FUNCTION_TERMINATED_NORMALLY) { status=0.0;//no error in executing the function sciprint("Function executed successfully"); } } int e=createScalarDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,status); if (e){ AssignOutputVariable(pvApiCtx, 1) = 0; return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_drawlater(char * fname, void* pvApiCtx) { int iFalse = (int)FALSE; int iParentFigureUID = 0; int* piParentFigureUID = &iParentFigureUID; int iSubwinUID = 0; int iCurChildUID = 0; int iType = -1; int *piType = &iType; CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 0, 1); if (nbInputArgument(pvApiCtx) <= 0) { iSubwinUID = getOrCreateDefaultSubwin(); if (iSubwinUID != 0) { // Look for top level figure iCurChildUID = iSubwinUID; do { iParentFigureUID = getParentObject(iCurChildUID); getGraphicObjectProperty(iParentFigureUID, __GO_TYPE__, jni_int, (void **)&piType); iCurChildUID = iParentFigureUID; } while (iParentFigureUID != 0 && iType != __GO_FIGURE__); if (iParentFigureUID != 0) { setGraphicObjectProperty(iParentFigureUID, __GO_IMMEDIATE_DRAWING__, &iFalse, jni_bool, 1); } } } AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*Function that closes symphony environment * Returns 1 on success , 0 on failure */ int sci_sym_close(char *fname, unsigned long fname_len){ // Error management variable SciErr sciErr; double status=0; int output;//output parameter for closing the environment //check whether we have no input and one output argument or not CheckInputArgument(pvApiCtx, 0, 0) ;//no input argument CheckOutputArgument(pvApiCtx, 1, 1) ;//one output argument if (global_sym_env==NULL){//check for environment sciprint("Error: symphony environment is not initialized.\n"); }else{ output=sym_close_environment(global_sym_env);//close environment if(output==ERROR__USER){ status=0;//User error detected in user_free_master() function or when function invoked unsuccessfully sciprint("Error in user_free_master()\n"); }else if(output==FUNCTION_TERMINATED_ABNORMALLY){ status=0;//function invoked unsuccessfully sciprint("Symphony environment could not be closed.\n"); }else if(output==FUNCTION_TERMINATED_NORMALLY){ status=1;//function invoked successfully and no error global_sym_env=NULL;//important to set to NULL, so that other functions can detect that environment is not open. //sciprint("Symphony environement closed successfully. Please run 'sym_open()' to restart.\n"); //delete the sym_ variables deleteNamedVariable(pvApiCtx,"sym_minimize"); deleteNamedVariable(pvApiCtx,"sym_maximize"); } } /*write satus of function (success-1 or failure-0) as output argument to scilab*/ if(returnDoubleToScilab(status)) return 1; return 0; }
int ScilabGateway::getEnvId(char * fname, const int envId, void * pvApiCtx) { SciErr sciErr; CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 1, 1); ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId); ScilabGatewayOptions & options = env.getGatewayOptions(); OptionsHelper::setCopyOccurred(false); ScilabObjects::initialization(env, pvApiCtx); options.setIsNew(false); sciErr = createMatrixOfInteger32(pvApiCtx, 1, 1, 1, &envId); if (sciErr.iErr) { throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot create the identifier")); } LhsVar(1) = 1; PutLhsVar(); return 0; }
/*--------------------------------------------------------------------------*/ int sci_contour2di(char * fname, void* pvApiCtx) { SciErr sciErr; int flagx = 0, nz = 10; /* default number of level curves : 10 */ int m1 = 0, n1 = 0, m2 = 0, n2 = 0, m3 = 0, n3 = 0, m4 = 0, n4 = 0; double* hl1 = NULL; double* hl2 = NULL; double* znz = NULL; int ix4, i = 0, un = 1; int* piAddr1 = NULL; int* piAddr2 = NULL; int* piAddr3 = NULL; int* piAddr4 = NULL; double* l1 = NULL; double* l2 = NULL; double* l3 = NULL; double* l4 = NULL; int* l5 = NULL; CheckInputArgument(pvApiCtx, 4, 4); CheckOutputArgument(pvApiCtx, 2, 2); //get variable address sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDouble(pvApiCtx, piAddr1, &m1, &n1, &l1); if (sciErr.iErr) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); printError(&sciErr, 0); return 1; } //CheckVector if (m1 != 1 && n1 != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 1); return 1; } //get variable address sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &m2, &n2, &l2); if (sciErr.iErr) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2); printError(&sciErr, 0); return 1; } //CheckVector if (m2 != 1 && n2 != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 2); return 1; } //get variable address sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 3. sciErr = getMatrixOfDouble(pvApiCtx, piAddr3, &m3, &n3, &l3); if (sciErr.iErr) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 3); printError(&sciErr, 0); return 1; } if (m3 * n3 == 0) { AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } if (m3 == 1 || n3 == 1) { Scierror(999, _("%s: Wrong type for input argument #%d: Matrix expected.\n"), fname, 3); return 1; } //CheckDimProp if (m1 * n1 != m3) { Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname); return 1; } //CheckDimProp if (m2 * n2 != n3) { Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname); return 1; } /* number of level curves */ //get variable address sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddr4); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 4. sciErr = getMatrixOfDouble(pvApiCtx, piAddr4, &m4, &n4, &l4); if (sciErr.iErr) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 4); printError(&sciErr, 0); return 1; } if (m4 * n4 == 1) { flagx = 0; nz = Max(1, (int) * (l4)); znz = (l4); } else { flagx = 1; nz = m4 * n4; znz = (l4); } ix4 = Max(nz, 2); sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 5, un, ix4, &l5); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } for (i = 0 ; i < ix4 ; ++i) { l5[i] = i + 1; } if (nz == 1) { l5[1] = 1; } if (C2F(contourif)(l1, l2, l3, &m3, &n3, &flagx, &nz, znz, l5) != 0) { /* Something wrong happened */ return -1; } C2F(getconts)(&hl1, &hl2, &m1, &n1); if (n1 == 0) { sciErr = allocMatrixOfDouble(pvApiCtx, 6, n1, n1, &hl1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } sciErr = allocMatrixOfDouble(pvApiCtx, 7, n1, n1, &hl2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } } else { sciErr = createMatrixOfDouble(pvApiCtx, 6, m1, n1, hl1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } sciErr = createMatrixOfDouble(pvApiCtx, 7, m1, n1, hl2); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } } AssignOutputVariable(pvApiCtx, 1) = 6; AssignOutputVariable(pvApiCtx, 2) = 7; ReturnArguments(pvApiCtx); return 0; }
/*--------------------------------------------------------------------------*/ int sci_delete(char *fname, unsigned long fname_len) { SciErr sciErr; int* piAddrl1 = NULL; long long* l1 = NULL; int* piAddrl2 = NULL; char* l2 = NULL; int m1 = 0, n1 = 0, lw = 0; unsigned long hdl = 0; int nb_handles = 0, i = 0, dont_overload = 0; int iObjUID = 0; int iFigureUID = 0; int* piChildrenUID = NULL; int iChildrenCount = 0; int* childrencount = &iChildrenCount; int iHidden = 0; int *piHidden = &iHidden; int iParentUID = 0; int* piParentUID = &iParentUID; int iParentType = -1; int *piParentType = &iParentType; int iObjType = -1; int *piObjType = &iObjType; CheckInputArgument(pvApiCtx, 0, 1); CheckOutputArgument(pvApiCtx, 0, 1); if (nbInputArgument(pvApiCtx) == 0) /* Delete current object */ { iObjUID = getCurrentObject(); if (iObjUID == 0) { //No current object, we can leave AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } hdl = (unsigned long)getHandle(iObjUID); dont_overload = 1; nb_handles = 1; } else { sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } switch (getInputArgumentType(pvApiCtx, 1)) { case sci_matrix: { if (isEmptyMatrix(pvApiCtx, piAddrl1)) { AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 1; } else { Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } break; } case sci_handles: /* delete Entity given by a handle */ // Retrieve a matrix of handle at position 1. sciErr = getMatrixOfHandle(pvApiCtx, piAddrl1, &m1, &n1, &l1); /* Gets the Handle passed as argument */ if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } nb_handles = m1 * n1; if (nbInputArgument(pvApiCtx) == 2) { sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) /* Gets the command name */ { Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 2); return 1; } } hdl = (unsigned long) * (l1); /* Puts the value of the Handle to hdl */ break; case sci_strings: /* delete("all") */ CheckInputArgument(pvApiCtx, 1, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) { Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 1); return 1; } if (strcmp((l2), "all") == 0) { int i = 0; int iFigureNumber = sciGetNbFigure(); if (iFigureNumber == 0) { //no graphic windows, we can leave AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } iFigureUID = getCurrentFigure(); getGraphicObjectProperty(iFigureUID, __GO_CHILDREN_COUNT__, jni_int, (void **)&childrencount); getGraphicObjectProperty(iFigureUID, __GO_CHILDREN__, jni_int_vector, (void **)&piChildrenUID); for (i = 0; i < childrencount[0]; ++i) { getGraphicObjectProperty(piChildrenUID[i], __GO_HIDDEN__, jni_bool, (void **)&piHidden); if (iHidden == 0) { deleteGraphicObject(piChildrenUID[i]); } } /* * Clone a new Axes object using the Axes model which is then * attached to the 'cleaned' Figure. */ cloneAxesModel(iFigureUID); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } else { Scierror(999, _("%s: Wrong value for input argument #%d: '%s' expected.\n"), fname, 1, "all"); return 0; } break; default: // Overload lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); C2F(overload) (&lw, "delete", 6); return 0; } } for (i = 0; i < nb_handles; i++) { int iTemp = 0; if (nbInputArgument(pvApiCtx) != 0) { hdl = (unsigned long) * (l1 + i); /* Puts the value of the Handle to hdl */ } iObjUID = getObjectFromHandle(hdl); if (iObjUID == 0) { Scierror(999, _("%s: The handle is not valid.\n"), fname); return 0; } if (isFigureModel(iObjUID) || isAxesModel(iObjUID)) { Scierror(999, _("This object cannot be deleted.\n")); return 0; } /* Object type */ getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piObjType); if (iObjType == __GO_AXES__) { /* Parent object */ iParentUID = getParentObject(iObjUID); /* Parent type */ getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType); } if (iObjType == __GO_LABEL__) { Scierror(999, _("A Label object cannot be deleted.\n")); return 0; } //bug #11485 : duplicate pobjUID before delete it. iTemp = iObjUID; deleteGraphicObject(iObjUID); /* ** All figure must have at least one axe child. ** If the last one is removed, add a new default one. */ if (iObjType == __GO_AXES__ && iParentType == __GO_FIGURE__) { int iChild = 0; int iChildCount = 0; int *piChildCount = &iChildCount; char **pstChildren = NULL; int iChildType = -1; int *piChildType = &iChildType; int iAxesFound = 0; int iDefaultAxes = -1; int *piDefaultAxes = &iDefaultAxes; getGraphicObjectProperty(iParentUID, __GO_CHILDREN_COUNT__, jni_int, (void **)&piChildCount); getGraphicObjectProperty(iParentUID, __GO_CHILDREN__, jni_int_vector, (void **)&piChildrenUID); getGraphicObjectProperty(iParentUID, __GO_DEFAULT_AXES__, jni_bool, (void **)&piDefaultAxes); for (iChild = 0; iChild < iChildCount; iChild++) { getGraphicObjectProperty(piChildrenUID[iChild], __GO_TYPE__, jni_int, (void **)&piChildType); if (iChildType == __GO_AXES__) { if (getCurrentSubWin() == iTemp) // Current axes has been deleted { setCurrentSubWin(piChildrenUID[iChild]); } iAxesFound = 1; break; } } if (!iAxesFound && iDefaultAxes != 0) { /* * Clone a new Axes object using the Axes model which is then * attached to the newly created Figure. */ cloneAxesModel(iParentUID); } } } if (!dont_overload) { // Overload lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); C2F(overload) (&lw, "delete", 6); } else { AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); } if (l2) { freeAllocatedSingleString(l2); } return 0; }
/*--------------------------------------------------------------------------*/ int sci_dnaupd(char *fname, void *pvApiCtx) { SciErr sciErr; int* piAddrpIDO = NULL; int* pIDO = NULL; int* piAddrpBMAT = NULL; char* pBMAT = NULL; int* piAddrpN = NULL; int* pN = NULL; int* piAddrpWHICH = NULL; char* pWHICH = NULL; int* piAddrpNEV = NULL; int* pNEV = NULL; int* piAddrpTOL = NULL; double* pTOL = NULL; int* piAddrpRESID = NULL; double* pRESID = NULL; int* piAddrpNCV = NULL; int* pNCV = NULL; int* piAddrpV = NULL; double* pV = NULL; int* piAddrpIPARAM = NULL; int* pIPARAM = NULL; int* piAddrpIPNTR = NULL; int* pIPNTR = NULL; int* piAddrpWORKD = NULL; double* pWORKD = NULL; int* piAddrpWORKL = NULL; double* pWORKL = NULL; int* piAddrpINFO = NULL; int* pINFO = NULL; int IDO, mIDO, nIDO; int mN, nN; int mNEV, nNEV; int mTOL, nTOL; int RESID, mRESID, nRESID; int mNCV, nNCV; int V, mV, nV; int IPARAM, mIPARAM, nIPARAM; int IPNTR, mIPNTR, nIPNTR; int WORKD, mWORKD, nWORKD; int WORKL, mWORKL, nWORKL; int INFO, mINFO, nINFO; int minlhs = 1, minrhs = 14, maxlhs = 8, maxrhs = 14; int LDV, LWORKL; int sizeWORKL = 0; /* [IDO,RESID,V,IPARAM,IPNTR,WORKD,WORKL,INFO]=dnaupd... (ID0,BMAT,N,WHICH,NEV,TOL,RESID,NCV,V,IPARAM,IPNTR,WORKD,WORKL,INFO) */ CheckInputArgument(pvApiCtx, minrhs, maxrhs); CheckOutputArgument(pvApiCtx, minlhs, maxlhs); /* VARIABLE = NUMBER */ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrpIDO); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 1. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpIDO, &mIDO, &nIDO, &pIDO); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } IDO = 1; sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrpN); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 3. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpN, &mN, &nN, &pN); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 3); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddrpNEV); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 5. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpNEV, &mNEV, &nNEV, &pNEV); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 5); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddrpTOL); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 6. sciErr = getMatrixOfDouble(pvApiCtx, piAddrpTOL, &mTOL, &nTOL, &pTOL); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 6); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 7, &piAddrpRESID); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 7. sciErr = getMatrixOfDouble(pvApiCtx, piAddrpRESID, &mRESID, &nRESID, &pRESID); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 7); return 1; } RESID = 7; sciErr = getVarAddressFromPosition(pvApiCtx, 8, &piAddrpNCV); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 8. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpNCV, &mNCV, &nNCV, &pNCV); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 8); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 9, &piAddrpV); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 9. sciErr = getMatrixOfDouble(pvApiCtx, piAddrpV, &mV, &nV, &pV); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 9); return 1; } V = 9; sciErr = getVarAddressFromPosition(pvApiCtx, 10, &piAddrpIPARAM); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 10. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpIPARAM, &mIPARAM, &nIPARAM, &pIPARAM); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 10); return 1; } IPARAM = 10; sciErr = getVarAddressFromPosition(pvApiCtx, 11, &piAddrpIPNTR); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 11. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpIPNTR, &mIPNTR, &nIPNTR, &pIPNTR); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 11); return 1; } IPNTR = 11; sciErr = getVarAddressFromPosition(pvApiCtx, 12, &piAddrpWORKD); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 12. sciErr = getMatrixOfDouble(pvApiCtx, piAddrpWORKD, &mWORKD, &nWORKD, &pWORKD); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 12); return 1; } WORKD = 12; sciErr = getVarAddressFromPosition(pvApiCtx, 13, &piAddrpWORKL); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 13. sciErr = getMatrixOfDouble(pvApiCtx, piAddrpWORKL, &mWORKL, &nWORKL, &pWORKL); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 13); return 1; } WORKL = 13; sciErr = getVarAddressFromPosition(pvApiCtx, 14, &piAddrpINFO); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 14. sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrpINFO, &mINFO, &nINFO, &pINFO); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 14); return 1; } INFO = 14; LWORKL = mWORKL * nWORKL; LDV = Max(1, pN[0]); /* Don't call dnaupd if ido == 99 */ if (pIDO[0] == 99) { Scierror(999, _("%s: the computation is already terminated\n"), fname); return 1; } /* Check some sizes */ if (mIPARAM*nIPARAM != 11) { Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "IPARAM", 11); return 1; } if (mIPNTR*nIPNTR != 14) { Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "IPNTR", 14); return 1; } if (mRESID*nRESID != pN[0]) { Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "RESID", *(int*)(pN)); return 1; } if ((mV != pN[0]) || (nV != pNCV[0])) { Scierror(999, _("%s: Wrong size for input argument %s: A matrix of size %dx%d expected.\n"), fname, "V", *(int*)(pN), *(int*)(pNCV)); return 1; } if (mWORKD * nWORKD < 3 * pN[0]) { Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "WORKD", 3 * *(int*)(pN)); return 1; } sizeWORKL = 3 * pNCV[0] * pNCV[0] + 6 * pNCV[0]; if (mWORKL * nWORKL < sizeWORKL) { Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "WORKL", sizeWORKL); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrpBMAT); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 2. if (getAllocatedSingleString(pvApiCtx, piAddrpBMAT, &pBMAT)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrpWHICH); if (sciErr.iErr) { freeAllocatedSingleString(pBMAT); printError(&sciErr, 0); return 1; } // Retrieve a matrix of double at position 4. if (getAllocatedSingleString(pvApiCtx, piAddrpWHICH, &pWHICH)) { freeAllocatedSingleString(pBMAT); Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 4); return 1; } C2F(dnaupd)(pIDO, pBMAT, pN, pWHICH, pNEV, pTOL, pRESID, pNCV, pV, &LDV, pIPARAM, pIPNTR, pWORKD, pWORKL, &LWORKL, pINFO, 1L, 2L); freeAllocatedSingleString(pBMAT); freeAllocatedSingleString(pWHICH); if (*pINFO < 0) { Scierror(998, _("%s: internal error, info=%d.\n"), fname, *pINFO); return 0; } AssignOutputVariable(pvApiCtx, 1) = IDO; AssignOutputVariable(pvApiCtx, 2) = RESID; AssignOutputVariable(pvApiCtx, 3) = V; AssignOutputVariable(pvApiCtx, 4) = IPARAM; AssignOutputVariable(pvApiCtx, 5) = IPNTR; AssignOutputVariable(pvApiCtx, 6) = WORKD; AssignOutputVariable(pvApiCtx, 7) = WORKL; AssignOutputVariable(pvApiCtx, 8) = INFO; ReturnArguments(pvApiCtx); return 0; }