本文整理汇总了C++中sciprint函数的典型用法代码示例。如果您正苦于以下问题:C++ sciprint函数的具体用法?C++ sciprint怎么用?C++ sciprint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sciprint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sci_sym_solve
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);
}
示例2: printError
int printError(SciErr* _psciErr, int _iLastMsg)
{
if (_psciErr->iErr == 0)
{
return 0;
}
SciStoreError(_psciErr->iErr);
if (getPromptMode() != PROMPTMODE_SILENT && getSilentError() == VERBOSE_ERROR)
{
if (_iLastMsg)
{
sciprint(_("API Error:\n"));
sciprint(_("\tin %s\n"), _psciErr->pstMsg[0]);
}
else
{
sciprint(_("API Error:\n"));
for (int i = _psciErr->iMsgCount - 1; i >= 0; i--)
{
sciprint(_("\tin %s\n"), _psciErr->pstMsg[i]);
}
}
}
sciErrClean(_psciErr);
return 0;
}
示例3: C2F
/*--------------------------------------------------------------------------*/
void C2F(mget) (int *fd, double *res, int *n, char *type, int *ierr)
{
int nc, swap2;
FILE *fa;
nc = (int)strlen(type);
*ierr = 0;
if (nc == 0)
{
sciprint(_("%s: Wrong size for input argument #%d: Non-empty string expected.\n"), "mput", 4, type);
*ierr = 2;
return;
}
fa = GetFileOpenedInScilab(*fd);
if (fa)
{
swap2 = GetSwapStatus(*fd);
mget2(fa, swap2, res, *n, type, ierr);
if (*ierr > 0)
{
sciprint(_("%s: Wrong value for input argument #%d: Format not recognized.\n"), "mget", 4);
}
}
else
{
sciprint(_("%s: No input file associated to logical unit %d.\n"), "mget", *fd);
*ierr = 3;
}
}
示例4: printError
int printError(SciErr* _psciErr, int _iLastMsg)
{
int iMode = getExecMode();
if(_psciErr->iErr == 0)
{
return 0;
}
SciStoreError(_psciErr->iErr);
if(iMode == SILENT_EXEC_MODE)
{
return 0;
}
if(_iLastMsg)
{
sciprint(_("API Error:\n"));
sciprint(_("\tin %s\n"), _psciErr->pstMsg[0]);
}
else
{
sciprint(_("API Error:\n"));
// for(int i = 0 ; i < _psciErr->iMsgCount ;i++)
for(int i = _psciErr->iMsgCount - 1 ; i >= 0 ; i--)
{
// if(i == 0)
sciprint(_("\tin %s\n"), _psciErr->pstMsg[i]);
}
}
return 0;
}
示例5: C2F
/*--------------------------------------------------------------------------*/
void C2F(mtell) (int *fd, double *offset, int *err)
{
FILE *fa= GetFileOpenedInScilab(*fd);
if ( fa == (FILE *) 0 )
{
char *filename = GetFileNameOpenedInScilab(*fd);
if (filename)
{
sciprint(_("%s: Error while opening, reading or writing '%s'.\n"),"mtell",filename);
}
else
{
sciprint(_("%s: Error while opening, reading or writing.\n"),"mtell");
}
*err=1;
return;
}
*err = 0;
#ifdef _MSC_VER
#if _WIN64
*offset = (double) _ftelli64(fa) ;
#else
*offset = (double) ftell(fa) ;
#endif
#else
*offset = (double) ftell(fa) ;
#endif
}
示例6: C2F
/*--------------------------------------------------------------------------*/
void C2F(mput) (int *fd, double *res, int *n, char *type, int *ierr)
{
*ierr = 0;
if (strlen(type) == 0)
{
if (getWarningMode())
{
sciprint(_("%s: Wrong size for input argument #%d ('%s'): Non-empty string expected.\n"), "mput", 4, type);
}
*ierr = 2;
return;
}
types::File *pFile = FileManager::getFile(*fd);
if (pFile && pFile->getFiledesc())
{
mput2(pFile->getFiledesc(), pFile->getFileSwap(), res, *n, type, ierr);
if (*ierr > 0)
{
if (getWarningMode())
{
sciprint(_("%s: Wrong value for input argument #%d ('%s'): Format not recognized.\n"), "mput", 4, type);
}
}
}
else
{
if (getWarningMode())
{
sciprint(_("%s: No input file associated to logical unit %d.\n"), "mput", *fd);
}
*ierr = 3;
}
}
示例7: sci_sym_getObjSense
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;
}
示例8: sci_gpuDeviceMemInfo
/* ========================================================================== */
int sci_gpuDeviceMemInfo(char *fname)
{
#ifdef WITH_CUDA
if(isGpuInit())
{
if (useCuda())
{
size_t free = 0, total = 0;
cuMemGetInfo(&free,&total);
double freeMem = (double)free;
createScalarDouble(pvApiCtx, Rhs + 1, freeMem);
}
else
{
double zero = 0.;
createScalarDouble(pvApiCtx, Rhs + 1, zero);
sciprint("not implemented with OpenCL.\n");
}
LhsVar(1) = Rhs + 1;
PutLhsVar();
}
else
{
Scierror(999,"%s","gpu is not initialised. Please launch gpuInit() before use this function.\n");
}
#else
sciprint("not implemented with OpenCL.\n");
#endif
return 0;
}
示例9: sci_sym_open
/* 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;
}
示例10: read_sparse
int read_sparse(char *fname, unsigned long fname_len)
{
SciErr sciErr;
int i, j, k;
int* piAddr = NULL;
int iRows = 0;
int iCols = 0;
int iNbItem = 0;
int* piNbItemRow = NULL;
int* piColPos = NULL;
double* pdblReal = NULL;
double* pdblImg = NULL;
CheckInputArgument(pvApiCtx, 1, 1);
sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
if (sciErr.iErr)
{
printError(&sciErr, 0);
return 0;
}
if (isVarComplex(pvApiCtx, piAddr))
{
sciErr = getComplexSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
}
else
{
sciErr = getSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal);
}
if (sciErr.iErr)
{
printError(&sciErr, 0);
return 0;
}
sciprint("Sparse %d item(s)\n", iNbItem);
k = 0;
for (i = 0 ; i < iRows ; i++)
{
for (j = 0 ; j < piNbItemRow[i] ; j++)
{
sciprint("(%d,%d) = %f", i + 1, piColPos[k], pdblReal[k]);
if (isVarComplex(pvApiCtx, piAddr))
{
sciprint(" %+fi", pdblImg[k]);
}
sciprint("\n");
k++;
}
}
//assign allocated variables to Lhs position
AssignOutputVariable(pvApiCtx, 1) = 0;
return 0;
}
示例11: sci_sym_set_str_param
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;
}
示例12: sci_sym_get_dbl_param
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;
}
示例13: DeleteDirectory
static int DeleteDirectory(char *refcstrRootDirectory)
{
DIR *dir;
struct dirent *ent;
dir = opendir(refcstrRootDirectory) ;
if (dir == NULL)
{
sciprint(_("Warning: Error while opening %s: %s\n"), refcstrRootDirectory, strerror(errno));
return -1;
}
while ((ent = readdir(dir)) != NULL)
{
char *filename = NULL;
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
{
continue ;
}
filename = MALLOC(sizeof(char) * (strlen(refcstrRootDirectory) + 1 + strlen(ent->d_name) + 1 + 1)) ;
sprintf(filename, "%s/%s", refcstrRootDirectory, ent->d_name);
if (isdir(filename))
{
/* Delete recursively */
DeleteDirectory(filename);
if (filename)
{
FREE(filename);
filename = NULL;
}
}
else
{
/* Not a directory... It must be a file (at least, I hope it is a file */
if (remove(filename) != 0)
{
sciprint(_("Warning: Could not remove file %s: %s\n"), filename, strerror(errno));
}
if (filename)
{
FREE(filename);
filename = NULL;
}
}
}
if (rmdir(refcstrRootDirectory) != 0)
{
sciprint(_("Warning: Could not remove directory %s: %s\n"), refcstrRootDirectory, strerror(errno));
}
if (dir)
{
FREE(dir);
dir = NULL;
}
return 0;
}
示例14: sci_sym_setVarBound
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;
}
示例15: Sci_dlsym
/*---------------------------------------------------------------------------*/
int Sci_dlsym(char *ename, int ishared, char *strf)
{
DynLibHandle hd1 = NULL;
int ish = Min(Max(0, ishared), ENTRYMAX - 1);
char enamebuf[MAXNAME];
if ( strf[0] == 'f' )
{
Underscores(1, ename, enamebuf);
}
else
{
Underscores(0, ename, enamebuf);
}
/* lookup the address of the function to be called */
if ( NEpoints == ENTRYMAX )
{
return -1;
}
if ( hd[ish].ok == FALSE )
{
return -3;
}
/** entry was previously loaded **/
if ( SearchFandS(ename, ish) >= 0 )
{
sciprint(_("Entry name %s.\n"), ename);
return -4;
}
else
{
hd1 = (DynLibHandle)hd[ish].shl;
EP[NEpoints].epoint = (function) GetDynLibFuncPtr (hd1, enamebuf);
if ( EP[NEpoints].epoint == NULL )
{
if (getIlibVerboseLevel() != ILIB_VERBOSE_NO_OUTPUT)
{
sciprint(_("%s is not an entry point.\n"), enamebuf);
}
return -5;
}
else
{
/* we don't add the _ in the table */
if (debug)
{
sciprint(_("Linking %s.\n"), ename);
}
strncpy(EP[NEpoints].name, ename, MAXNAME);
EP[NEpoints].Nshared = ish;
NEpoints++;
}
}
return 0;
}