for (i = 0; i < size1; ++i)
{
- //For each element of the matrix, multiply by 2
+ //For each element of the matrix, multiply by 2
out1[i] = in1[i] * 2;
}
for (i = 0; i < size2; ++i)
{
- //For each element of the matrix, invert the value
+ //For each element of the matrix, invert the value
out2[i] = in2[i] == TRUE ? FALSE : TRUE;
}
{
STATUS_OK = 0,
STATUS_ERROR = 1
-}scilabStatus;
+} scilabStatus;
void scilab_setError(scilabEnv env, const wchar_t* msg);
const wchar_t* scilab_lastError(scilabEnv env);
#define scilab_getOptional API_PROTO(getOptional)
- scilabVar API_PROTO(getOptional)(scilabEnv env, scilabOpt opt, const wchar_t* varname);
+scilabVar API_PROTO(getOptional)(scilabEnv env, scilabOpt opt, const wchar_t* varname);
#ifdef __cplusplus
}
#endif
extern "C" {
#endif
- /*******************************/
- /* boolean sparse functions */
- /*******************************/
- /**
- * Get boolean sparse variable
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of number of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr getBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
+/*******************************/
+/* boolean sparse functions */
+/*******************************/
+/**
+ * Get boolean sparse variable
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of number of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr getBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
- /**
- * Allocate boolean sparse variable data
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[out] _piNbItemRow return array of number of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr allocBooleanSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos);
+/**
+ * Allocate boolean sparse variable data
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[out] _piNbItemRow return array of number of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr allocBooleanSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos);
- /**
- * Create boolean sparse variable
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[in] _piNbItemRow array of number of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr createBooleanSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos);
+/**
+ * Create boolean sparse variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[in] _piNbItemRow array of number of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr createBooleanSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos);
- /**
- * Create named boolean sparse variable
- * @param[in] _pstName variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[in] _piNbItemRow array of number of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr createNamedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos);
+/**
+ * Create named boolean sparse variable
+ * @param[in] _pstName variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[in] _piNbItemRow array of number of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr createNamedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos);
- /**
- * Read named boolean sparse variable
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of number of item for each row
- * @param[out] _piColPos return array of item column position ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr readNamedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos);
+/**
+ * Read named boolean sparse variable
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of number of item for each row
+ * @param[out] _piColPos return array of item column position ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr readNamedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos);
- /* shortcut functions */
+/* shortcut functions */
- /**
- * Check if the variable type is boolean sparse
- * @param[in] _piAddress variable address
- * @return 1 for true and 0 for false
- */
- int isBooleanSparseType(void* _pvCtx, int* _piAddress);
+/**
+ * Check if the variable type is boolean sparse
+ * @param[in] _piAddress variable address
+ * @return 1 for true and 0 for false
+ */
+int isBooleanSparseType(void* _pvCtx, int* _piAddress);
- /**
- * Check if the variable type is boolean sparse
- * @param[in] _pstName variable name
- * @return 1 for true and 0 for false
- */
- int isNamedBooleanSparseType(void* _pvCtx, const char* _pstName);
+/**
+ * Check if the variable type is boolean sparse
+ * @param[in] _pstName variable name
+ * @return 1 for true and 0 for false
+ */
+int isNamedBooleanSparseType(void* _pvCtx, const char* _pstName);
- /**
- * Get boolean sparse variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of number of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- int getAllocatedBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
+/**
+ * Get boolean sparse variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of number of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+int getAllocatedBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
- /**
- * Get named boolean sparse variable data
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of number of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @return if the operation succeeded (0) or not ( !0 )
- */
- int getNamedAllocatedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
+/**
+ * Get named boolean sparse variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of number of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+int getNamedAllocatedBooleanSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
- /**
- * Free data allocated by shortcut functions
- * @param[in] _piNbItemRow array of number of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- */
- void freeAllocatedBooleanSparse(int* _piNbItemRow, int* _piColPos);
+/**
+ * Free data allocated by shortcut functions
+ * @param[in] _piNbItemRow array of number of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ */
+void freeAllocatedBooleanSparse(int* _piNbItemRow, int* _piColPos);
#ifdef __cplusplus
}
extern "C" {
#endif
- /**
- * Get handle variable
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _pllHandle return pointer to data
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr getMatrixOfHandle(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, long long** _pllHandle);
+/**
+ * Get handle variable
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _pllHandle return pointer to data
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr getMatrixOfHandle(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, long long** _pllHandle);
- /**
- * Allocate handle variable
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[out] _pllHandle return pointer to data
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr allocMatrixOfHandle(void* _pvCtx, int _iVar, int _iRows, int _iCols, long long** _pllHandle);
+/**
+ * Allocate handle variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[out] _pllHandle return pointer to data
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr allocMatrixOfHandle(void* _pvCtx, int _iVar, int _iRows, int _iCols, long long** _pllHandle);
- /**
- * Create handle variable
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _pllHandle pointer to data
- * @return if the operation succeeded (0) or not ( !0 )
- */
- SciErr createMatrixOfHandle(void* _pvCtx, int _iVar, int _iRows, int _iCols, long long* _pllHandle);
+/**
+ * Create handle variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _pllHandle pointer to data
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+SciErr createMatrixOfHandle(void* _pvCtx, int _iVar, int _iRows, int _iCols, long long* _pllHandle);
- /*shortcut functions*/
+/*shortcut functions*/
- /**
- * Check if the variable type is handle
- * @param[in] _piAddress variable address
- * @return 1 for true and 0 for false
- */
- int isHandleType(void* _pvCtx, int* _piAddress);
+/**
+ * Check if the variable type is handle
+ * @param[in] _piAddress variable address
+ * @return 1 for true and 0 for false
+ */
+int isHandleType(void* _pvCtx, int* _piAddress);
- /**
- * Get scalar handle variable data
- * @param[in] _piAddress variable address
- * @param[out] _pllHandle return handle value
- * @return if the operation succeeded (0) or not ( !0 )
- */
- int getScalarHandle(void* _pvCtx, int* _piAddress, long long* _pllHandle);
+/**
+ * Get scalar handle variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _pllHandle return handle value
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+int getScalarHandle(void* _pvCtx, int* _piAddress, long long* _pllHandle);
- /**
- * Create scalar handle
- * @param[in] _iVar variable number
- * @param[in] _llHandle value
- * @return if the operation succeeded (0) or not ( !0 )
- */
- int createScalarHandle(void* _pvCtx, int _iVar, long long _llHandle);
+/**
+ * Create scalar handle
+ * @param[in] _iVar variable number
+ * @param[in] _llHandle value
+ * @return if the operation succeeded (0) or not ( !0 )
+ */
+int createScalarHandle(void* _pvCtx, int _iVar, long long _llHandle);
#ifdef __cplusplus
}
extern "C" {
#endif
-/*
+/*
* These values are also used in:
- * modules/core/includes/sci_types.h
+ * modules/core/includes/sci_types.h
*/
#define SCI_INT8 1
extern "C" {
#endif
- typedef struct rhs_opts__
- {
- int iPos ; /** stack position : -1 if not present */
- char* pstName;
- int iType;// -1 not yet defined
- int iRows;
- int iCols;
- int* piAddr;
- } rhs_opts;
+typedef struct rhs_opts__
+{
+ int iPos ; /** stack position : -1 if not present */
+ char* pstName;
+ int iType;// -1 not yet defined
+ int iRows;
+ int iCols;
+ int* piAddr;
+} rhs_opts;
- /**
- * Get optional variable
- * @param[in] name of function caller
- * @param[in/out] opts structure of optional arguments
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getOptionals(void* _pvCtx, char* fname, rhs_opts opts[]);
- int FirstOpt(void* _pvCtx);
- int NumOpt(void* _pvCtx);
- int FindOpt(void* _pvCtx, char* pstProperty, rhs_opts opts[]);
+/**
+ * Get optional variable
+ * @param[in] name of function caller
+ * @param[in/out] opts structure of optional arguments
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getOptionals(void* _pvCtx, char* fname, rhs_opts opts[]);
+int FirstOpt(void* _pvCtx);
+int NumOpt(void* _pvCtx);
+int FindOpt(void* _pvCtx, char* pstProperty, rhs_opts opts[]);
#ifdef __cplusplus
}
#endif
#include "dynlib_api_scilab.h"
- /**
- * Get pointer variable
- * @param[in] _piAddress variable address
- * @param[out] _pvPtr return pointer
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr getPointer(void* _pvCtx, int* _piAddress, void** _pvPtr);
+/**
+* Get pointer variable
+* @param[in] _piAddress variable address
+* @param[out] _pvPtr return pointer
+* @return if the operation succeeded ( 0 ) or not ( !0 )
+*/
+SciErr getPointer(void* _pvCtx, int* _piAddress, void** _pvPtr);
- /**
- * Create pointer variable
- * @param[in] _iVar variable number
- * @param[in] _pvPtr pointer
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr createPointer(void* _pvCtx, int _iVar, void* _pvPtr);
+/**
+* Create pointer variable
+* @param[in] _iVar variable number
+* @param[in] _pvPtr pointer
+* @return if the operation succeeded ( 0 ) or not ( !0 )
+*/
+SciErr createPointer(void* _pvCtx, int _iVar, void* _pvPtr);
- /**
- * Create named pointer variable
- * @param[in] _pstName variable name
- * @param[in] _pvPtr pointer
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr createNamedPointer(void* _pvCtx, const char* _pstName, void* _pvPtr);
+/**
+* Create named pointer variable
+* @param[in] _pstName variable name
+* @param[in] _pvPtr pointer
+* @return if the operation succeeded ( 0 ) or not ( !0 )
+*/
+SciErr createNamedPointer(void* _pvCtx, const char* _pstName, void* _pvPtr);
- /**
- * Read pointer named variable
- * @param[in] _pstName variable name
- * @param[out] _pvPtr return pointer
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr readNamedPointer(void* _pvCtx, const char* _pstName, void** _pvPtr);
+/**
+* Read pointer named variable
+* @param[in] _pstName variable name
+* @param[out] _pvPtr return pointer
+* @return if the operation succeeded ( 0 ) or not ( !0 )
+*/
+SciErr readNamedPointer(void* _pvCtx, const char* _pstName, void** _pvPtr);
- /* shortcut functions */
+/* shortcut functions */
- /**
- * Check if the variable is of pointer type
- * @param[in] _piAddress variable address
- * @return 1 for true and 0 for false
- */
- int isPointerType(void* _pvCtx, int* _piAddress);
+/**
+* Check if the variable is of pointer type
+* @param[in] _piAddress variable address
+* @return 1 for true and 0 for false
+*/
+int isPointerType(void* _pvCtx, int* _piAddress);
- /**
- * check if the named variable type of pointer type
- * @param[in] _pstName variable name
- * @return 1 for true and 0 for false
- */
- int isNamedPointerType(void* _pvCtx, const char* _pstName);
+/**
+* check if the named variable type of pointer type
+* @param[in] _pstName variable name
+* @return 1 for true and 0 for false
+*/
+int isNamedPointerType(void* _pvCtx, const char* _pstName);
#ifdef __cplusplus
}
#include "dynlib_api_scilab.h"
- /*****************************/
- /* poly matrix functions */
- /*****************************/
-
- /**
- * Get polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _pstVarName return variable name of polynomials
- * @param[out] _piVarNameLen return length of _pstVarName
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr getPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen);
-
- /**
- * Get polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr getMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal);
-
- /**
- * Get complex polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return real coefficients
- * @param[out] _pdblImg return imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr getComplexMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
-
- /**
- * Create a polynomial variable
- * @param[in] _iVar variable number
- * @param[in] _pstVarName polynomial variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _piNbCoef number of polynomial coefficients for each element
- * @param[in] _pdblReal pointer to real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr createMatrixOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal);
-
- /**
- * Create complex polynomial variable data
- * @param[in] _iVar variable number
- * @param[in] _pstVarName polynomial variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _piNbCoef number of polynomial coefficients for each element
- * @param[in] _pdblReal pointer to real coefficients
- * @param[in] _pdblImg pointer to imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr createComplexMatrixOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg);
-
- /**
- * Create polynomial named variable
- * @param[in] _pstName variable name
- * @param[in] _pstVarName polynomial variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _piNbCoef number of polynomial coefficients for each element
- * @param[in] _pdblReal pointer to real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr createNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal);
-
- /**
- * Create complex polynomial named variable
- * @param[in] _pstName variable name
- * @param[in] _pstVarName polynomial variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _piNbCoef number of polynomial coefficients for each element
- * @param[in] _pdblReal pointer to real coefficients
- * @param[in] _pdblImg pointer to imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr createNamedComplexMatrixOfPoly(void* _pvCtx, const char* _pstName, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg);
-
- /**
- * Get named polynomial variable
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr readNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal);
-
- /**
- * Get named complex polynomial variable
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return real coefficients
- * @param[out] _pdblImg return imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
-
- SciErr readNamedComplexMatrixOfPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
-
- /* shortcut functions */
-
- /**
- * Check if the variable type is polynomial
- * @param[in] _piAddress variable address
- * @return 1 for true and 0 for false
- */
- int isPolyType(void* _pvCtx, int* _piAddress);
-
- /**
- * Check if the named variable type is polynomial
- * @param[in] _pstName variable name
- * @return 1 for true and 0 for false
- */
- int isNamedPolyType(void* _pvCtx, const char* _pstName);
-
- /**
- * Get single polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _piNbCoef return number of polynomial coefficients
- * @param[out] _pdblReal pointer to real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal);
-
- /**
- * Get single complex polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _piNbCoef return number of polynomial coefficients
- * @param[out] _pdblReal pointer to real coefficients
- * @param[out] _pdblImg pointer to imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedSingleComplexPoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
-
- /**
- * Get single named polynomial variable data
- * @param[in] _pstName variable name
- * @param[out] _piNbCoef return number of polynomial coefficients
- * @param[out] _pdblReal pointer to real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedNamedSinglePoly(void* _pvCtx, const char* _pstName, int* _piNbCoef, double** _pdblReal);
-
- /**
- * Get single named complex polynomial variable data
- * @param[in] _pstName variable name
- * @param[out] _piNbCoef return number of polynomial coefficients
- * @param[out] _pdblReal pointer to real coefficients
- * @param[out] _pdblImg pointer to imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedNamedSingleComplexPoly(void* _pvCtx, const char* _pstName, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
-
- /**
- * Get matrix of polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients
- * @param[out] _pdblReal return pointer to real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal);
-
- /**
- * Get matrix of complex polynomial variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return pointer to real coefficients
- * @param[out] _pdblImg return pointer to imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedMatrixOfComplexPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
-
- /**
- * Get named matrix of polynomials variable data
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return pointer to real coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal);
-
- /**
- * Get named matrix of complex polynomials variable data
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbCoef return number of polynomial coefficients for each element
- * @param[out] _pdblReal return pointer to real coefficients
- * @param[out] _pdblImg return pointer to imaginary coefficients
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedNamedMatrixOfComplexPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
-
- /**
- * Free memory allocated for a single polynomial variable ( named or not )
- * @param[in] _pdblReal pointer to real coefficients
- */
- void freeAllocatedSinglePoly(double* _pdblReal);
-
- /**
- * Free memory allocated for a single complex polynomial variable ( named or not )
- * @param[in] _pdblReal pointer to real coefficients
- * @param[in] _pdblImg pointer to imaginary coefficients
- */
- void freeAllocatedSingleComplexPoly(double* _pdblReal, double* _pdblImg);
-
- /**
- * Free memory allocated for a polynomial matrix ( named or not )
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _piNbCoef number of polynomial coefficients for each element
- * @param[in] _pdblReal pointer to real coefficients
- */
- void freeAllocatedMatrixOfPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal);
-
- /**
- * Free memory allocated for a complex polynomial matrix ( named or not )
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _piNbCoef number of polynomial coefficients for each element
- * @param[in] _pdblReal pointer to real coefficients
- * @param[in] _pdblImg pointer to imaginary coefficients
- */
- void freeAllocatedMatrixOfComplexPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
+/*****************************/
+/* poly matrix functions */
+/*****************************/
+
+/**
+ * Get polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _pstVarName return variable name of polynomials
+ * @param[out] _piVarNameLen return length of _pstVarName
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr getPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen);
+
+/**
+ * Get polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr getMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal);
+
+/**
+ * Get complex polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return real coefficients
+ * @param[out] _pdblImg return imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr getComplexMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
+
+/**
+ * Create a polynomial variable
+ * @param[in] _iVar variable number
+ * @param[in] _pstVarName polynomial variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr createMatrixOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal);
+
+/**
+ * Create complex polynomial variable data
+ * @param[in] _iVar variable number
+ * @param[in] _pstVarName polynomial variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ * @param[in] _pdblImg pointer to imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr createComplexMatrixOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg);
+
+/**
+ * Create polynomial named variable
+ * @param[in] _pstName variable name
+ * @param[in] _pstVarName polynomial variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr createNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal);
+
+/**
+ * Create complex polynomial named variable
+ * @param[in] _pstName variable name
+ * @param[in] _pstVarName polynomial variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ * @param[in] _pdblImg pointer to imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr createNamedComplexMatrixOfPoly(void* _pvCtx, const char* _pstName, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg);
+
+/**
+ * Get named polynomial variable
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr readNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal);
+
+/**
+ * Get named complex polynomial variable
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return real coefficients
+ * @param[out] _pdblImg return imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+
+SciErr readNamedComplexMatrixOfPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
+
+/* shortcut functions */
+
+/**
+ * Check if the variable type is polynomial
+ * @param[in] _piAddress variable address
+ * @return 1 for true and 0 for false
+ */
+int isPolyType(void* _pvCtx, int* _piAddress);
+
+/**
+ * Check if the named variable type is polynomial
+ * @param[in] _pstName variable name
+ * @return 1 for true and 0 for false
+ */
+int isNamedPolyType(void* _pvCtx, const char* _pstName);
+
+/**
+ * Get single polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piNbCoef return number of polynomial coefficients
+ * @param[out] _pdblReal pointer to real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal);
+
+/**
+ * Get single complex polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piNbCoef return number of polynomial coefficients
+ * @param[out] _pdblReal pointer to real coefficients
+ * @param[out] _pdblImg pointer to imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedSingleComplexPoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
+
+/**
+ * Get single named polynomial variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piNbCoef return number of polynomial coefficients
+ * @param[out] _pdblReal pointer to real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedNamedSinglePoly(void* _pvCtx, const char* _pstName, int* _piNbCoef, double** _pdblReal);
+
+/**
+ * Get single named complex polynomial variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piNbCoef return number of polynomial coefficients
+ * @param[out] _pdblReal pointer to real coefficients
+ * @param[out] _pdblImg pointer to imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedNamedSingleComplexPoly(void* _pvCtx, const char* _pstName, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
+
+/**
+ * Get matrix of polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients
+ * @param[out] _pdblReal return pointer to real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal);
+
+/**
+ * Get matrix of complex polynomial variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return pointer to real coefficients
+ * @param[out] _pdblImg return pointer to imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedMatrixOfComplexPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
+
+/**
+ * Get named matrix of polynomials variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return pointer to real coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedNamedMatrixOfPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal);
+
+/**
+ * Get named matrix of complex polynomials variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return pointer to real coefficients
+ * @param[out] _pdblImg return pointer to imaginary coefficients
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedNamedMatrixOfComplexPoly(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
+
+/**
+ * Free memory allocated for a single polynomial variable ( named or not )
+ * @param[in] _pdblReal pointer to real coefficients
+ */
+void freeAllocatedSinglePoly(double* _pdblReal);
+
+/**
+ * Free memory allocated for a single complex polynomial variable ( named or not )
+ * @param[in] _pdblReal pointer to real coefficients
+ * @param[in] _pdblImg pointer to imaginary coefficients
+ */
+void freeAllocatedSingleComplexPoly(double* _pdblReal, double* _pdblImg);
+
+/**
+ * Free memory allocated for a polynomial matrix ( named or not )
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ */
+void freeAllocatedMatrixOfPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal);
+
+/**
+ * Free memory allocated for a complex polynomial matrix ( named or not )
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ * @param[in] _pdblImg pointer to imaginary coefficients
+ */
+void freeAllocatedMatrixOfComplexPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
#ifdef __cplusplus
}
#endif
#include "dynlib_api_scilab.h"
- /*****************************/
- /* sparse matrix functions */
- /*****************************/
+/*****************************/
+/* sparse matrix functions */
+/*****************************/
- /**
- * Get sparse variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal return pointer to real data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr getSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
+/**
+ * Get sparse variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr getSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
- /**
- * Get complex sparse variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal return pointer to real parts
- * @param[out] _pdblImg return pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr getComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
+/**
+ * Get complex sparse variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real parts
+ * @param[out] _pdblImg return pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr getComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
- /**
- * Allocate a sparse variable
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column position ( 1 indexed )
- * @param[out] _pdblReal return pointer to data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr allocSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
+/**
+ * Allocate a sparse variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column position ( 1 indexed )
+ * @param[out] _pdblReal return pointer to data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr allocSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
- /**
- * Allocate a complex sparse variable
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal return pointer to real parts
- * @param[out] _pdblImg return pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr allocComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
+/**
+ * Allocate a complex sparse variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real parts
+ * @param[out] _pdblImg return pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr allocComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
- /**
- * Create a sparse double variable
- * @param[in] _iVar variable number
- * @param[in] _iRows nmber of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[in] _piNbItemRow array of numbers of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @param[in] _pdblReal pointer to real data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr createSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal);
+/**
+ * Create a sparse double variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows nmber of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[in] _piNbItemRow array of numbers of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @param[in] _pdblReal pointer to real data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr createSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal);
- /**
- * Create a complex sparse double variable
- * @param[in] _iVar variable number
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[in] _piNbItemRow array of numbers of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @param[in] _pdblReal pointer to real parts
- * @param[in] _pdblImg pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr createComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg);
+/**
+ * Create a complex sparse double variable
+ * @param[in] _iVar variable number
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[in] _piNbItemRow array of numbers of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @param[in] _pdblReal pointer to real parts
+ * @param[in] _pdblImg pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr createComplexSparseMatrix(void* _pvCtx, int _iVar, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg);
- /**
- * Create a named sparse double variable
- * @param[in] _pstName variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[in] _piNbItemRow array of numbers of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @param[in] _pdblReal pointer to real data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr createNamedSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal);
+/**
+ * Create a named sparse double variable
+ * @param[in] _pstName variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[in] _piNbItemRow array of numbers of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @param[in] _pdblReal pointer to real data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr createNamedSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal);
- /**
- * Create a named complex sparse double variable
- * @param[in] _pstName variable name
- * @param[in] _iRows number of rows
- * @param[in] _iCols number of columns
- * @param[in] _iNbItem number of items
- * @param[in] _piNbItemRow array of number of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @param[in] _pdblReal pointer to real parts
- * @param[int] _pdblImg pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr createNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg);
+/**
+ * Create a named complex sparse double variable
+ * @param[in] _pstName variable name
+ * @param[in] _iRows number of rows
+ * @param[in] _iCols number of columns
+ * @param[in] _iNbItem number of items
+ * @param[in] _piNbItemRow array of number of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @param[in] _pdblReal pointer to real parts
+ * @param[int] _pdblImg pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr createNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, int _iNbItem, const int* _piNbItemRow, const int* _piColPos, const double* _pdblReal, const double* _pdblImg);
- /**
- * Read named sparse double variable
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal pointer to real data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr readNamedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal);
+/**
+ * Read named sparse double variable
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal pointer to real data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr readNamedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal);
- /**
- * Read a named complex sparse double variable
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of number of items for each row
- * @param[out] _piColPos return array of item column position ( 1 indexed )
- * @param[out] _pdblReal pointer to real parts
- * @param[out] _pdblImg pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- SciErr readNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg);
+/**
+ * Read a named complex sparse double variable
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of number of items for each row
+ * @param[out] _piColPos return array of item column position ( 1 indexed )
+ * @param[out] _pdblReal pointer to real parts
+ * @param[out] _pdblImg pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr readNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg);
- /* shortcut functions */
+/* shortcut functions */
- /**
- * Check if the variable type is sparse double
- * @param[in] _piAddress variable address
- * @return 1 for true and 0 for false
- */
- int isSparseType(void* _pvCtx, int* _piAddress);
+/**
+ * Check if the variable type is sparse double
+ * @param[in] _piAddress variable address
+ * @return 1 for true and 0 for false
+ */
+int isSparseType(void* _pvCtx, int* _piAddress);
- /**
- * Check if the variable type is sparse double
- * @param[in] _pstName variable name
- * @return 1 for true and 0 for false
- */
- int isNamedSparseType(void* _pvCtx, const char* _pstName);
+/**
+ * Check if the variable type is sparse double
+ * @param[in] _pstName variable name
+ * @return 1 for true and 0 for false
+ */
+int isNamedSparseType(void* _pvCtx, const char* _pstName);
- /**
- * Get sparse variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal return pointer to real data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
+/**
+ * Get sparse variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
- /**
- * Get complex sparse variable data
- * @param[in] _piAddress variable address
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal return pointer to real parts
- * @param[out] _pdblImg return pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getAllocatedComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
+/**
+ * Get complex sparse variable data
+ * @param[in] _piAddress variable address
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real parts
+ * @param[out] _pdblImg return pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getAllocatedComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
- /**
- * Get named sparse variable data
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column positions ( 1 indexed )
- * @param[out] _pdblReal return pointer to real data
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getNamedAllocatedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
+/**
+ * Get named sparse variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column positions ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real data
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getNamedAllocatedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
- /**
- * Get named complex sparse variable data
- * @param[in] _pstName variable name
- * @param[out] _piRows return number of rows
- * @param[out] _piCols return number of columns
- * @param[out] _piNbItem return number of items
- * @param[out] _piNbItemRow return array of numbers of items for each row
- * @param[out] _piColPos return array of item column position ( 1 indexed )
- * @param[out] _pdblReal return pointer to real parts
- * @param[out] _pdblImg return pointer to imaginary parts
- * @return if the operation succeeded ( 0 ) or not ( !0 )
- */
- int getNamedAllocatedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
+/**
+ * Get named complex sparse variable data
+ * @param[in] _pstName variable name
+ * @param[out] _piRows return number of rows
+ * @param[out] _piCols return number of columns
+ * @param[out] _piNbItem return number of items
+ * @param[out] _piNbItemRow return array of numbers of items for each row
+ * @param[out] _piColPos return array of item column position ( 1 indexed )
+ * @param[out] _pdblReal return pointer to real parts
+ * @param[out] _pdblImg return pointer to imaginary parts
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+int getNamedAllocatedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
- /**
- * Free memory allocated for a sparse matrix (named or not) by shortcut functions
- * @param[in] _piNbItemRow array of numbers of items for each row
- * @param[in] _piColPos array of item column position ( 1 indexed )
- * @param[in] _pdblReal pointer to real data
- */
- void freeAllocatedSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal);
+/**
+ * Free memory allocated for a sparse matrix (named or not) by shortcut functions
+ * @param[in] _piNbItemRow array of numbers of items for each row
+ * @param[in] _piColPos array of item column position ( 1 indexed )
+ * @param[in] _pdblReal pointer to real data
+ */
+void freeAllocatedSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal);
- /**
- * Free memory allocated for a complex sparse matrix (named or not) by shortcut functions
- * @param[in] _piNbItemRow array of numbers of items for each row
- * @param[in] _piColPos array of item column positions ( 1 indexed )
- * @param[in] _pdblReal pointer to real parts
- * @param[in] _pdblImg pointer to imaginary parts
- */
- void freeAllocatedComplexSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal, double* _pdblImg);
+/**
+ * Free memory allocated for a complex sparse matrix (named or not) by shortcut functions
+ * @param[in] _piNbItemRow array of numbers of items for each row
+ * @param[in] _piColPos array of item column positions ( 1 indexed )
+ * @param[in] _pdblReal pointer to real parts
+ * @param[in] _pdblImg pointer to imaginary parts
+ */
+void freeAllocatedComplexSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal, double* _pdblImg);
#ifdef __cplusplus
}
#include "dynlib_api_scilab.h"
- /**
- * create an empty matrix in the scilab stack in order to see it in the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnEmptyMatrix(void);
-
- /**
- * copy the string value in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnString(const char * value ) ;
-
- /**
- * copy a char value into a scilab string in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnChar(char value ) ;
-
- /**
- * copy a single double in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnDouble(double value ) ;
-
- /**
- * copy a single int in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnInt(int value ) ;
-
- /**
- * copy a double array into a row vector in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnRowVector(const double values[], int nbValues ) ;
-
- /**
- * copy a int array into a row vector (of double) in the scilab stack
- * in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnRowVectorFromInt(const int values[], int nbValues ) ;
-
- /**
- * copy an int array into an int row vector in the scilab stack
- * in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnRowIntVector(const int values[], int nbValues ) ;
-
- /**
- * copy a char * array into an string row vector in the scilab stack
- * in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnRowStringVector(char * values[], int nbValues ) ;
-
- /**
- * copy a handle in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnHandle(long handle ) ;
-
- /**
- * copy an handle array into a row vector in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnRowHandleVector(const long handles[], int nbValues ) ;
-
- /**
- * copy an handle array into a col vector in the scilab stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnColHandleVector(const long handles[], int nbValues ) ;
-
- /**
- * copy a matrix stored has a double array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrix(double values[], int nbRow, int nbCol ) ;
-
- /**
- * copy a matrix stored has a char * array
- * into a Scilab string matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnStringMatrix(char * values[], int nbRow, int nbCol ) ;
-
- /**
- * return user data in the scilab console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnUserData(const int * userData, int userDataSize ) ;
-
- /**
- * copy a matrix stored has a double hypermatrix
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnHypermatOfDouble(int dims[], int ndims, double values[]);
-
- /**
- * copy a matrix stored has a int8 hypermatrix
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnHypermatOfInteger8(int dims[], int ndims, char values[]);
-
- /**
- * copy a matrix stored has a uint8 hypermatrix
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnHypermatOfUnsignedInteger8(int dims[], int ndims, unsigned char values[]);
-
- /**
- * copy a matrix stored has a int8 array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrixOfInteger8(char values[], int nbRow, int nbCol);
-
- /**
- * copy a matrix stored has a uint8 array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrixOfUnsignedInteger8(unsigned char values[], int nbRow, int nbCol);
-
- /**
- * copy a matrix stored has a int16 array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrixOfInteger16(short values[], int nbRow, int nbCol);
-
- /**
- * copy a matrix stored has a uint16 array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrixOfUnsignedInteger16(unsigned short values[], int nbRow, int nbCol);
-
- /**
- * copy a matrix stored has a int32 array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrixOfInteger32(int values[], int nbRow, int nbCol);
-
- /**
- * copy a matrix stored has a uint32 array
- * into a Scilab matrix in the stack in order to see it the console.
- * @return 0 if the function was executed correctly, -1 if an error occurred.
- */
- void* sciReturnMatrixOfUnsignedInteger32(unsigned int values[], int nbRow, int nbCol);
+/**
+ * create an empty matrix in the scilab stack in order to see it in the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnEmptyMatrix(void);
+
+/**
+ * copy the string value in the scilab stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnString(const char * value ) ;
+
+/**
+ * copy a char value into a scilab string in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnChar(char value ) ;
+
+/**
+ * copy a single double in the scilab stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnDouble(double value ) ;
+
+/**
+ * copy a single int in the scilab stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnInt(int value ) ;
+
+/**
+ * copy a double array into a row vector in the scilab stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnRowVector(const double values[], int nbValues ) ;
+
+/**
+* copy a int array into a row vector (of double) in the scilab stack
+* in order to see it the console.
+* @return 0 if the function was executed correctly, -1 if an error occurred.
+*/
+void* sciReturnRowVectorFromInt(const int values[], int nbValues ) ;
+
+/**
+ * copy an int array into an int row vector in the scilab stack
+ * in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnRowIntVector(const int values[], int nbValues ) ;
+
+/**
+ * copy a char * array into an string row vector in the scilab stack
+ * in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnRowStringVector(char * values[], int nbValues ) ;
+
+/**
+ * copy a handle in the scilab stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnHandle(long handle ) ;
+
+/**
+ * copy an handle array into a row vector in the scilab stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnRowHandleVector(const long handles[], int nbValues ) ;
+
+/**
+* copy an handle array into a col vector in the scilab stack in order to see it the console.
+* @return 0 if the function was executed correctly, -1 if an error occurred.
+*/
+void* sciReturnColHandleVector(const long handles[], int nbValues ) ;
+
+/**
+ * copy a matrix stored has a double array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrix(double values[], int nbRow, int nbCol ) ;
+
+/**
+ * copy a matrix stored has a char * array
+ * into a Scilab string matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnStringMatrix(char * values[], int nbRow, int nbCol ) ;
+
+/**
+ * return user data in the scilab console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnUserData(const int * userData, int userDataSize ) ;
+
+/**
+ * copy a matrix stored has a double hypermatrix
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnHypermatOfDouble(int dims[], int ndims, double values[]);
+
+/**
+ * copy a matrix stored has a int8 hypermatrix
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnHypermatOfInteger8(int dims[], int ndims, char values[]);
+
+/**
+ * copy a matrix stored has a uint8 hypermatrix
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnHypermatOfUnsignedInteger8(int dims[], int ndims, unsigned char values[]);
+
+/**
+ * copy a matrix stored has a int8 array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrixOfInteger8(char values[], int nbRow, int nbCol);
+
+/**
+ * copy a matrix stored has a uint8 array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrixOfUnsignedInteger8(unsigned char values[], int nbRow, int nbCol);
+
+/**
+ * copy a matrix stored has a int16 array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrixOfInteger16(short values[], int nbRow, int nbCol);
+
+/**
+ * copy a matrix stored has a uint16 array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrixOfUnsignedInteger16(unsigned short values[], int nbRow, int nbCol);
+
+/**
+ * copy a matrix stored has a int32 array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrixOfInteger32(int values[], int nbRow, int nbCol);
+
+/**
+ * copy a matrix stored has a uint32 array
+ * into a Scilab matrix in the stack in order to see it the console.
+ * @return 0 if the function was executed correctly, -1 if an error occurred.
+ */
+void* sciReturnMatrixOfUnsignedInteger32(unsigned int values[], int nbRow, int nbCol);
#ifdef __cplusplus
}
#endif
#include "dynlib_api_scilab.h"
- /**
- * Construct a new tlist for return in the console.
- * Only one tlist should be used at the same time.
- * @param nbElement Number of element of element in the list not including the name.
- * @param name Array of string of size nbElement containing the names of the list
- * and its properties. Its size is nbElement + 1.
- * @return a pointer to the newly created list or NULL if an error occurred.
- */
- void* createReturnedList(int nbElements, char* elementName[]);
+/**
+ * Construct a new tlist for return in the console.
+ * Only one tlist should be used at the same time.
+ * @param nbElement Number of element of element in the list not including the name.
+ * @param name Array of string of size nbElement containing the names of the list
+ * and its properties. Its size is nbElement + 1.
+ * @return a pointer to the newly created list or NULL if an error occurred.
+ */
+void* createReturnedList(int nbElements, char* elementName[]);
- /**
- * add a new row vector in the list.
- * @param[in/out] void the returned tList
- * @param[in] vector values to be inserted of size nbValues
- * @return 0 if the call was successful
- */
- int addRowVectorToReturnedList(void* list, const double vector[], int nbValues);
+/**
+ * add a new row vector in the list.
+ * @param[in/out] void the returned tList
+ * @param[in] vector values to be inserted of size nbValues
+ * @return 0 if the call was successful
+ */
+int addRowVectorToReturnedList(void* list, const double vector[], int nbValues);
- /**
- * add a new column vector in the list.
- * @param[in/out] void the returned tList
- * @param[in] vector values to be inserted of size nbValues
- * @return 0 if the call was successful
- */
- int addColVectorToReturnedList(void* list, const double vector[], int nbValues);
+/**
+ * add a new column vector in the list.
+ * @param[in/out] void the returned tList
+ * @param[in] vector values to be inserted of size nbValues
+ * @return 0 if the call was successful
+ */
+int addColVectorToReturnedList(void* list, const double vector[], int nbValues);
- /**
- * add a new column vector in the list.
- * @param[in/out] void the returned tList
- * @param[in] matrix values to be inserted of size nbRow x nbCol
- * @return 0 if the call was successful
- */
- int addMatrixToReturnedList(void* list, const double matrix[], int nbRow, int nbCol);
+/**
+ * add a new column vector in the list.
+ * @param[in/out] void the returned tList
+ * @param[in] matrix values to be inserted of size nbRow x nbCol
+ * @return 0 if the call was successful
+ */
+int addMatrixToReturnedList(void* list, const double matrix[], int nbRow, int nbCol);
- /**
- * add a new string column vector in the list.
- * @param[in/out] void the returned tList
- * @param[in] vector values to be inserted of size nbValues
- * @return 0 if the call was successful
- */
- int addStringColVectorToReturnedList(void* list, char* vector[], int nbValues);
- int addStringToReturnedList(void* list, char * str);
+/**
+ * add a new string column vector in the list.
+ * @param[in/out] void the returned tList
+ * @param[in] vector values to be inserted of size nbValues
+ * @return 0 if the call was successful
+ */
+int addStringColVectorToReturnedList(void* list, char* vector[], int nbValues);
+int addStringToReturnedList(void* list, char * str);
#ifdef __cplusplus
}
#endif
i++;
}
-
+
for (const auto& o : opt)
{
int typeOfOpt = -1;
}
/*------------------------------------------------------------------------*/
int addRowVectorToReturnedList(void* list, const double vector[], int nbValues)
-{
+{
types::TList* pL = (types::TList*)list;
pL->append((types::InternalType*)sciReturnMatrix((double*)vector, 1, nbValues));
return 0;
scilabVar API_PROTO(createBooleanMatrix2d)(scilabEnv env, int row, int col)
{
int dims[2] = {row, col};
-
+
#ifdef __API_SCILAB_SAFE__
for (int i = 0; i < 2; ++i)
{
{
return 0;
}
-
+
if (it->isGenericType())
{
types::GenericType* gt = static_cast<types::GenericType*>(it);
{
out[i] = (scilabVar)outCall[i];
}
-
+
return STATUS_OK;
}
return STATUS_ERROR;
}
#endif
-
+
bool ret = l->set(index, (types::InternalType*)val) != nullptr;
return ret ? STATUS_OK : STATUS_ERROR;
}
scilab_setInternalError(env, L"createPolyMatrix", _W("memory allocation error"));
return nullptr;
}
-
+
p->setComplex(complex != 0);
return (scilabVar)p;
}
}
/* Check some sizes */
- if (mIPARAM*nIPARAM != 11)
+ 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)
+ 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])
+ 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;
LDZ = LDV;
/* Check some sizes */
- if (mIPARAM*nIPARAM != 11)
+ if (mIPARAM * nIPARAM != 11)
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "IPARAM", 11);
return 0;
}
- if (mIPNTR*nIPNTR != 14)
+ if (mIPNTR * nIPNTR != 14)
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "IPNTR", 14);
return 0;
}
- if (mRESID*nRESID != *(int*)(pN))
+ if (mRESID * nRESID != *(int*)(pN))
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "RESID", *(int*)(pN));
return 0;
return 0;
}
- if (mSELECT*nSELECT != *(int*)(pNCV))
+ if (mSELECT * nSELECT != *(int*)(pNCV))
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "SELECT", *(int*)(pNCV));
return 0;
}
- if (mDr*nDr != (*(int*)(pNEV) + 1))
+ if (mDr * nDr != (*(int*)(pNEV) + 1))
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "Dr", *(int*)(pNEV) + 1);
return 0;
}
- if (mDi*nDi != (*(int*)(pNEV) + 1))
+ if (mDi * nDi != (*(int*)(pNEV) + 1))
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "Di", *(int*)(pNEV) + 1);
return 0;
return 0;
}
- if (mWORKev*nWORKev != 3 * *(int*)(pNCV))
+ if (mWORKev * nWORKev != 3 * *(int*)(pNCV))
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "WORKev", 3 * *(int*)(pNCV));
return 0;
}
/* Check some sizes */
- if (mIPARAM*nIPARAM != 11)
+ 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)
+ 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])
+ if (mRESID * nRESID != pN[0])
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "RESID", pN[0]);
return 1;
LDZ = LDV;
/* Check some sizes */
- if (mIPARAM*nIPARAM != 11)
+ 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)
+ 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])
+ if (mRESID * nRESID != pN[0])
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "RESID", pN[0]);
return 1;
return 1;
}
- if (mSELECT*nSELECT != pNCV[0])
+ if (mSELECT * nSELECT != pNCV[0])
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "SELECT", pNCV[0]);
return 1;
}
- if (mD*nD != (pNEV[0]))
+ if (mD * nD != (pNEV[0]))
{
Scierror(999, _("%s: Wrong size for input argument %s: An array of size %d expected.\n"), fname, "D", pNEV[0]);
return 1;
namespace analysis
{
- class Chrono
+class Chrono
+{
+ std::chrono::steady_clock::time_point start;
+ std::chrono::steady_clock::time_point end;
+
+public:
+
+ void start_chrono()
+ {
+ start = std::chrono::steady_clock::now();
+ }
+
+ void stop_chrono()
{
- std::chrono::steady_clock::time_point start;
- std::chrono::steady_clock::time_point end;
-
- public:
-
- void start_chrono()
- {
- start = std::chrono::steady_clock::now();
- }
-
- void stop_chrono()
- {
- end = std::chrono::steady_clock::now();
- }
-
- double get_duration() const
- {
- return (double)std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() * 1e-9;
- }
-
- friend std::wostream & operator<<(std::wostream & out, const Chrono & chrono)
- {
- out << L"Elapsed time: " << chrono.get_duration() << L" s.";
- return out;
- }
- };
-
+ end = std::chrono::steady_clock::now();
+ }
+
+ double get_duration() const
+ {
+ return (double)std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() * 1e-9;
+ }
+
+ friend std::wostream & operator<<(std::wostream & out, const Chrono & chrono)
+ {
+ out << L"Elapsed time: " << chrono.get_duration() << L" s.";
+ return out;
+ }
+};
+
} // namespace analysis
#endif // __CHRONO_HXX__
{
functionId = id;
}
-
+
inline uint64_t getFunctionId() const
{
return functionId;
{
out << L", temp id:" << res.tempId;
}
- if (res.functionId)
+ if (res.functionId)
{
out << L", function id:" << res.functionId;
}
namespace analysis
{
- class AnalysisVisitor;
- class Exp;
- class OpExp;
+class AnalysisVisitor;
+class Exp;
+class OpExp;
- class OperAnalyzer
- {
+class OperAnalyzer
+{
- public:
+public:
- OperAnalyzer() { }
+ OperAnalyzer() { }
- bool analyze(AnalysisVisitor & visitor, ast::Exp & e);
- ast::MemfillExp * analyzeMemfill(AnalysisVisitor & visitor, ast::OpExp & oe);
- };
+ bool analyze(AnalysisVisitor & visitor, ast::Exp & e);
+ ast::MemfillExp * analyzeMemfill(AnalysisVisitor & visitor, ast::OpExp & oe);
+};
} // namespace analysis
namespace analysis
{
- class Call
- {
+class Call
+{
- protected:
+protected:
- const std::wstring name;
- std::vector<TIType> args;
+ const std::wstring name;
+ std::vector<TIType> args;
- public:
+public:
- Call(const std::wstring & _name, const std::vector<TIType> & _args) : name(_name), args(_args) { }
- Call(const std::wstring & _name, const TIType & _arg) : name(_name), args(1, _arg) { }
- Call(const std::wstring & _name) : name(_name) { }
- Call(Call && call) : name(call.name), args(call.args) { }
+ Call(const std::wstring & _name, const std::vector<TIType> & _args) : name(_name), args(_args) { }
+ Call(const std::wstring & _name, const TIType & _arg) : name(_name), args(1, _arg) { }
+ Call(const std::wstring & _name) : name(_name) { }
+ Call(Call && call) : name(call.name), args(call.args) { }
- inline const std::wstring & getName() const
- {
- return name;
- }
+ inline const std::wstring & getName() const
+ {
+ return name;
+ }
- inline void setArgs(const std::vector<TIType> & _args)
- {
- args = _args;
- }
+ inline void setArgs(const std::vector<TIType> & _args)
+ {
+ args = _args;
+ }
- inline const std::vector<TIType> & getArgs() const
- {
- return args;
- }
+ inline const std::vector<TIType> & getArgs() const
+ {
+ return args;
+ }
- friend std::wostream & operator<<(std::wostream & out, const Call & res)
- {
- out << L"Call " << res.name;
- return out;
- }
- };
+ friend std::wostream & operator<<(std::wostream & out, const Call & res)
+ {
+ out << L"Call " << res.name;
+ return out;
+ }
+};
} // namespace analysis
namespace analysis
{
- class SizeCall : public Call
- {
+class SizeCall : public Call
+{
+
+public:
- public:
+ enum Kind { R, C, RC, R_C, ONE, BOTH, DUNNO };
- enum Kind { R, C, RC, R_C, ONE, BOTH, DUNNO };
+private:
- private:
-
- Kind kind;
-
- public:
+ Kind kind;
- SizeCall(Kind _kind) : Call(L"size"), kind(_kind) { }
+public:
- inline Kind getKind() const
- {
- return kind;
- }
- };
+ SizeCall(Kind _kind) : Call(L"size"), kind(_kind) { }
+
+ inline Kind getKind() const
+ {
+ return kind;
+ }
+};
} // namespace analysis
{
struct __MPCMO
{
- uint64_t id;
+ uint64_t id;
MPolyConstraintSet verified;
- ConstraintManager::UnverifiedSet unverified;
- std::set<symbol::Symbol> globalConstants;
+ ConstraintManager::UnverifiedSet unverified;
+ std::set<symbol::Symbol> globalConstants;
MacroOut out;
__MPCMO(const uint64_t _id, const MPolyConstraintSet & _verified, const ConstraintManager::UnverifiedSet & _unverified, const std::set<symbol::Symbol> & _globalConstants, MacroOut && _out) : id(_id), verified(_verified), unverified(_unverified), globalConstants(_globalConstants), out(_out) { }
- inline std::size_t getUnverifiedSize() const
- {
- std::size_t size = 0;
- for (const auto & mpcs : unverified)
- {
- size += mpcs.size();
- }
- return size;
- }
-
- struct Compare
- {
- inline bool operator()(const __MPCMO & L, const __MPCMO & R) const
- {
- std::size_t sizeL = L.getUnverifiedSize();
- std::size_t sizeR = R.getUnverifiedSize();
- if (sizeL < sizeR)
- {
- return true;
- }
- else if (sizeL == sizeR)
- {
- sizeL = L.verified.size();
- sizeR = R.verified.size();
- if (sizeL < sizeR)
- {
- return true;
- }
- else if (sizeL == sizeR)
- {
- return L.id < R.id;
- }
- }
- return false;
- }
- };
+ inline std::size_t getUnverifiedSize() const
+ {
+ std::size_t size = 0;
+ for (const auto & mpcs : unverified)
+ {
+ size += mpcs.size();
+ }
+ return size;
+ }
+
+ struct Compare
+ {
+ inline bool operator()(const __MPCMO & L, const __MPCMO & R) const
+ {
+ std::size_t sizeL = L.getUnverifiedSize();
+ std::size_t sizeR = R.getUnverifiedSize();
+ if (sizeL < sizeR)
+ {
+ return true;
+ }
+ else if (sizeL == sizeR)
+ {
+ sizeL = L.verified.size();
+ sizeR = R.verified.size();
+ if (sizeL < sizeR)
+ {
+ return true;
+ }
+ else if (sizeL == sizeR)
+ {
+ return L.id < R.id;
+ }
+ }
+ return false;
+ }
+ };
};
uint64_t & id;
CompleteMacroSignature(GVN & _gvn, uint64_t & _id) : id(_id), gvn(_gvn) { }
inline GVN & getGVN()
- {
- return gvn;
- }
+ {
+ return gvn;
+ }
const MacroOut * getOutTypes(AnalysisVisitor & visitor, const MacroSignature & signature, MacroDef * macrodef, DataManager & dm, const unsigned int rhs, std::vector<TIType> & in, const std::vector<GVN::Value *> values, uint64_t & functionId);
FunctionBlock(const unsigned int id, Block * parent, ast::Exp * exp);
virtual ~FunctionBlock()
- {
- // we got a clone
- delete exp;
- }
+ {
+ // we got a clone
+ delete exp;
+ }
inline ConstraintManager & getConstraintManager()
{
}
inline void setFunctionId(const uint64_t id)
- {
- functionId = id;
- }
+ {
+ functionId = id;
+ }
inline uint64_t getFunctionId() const
- {
- return functionId;
- }
+ {
+ return functionId;
+ }
inline const MPolyConstraintSet & getVerifiedConstraints() const
{
namespace analysis
{
- class GVN;
- class AnalysisVisitor;
+class GVN;
+class AnalysisVisitor;
- class PolymorphicMacroCache
- {
- typedef std::unordered_map<MacroSignature, CompleteMacroSignature, MacroSignature::Hash, MacroSignature::Eq> MacroSignMap;
- uint64_t id;
- MacroSignMap signatures;
- GVN gvn;
+class PolymorphicMacroCache
+{
+ typedef std::unordered_map<MacroSignature, CompleteMacroSignature, MacroSignature::Hash, MacroSignature::Eq> MacroSignMap;
+ uint64_t id;
+ MacroSignMap signatures;
+ GVN gvn;
- public:
+public:
- PolymorphicMacroCache();
- ~PolymorphicMacroCache();
+ PolymorphicMacroCache();
+ ~PolymorphicMacroCache();
- const bool getOutTypes(AnalysisVisitor & visitor, MacroDef * macrodef, std::vector<TIType> & in, std::vector<TIType> & out, uint64_t & functionId);
+ const bool getOutTypes(AnalysisVisitor & visitor, MacroDef * macrodef, std::vector<TIType> & in, std::vector<TIType> & out, uint64_t & functionId);
- friend std::wostream & operator<<(std::wostream & out, const PolymorphicMacroCache & pmc);
+ friend std::wostream & operator<<(std::wostream & out, const PolymorphicMacroCache & pmc);
- private:
+private:
- GVN::Value * getValue(const GVN::Value * value, AnalysisVisitor & visitor, const std::vector<const MultivariatePolynomial *> & polys, const int maxVarId) const;
+ GVN::Value * getValue(const GVN::Value * value, AnalysisVisitor & visitor, const std::vector<const MultivariatePolynomial *> & polys, const int maxVarId) const;
- static bool getCompleteIn(MacroDef & macrodef, AnalysisVisitor & visitor, const std::vector<TIType> & in, std::vector<TIType> & completeIn);
+ static bool getCompleteIn(MacroDef & macrodef, AnalysisVisitor & visitor, const std::vector<TIType> & in, std::vector<TIType> & completeIn);
- };
+};
} // namespace analysis
namespace analysis
{
- struct TITypeTuple
- {
- std::vector<TIType> types;
+struct TITypeTuple
+{
+ std::vector<TIType> types;
- TITypeTuple() { }
+ TITypeTuple() { }
- TITypeTuple(const std::vector<TIType> & _types) : types(_types)
- {
- /*types.reserve(_types.size());
- for (const auto & type : _types)
- {
- types.emplace_back(type.type, type.isscalar());
- }*/
- }
+ TITypeTuple(const std::vector<TIType> & _types) : types(_types)
+ {
+ /*types.reserve(_types.size());
+ for (const auto & type : _types)
+ {
+ types.emplace_back(type.type, type.isscalar());
+ }*/
+ }
- inline std::size_t size() const
- {
- return types.size();
- }
+ inline std::size_t size() const
+ {
+ return types.size();
+ }
- inline std::size_t hash() const
+ inline std::size_t hash() const
+ {
+ if (types.empty())
+ {
+ return 0;
+ }
+ else
+ {
+ std::size_t seed = types.front().hashPureType();
+ for (std::vector<TIType>::const_iterator i = ++types.begin(), e = types.end(); i != e; ++i)
{
- if (types.empty())
- {
- return 0;
- }
- else
- {
- std::size_t seed = types.front().hashPureType();
- for (std::vector<TIType>::const_iterator i = ++types.begin(), e = types.end(); i != e; ++i)
- {
- seed = tools::hash_combine(seed, i->hashPureType());
- }
- return seed;
- }
+ seed = tools::hash_combine(seed, i->hashPureType());
}
+ return seed;
+ }
+ }
- inline bool operator==(const TITypeTuple & R) const
+ inline bool operator==(const TITypeTuple & R) const
+ {
+ if (types.size() == R.types.size())
+ {
+ for (std::vector<TIType>::const_iterator i = types.begin(), j = R.types.begin(), e = types.end(); i != e; ++i, ++j)
{
- if (types.size() == R.types.size())
+ if (i->type != j->type || i->isscalar() != j->isscalar())
{
- for (std::vector<TIType>::const_iterator i = types.begin(), j = R.types.begin(), e = types.end(); i != e; ++i, ++j)
- {
- if (i->type != j->type || i->isscalar() != j->isscalar())
- {
- return false;
- }
- }
- return true;
+ return false;
}
-
- return false;
}
+ return true;
+ }
+
+ return false;
+ }
- friend std::wostream & operator<<(std::wostream & out, const TITypeTuple & tuple)
+ friend std::wostream & operator<<(std::wostream & out, const TITypeTuple & tuple)
+ {
+ if (tuple.types.empty())
+ {
+ out << L"[]";
+ }
+ else
+ {
+ out << L"[";
+ for (std::vector<TIType>::const_iterator i = tuple.types.begin(), e = std::prev(tuple.types.end()); i != e; ++i)
{
- if (tuple.types.empty())
- {
- out << L"[]";
- }
- else
- {
- out << L"[";
- for (std::vector<TIType>::const_iterator i = tuple.types.begin(), e = std::prev(tuple.types.end()); i != e; ++i)
- {
- out << *i << L", ";
- }
- out << tuple.types.back() << L"]";
- }
- return out;
+ out << *i << L", ";
}
+ out << tuple.types.back() << L"]";
+ }
+ return out;
+ }
- struct Hash
+ struct Hash
+ {
+ inline std::size_t operator()(const TITypeTuple & tuple) const
{
- inline std::size_t operator()(const TITypeTuple & tuple) const
- {
- return tuple.hash();
- }
- };
+ return tuple.hash();
+ }
+ };
- struct Eq
+ struct Eq
+ {
+ inline bool operator()(const TITypeTuple & L, const TITypeTuple & R) const
{
- inline bool operator()(const TITypeTuple & L, const TITypeTuple & R) const
- {
- return L == R;
- }
- };
+ return L == R;
+ }
};
+};
} // namespace analysis
namespace analysis
{
- class EXTERN_AST TemporaryManager
- {
+class EXTERN_AST TemporaryManager
+{
- int currentId;
- std::map<TypeLocal, std::stack<int>> availableTmp;
- std::unordered_map<int, TypeLocal> usedTmp;
+ int currentId;
+ std::map<TypeLocal, std::stack<int>> availableTmp;
+ std::unordered_map<int, TypeLocal> usedTmp;
- public:
+public:
- TemporaryManager() : currentId(0) { }
+ TemporaryManager() : currentId(0) { }
- int getTmp(const TIType & type, const bool isAnInt = false);
- void releaseTmp(const int id);
- const std::map<TypeLocal, std::stack<int>> & getTemp() const;
- };
+ int getTmp(const TIType & type, const bool isAnInt = false);
+ void releaseTmp(const int id);
+ const std::map<TypeLocal, std::stack<int>> & getTemp() const;
+};
} // namespace analysis
namespace analysis
{
- struct TypeLocal
+struct TypeLocal
+{
+ TIType::Type type;
+ int rows;
+ int cols;
+ bool isAnInt;
+
+ TypeLocal(const TIType::Type _type, const int _rows, const int _cols, const bool _isAnInt) : type(_type), rows(_rows), cols(_cols), isAnInt(_isAnInt) { }
+
+ TypeLocal(const TypeLocal & tl) : type(tl.type), rows(tl.rows), cols(tl.cols), isAnInt(tl.isAnInt) { }
+
+ inline bool operator<(const TypeLocal & R) const
+ {
+ return type < R.type || (type == R.type && (rows < R.rows || (rows == R.rows && (cols < R.cols || (cols == R.cols && (int)isAnInt < (int)R.isAnInt)))));
+ }
+
+ inline bool operator==(const TypeLocal & R) const
+ {
+ return type == R.type && rows == R.rows && cols == R.cols && isAnInt == R.isAnInt;
+ }
+
+ inline bool isScalar() const
+ {
+ return rows == 1 && cols == 1;
+ }
+
+ inline bool isKnown() const
+ {
+ return rows != -1;
+ }
+
+ inline int totalSize() const
+ {
+ return isKnown() ? (rows * cols) : -1;
+ }
+
+ inline static TypeLocal get(const TIType & type, const bool isAnInt = false)
+ {
+ if (type.isConstantDims())
+ {
+ return TypeLocal(type.type, type.rows.getConstant(), type.cols.getConstant(), isAnInt);
+ }
+ else
+ {
+ return TypeLocal(type.type, -1, -1, false);
+ }
+ }
+
+ friend std::wostream & operator<<(std::wostream & out, const TypeLocal & tl)
{
- TIType::Type type;
- int rows;
- int cols;
- bool isAnInt;
-
- TypeLocal(const TIType::Type _type, const int _rows, const int _cols, const bool _isAnInt) : type(_type), rows(_rows), cols(_cols), isAnInt(_isAnInt) { }
-
- TypeLocal(const TypeLocal & tl) : type(tl.type), rows(tl.rows), cols(tl.cols), isAnInt(tl.isAnInt) { }
-
- inline bool operator<(const TypeLocal & R) const
- {
- return type < R.type || (type == R.type && (rows < R.rows || (rows == R.rows && (cols < R.cols || (cols == R.cols && (int)isAnInt < (int)R.isAnInt)))));
- }
-
- inline bool operator==(const TypeLocal & R) const
- {
- return type == R.type && rows == R.rows && cols == R.cols && isAnInt == R.isAnInt;
- }
-
- inline bool isScalar() const
- {
- return rows == 1 && cols == 1;
- }
-
- inline bool isKnown() const
- {
- return rows != -1;
- }
-
- inline int totalSize() const
- {
- return isKnown() ? (rows * cols) : -1;
- }
-
- inline static TypeLocal get(const TIType & type, const bool isAnInt = false)
- {
- if (type.isConstantDims())
- {
- return TypeLocal(type.type, type.rows.getConstant(), type.cols.getConstant(), isAnInt);
- }
- else
- {
- return TypeLocal(type.type, -1, -1, false);
- }
- }
-
- friend std::wostream & operator<<(std::wostream & out, const TypeLocal & tl)
- {
- out << TIType::toString(tl.type);
- if (tl.isAnInt)
- {
- out << L"(int64_t)";
- }
- out << L" ";
- if (tl.rows == -1 || tl.cols == -1)
- {
- out << L"?x?";
- }
- else
- {
- out << tl.rows << L'x' << tl.cols;
- }
- return out;
- }
- };
+ out << TIType::toString(tl.type);
+ if (tl.isAnInt)
+ {
+ out << L"(int64_t)";
+ }
+ out << L" ";
+ if (tl.rows == -1 || tl.cols == -1)
+ {
+ out << L"?x?";
+ }
+ else
+ {
+ out << tl.rows << L'x' << tl.cols;
+ }
+ return out;
+ }
+};
} // namespace analysis
class XBlockHead : public Block
{
std::vector<Block *> testBlocks;
-
+
public:
XBlockHead(const unsigned int id, Block * parent, ast::Exp * exp) : Block(id, parent, exp) { }
virtual ~XBlockHead()
- {
- std::for_each(testBlocks.begin(), testBlocks.end(), [](Block * b)
- {
- delete b;
- });
- }
+ {
+ std::for_each(testBlocks.begin(), testBlocks.end(), [](Block * b)
+ {
+ delete b;
+ });
+ }
Block * addBlock(const unsigned int id, BlockKind kind, ast::Exp * exp) override;
void finalize() override;
virtual void applyConstraints(const std::vector<GVN::Value *> & values) const /*override*/;
};
- struct StrictGreaterConstraint : public InferenceConstraint
+struct StrictGreaterConstraint : public InferenceConstraint
{
virtual Result check(GVN & gvn, const std::vector<GVN::Value *> & values) const /*override*/;
virtual MPolyConstraintSet getMPConstraints(const std::vector<GVN::Value *> & values) const /*override*/;
}
inline bool isConstant() const
- {
- return poly.isConstant();
- }
+ {
+ return poly.isConstant();
+ }
virtual Result check(GVN & gvn, const std::vector<GVN::Value *> & values) const override;
virtual MPolyConstraintSet getMPConstraints(const std::vector<GVN::Value *> & values) const override;
};
inline bool operator==(const MPolyConstraint & R) const
- {
- return kind == R.kind && poly == R.poly;
- }
-
+ {
+ return kind == R.kind && poly == R.poly;
+ }
+
struct Eq
{
inline bool operator()(const MPolyConstraint & L, const MPolyConstraint & R) const
inline void add(MPolyConstraint && mpc)
{
- if (!mpc.isConstant())
- {
- constraints.emplace(std::move(mpc));
- }
+ if (!mpc.isConstant())
+ {
+ constraints.emplace(std::move(mpc));
+ }
}
inline void add(MultivariatePolynomial && poly, MPolyConstraint::Kind kind)
{
- if (!poly.isConstant())
- {
- constraints.emplace(std::move(poly), kind);
- }
+ if (!poly.isConstant())
+ {
+ constraints.emplace(std::move(poly), kind);
+ }
}
inline void add(const MultivariatePolynomial & poly, MPolyConstraint::Kind kind)
{
- if (!poly.isConstant())
- {
- constraints.emplace(poly, kind);
- }
+ if (!poly.isConstant())
+ {
+ constraints.emplace(poly, kind);
+ }
}
inline void add(const MPolyConstraintSet & set)
}
inline bool empty() const
- {
- return constraints.empty();
- }
+ {
+ return constraints.empty();
+ }
inline std::size_t size() const
- {
- return constraints.size();
- }
+ {
+ return constraints.size();
+ }
virtual Result check(GVN & gvn, const std::vector<GVN::Value *> & values) const override;
virtual MPolyConstraintSet getMPConstraints(const std::vector<GVN::Value *> & values) const override;
struct Hash
{
- inline std::size_t operator()(const MPolyConstraintSet & mpcs) const
- {
- std::size_t seed = 0;
- for (const auto & c : mpcs.constraints)
- {
- seed = tools::hash_combine(seed, MPolyConstraint::Hash()(c));
- }
- return seed;
- }
+ inline std::size_t operator()(const MPolyConstraintSet & mpcs) const
+ {
+ std::size_t seed = 0;
+ for (const auto & c : mpcs.constraints)
+ {
+ seed = tools::hash_combine(seed, MPolyConstraint::Hash()(c));
+ }
+ return seed;
+ }
};
struct Eq
* \param _end the ending value
*/
SymbolicRange(GVN * _gvn, GVN::Value * _start, GVN::Value * _end) : gvn(_gvn), start(_start), end(_end) { }
-
+
/**
* \brief constructor
* \param _gvn the GVN to use
SymbolicRange(GVN & _gvn, int64_t _start, int64_t _end) : SymbolicRange(&_gvn, _gvn.getValue(_start), _gvn.getValue(_end)) { }
inline void set(GVN & _gvn, GVN::Value * _start, GVN::Value * _end)
- {
- gvn = &_gvn;
- start = _start;
- end = _end;
- }
+ {
+ gvn = &_gvn;
+ start = _start;
+ end = _end;
+ }
inline GVN::Value * getStart() const
- {
- return start;
- }
+ {
+ return start;
+ }
inline GVN::Value * getEnd() const
- {
- return end;
- }
-
+ {
+ return end;
+ }
+
/**
* \brief Get the associated GVN
* \return the GVN
namespace analysis
{
- namespace logging
- {
-
- class Logger
- {
- std::shared_ptr<std::wostream> out;
-
- public:
-
- //Logger(std::wostream & _out) : out(new std::wostream(&_out)) { }
- Logger(const std::string & file) : out(new std::wofstream(file, std::ofstream::out | std::ofstream::trunc)) { }
-
- template<typename T>
- inline void log(const T & x)
- {
- //*out << x << std::endl;
- }
-
- template<typename T>
- inline void log(const unsigned int line, const char * file, const T & x)
- {
- //*out << file << L"@" << line << L": " << x << std::endl;
- }
-
- template<typename T, typename... Args>
- inline void log(const T & x, Args... args)
- {
- //*out << x << L" ";
- log(args...);
- }
- };
-
- } // namespace logging
+namespace logging
+{
+
+class Logger
+{
+ std::shared_ptr<std::wostream> out;
+
+public:
+
+ //Logger(std::wostream & _out) : out(new std::wostream(&_out)) { }
+ Logger(const std::string & file) : out(new std::wofstream(file, std::ofstream::out | std::ofstream::trunc)) { }
+
+ template<typename T>
+ inline void log(const T & x)
+ {
+ //*out << x << std::endl;
+ }
+
+ template<typename T>
+ inline void log(const unsigned int line, const char * file, const T & x)
+ {
+ //*out << file << L"@" << line << L": " << x << std::endl;
+ }
+
+ template<typename T, typename... Args>
+ inline void log(const T & x, Args... args)
+ {
+ //*out << x << L" ";
+ log(args...);
+ }
+};
+
+} // namespace logging
} // namespace analysis
}
void visit(ast::DoubleExp & e)
- {
- setResult(e.value_get() >= 0);
- }
+ {
+ setResult(e.value_get() >= 0);
+ }
void visit(ast::DoubleExp & e)
{
}
void visit(ast::OptimizedExp & e)
- {
- }
-
+ {
+ }
+
void visit(ast::MemfillExp & e)
- {
- }
-
+ {
+ }
+
void visit(ast::DAXPYExp & e)
- {
- }
+ {
+ }
};
} // namespace analysis
~Breakpoint()
{
- if(_conditionExp)
+ if (_conditionExp)
{
delete _conditionExp;
}
{
return new DummyVisitor();
}
-
+
virtual void visit(const MatrixExp &e)
{
exps_t lines = e.getLines();
{
return new ExecVisitor();
}
-
+
void visit(const SeqExp &e)
{
visitprivate(e);
(*o)->IncreaseRef();
}
}
-
+
for (types::optional_list::const_iterator o = opt.begin(); o != opt.end(); ++o)
{
if (o->second)
{
public:
TreeVisitor() : l(nullptr), eol(nullptr) {}
- ~TreeVisitor()
+ ~TreeVisitor()
{
eol->killMe();
l->killMe();
/** \name Accessors.
** \{ */
public:
-
+
inline const exps_t& getVars() const
{
return _exps;
inline exps_t getArgs() const
{
- return exps_t(std::next(_exps.begin()), _exps.end());
+ return exps_t(std::next(_exps.begin()), _exps.end());
}
inline exps_t getArgs()
{
- return exps_t(std::next(_exps.begin()), _exps.end());
+ return exps_t(std::next(_exps.begin()), _exps.end());
}
Location getFirstLocation() const
{
return true;
}
-
+
inline DoubleExp* neg()
{
_value = -_value;
: Dec (location),
_name (name),
_stack(nullptr),
- macro(nullptr)
+ macro(nullptr)
{
args.setParent(this);
returns.setParent(this);
//body will be deleted by types::Macro
//so replace by NULL to avoir delete in ~Exp()
//_exps[2] = NULL;
- if (macro)
+ if (macro)
{
macro->DecreaseRef();
macro->killMe();
macro->IncreaseRef();
}
}
-
+
protected:
symbol::Symbol _name;
symbol::Variable * _stack;
values[0] = std::numeric_limits<double>::quiet_NaN();
values[1] = std::numeric_limits<double>::quiet_NaN();
values[2] = std::numeric_limits<double>::quiet_NaN();
- values[3] = std::numeric_limits<double>::quiet_NaN();
+ values[3] = std::numeric_limits<double>::quiet_NaN();
is_values_int[0] = false;
is_values_int[1] = false;
namespace ast
{
- /**
- * \class MemfillExp
- * \brief represent an exp like zeros or ones or anything else...
- *
- * The expression %pi+zeros(...) is equivalent to fill the matrix with %pi and obviously
- * it is fastest to fill with %pi rather than to fill with zero and then add %pi.
- * This expression comes from an analysis of such expressions.
- *
- */
- class MemfillExp : public OptimizedExp
+/**
+ * \class MemfillExp
+ * \brief represent an exp like zeros or ones or anything else...
+ *
+ * The expression %pi+zeros(...) is equivalent to fill the matrix with %pi and obviously
+ * it is fastest to fill with %pi rather than to fill with zero and then add %pi.
+ * This expression comes from an analysis of such expressions.
+ *
+ */
+class MemfillExp : public OptimizedExp
+{
+
+public:
+
+ MemfillExp(const Location & location, Exp & value, const exps_t & args) : OptimizedExp(location)
{
+ _exps.push_back(&value);
+ value.setParent(this);
+ for (auto arg : args)
+ {
+ _exps.push_back(arg);
+ arg->setParent(this);
+ }
+ }
- public:
-
- MemfillExp(const Location & location, Exp & value, const exps_t & args) : OptimizedExp(location)
- {
- _exps.push_back(&value);
- value.setParent(this);
- for (auto arg : args)
- {
- _exps.push_back(arg);
- arg->setParent(this);
- }
- }
-
- virtual ~MemfillExp()
- {
- }
-
- virtual MemfillExp * clone() override
- {
- exps_t args;
- args.reserve(_exps.size() - 1);
- for (exps_t::iterator i = std::next(_exps.begin()), end = _exps.end(); i != end; ++i)
- {
- args.emplace_back((*i)->clone());
- }
- return new MemfillExp(getLocation(), *getValue().clone(), args);
- }
-
- virtual void accept(Visitor& v) override
- {
- v.visit(*this);
- }
-
- virtual void accept(ConstVisitor& v) const override
- {
- v.visit(*this);
- }
-
- const Exp & getValue() const
- {
- return *_exps[0];
- }
-
- Exp & getValue()
- {
- return *_exps[0];
- }
-
- exps_t getArgs() const
- {
- return exps_t(std::next(_exps.begin()), _exps.end());
- }
-
- exps_t getArgs()
- {
- return exps_t(std::next(_exps.begin()), _exps.end());
- }
-
- inline bool isMemfillExp() const
- {
- return true;
- }
-
- virtual ExpType getType() const
- {
- return MEMFILLEXP;
- }
- };
+ virtual ~MemfillExp()
+ {
+ }
+
+ virtual MemfillExp * clone() override
+ {
+ exps_t args;
+ args.reserve(_exps.size() - 1);
+ for (exps_t::iterator i = std::next(_exps.begin()), end = _exps.end(); i != end; ++i)
+ {
+ args.emplace_back((*i)->clone());
+ }
+ return new MemfillExp(getLocation(), *getValue().clone(), args);
+ }
+
+ virtual void accept(Visitor& v) override
+ {
+ v.visit(*this);
+ }
+
+ virtual void accept(ConstVisitor& v) const override
+ {
+ v.visit(*this);
+ }
+
+ const Exp & getValue() const
+ {
+ return *_exps[0];
+ }
+
+ Exp & getValue()
+ {
+ return *_exps[0];
+ }
+
+ exps_t getArgs() const
+ {
+ return exps_t(std::next(_exps.begin()), _exps.end());
+ }
+
+ exps_t getArgs()
+ {
+ return exps_t(std::next(_exps.begin()), _exps.end());
+ }
+
+ inline bool isMemfillExp() const
+ {
+ return true;
+ }
+
+ virtual ExpType getType() const
+ {
+ return MEMFILLEXP;
+ }
+};
} // namespace ast
** \param body EXP LIST intruction
*/
SeqExp (const Location& location,
- exps_t& body)
+ exps_t& body)
: Exp(location), execfrom(SCRIPT)
{
for (auto it : body)
inline ScilabId getId(void)
{
return isIdentity() ? isComplex() ? IdIdentityComplex : IdIdentity
- : isEmpty() ? IdEmpty
+ : isEmpty() ? IdEmpty
: isComplex() ? isScalar() ? IdScalarDoubleComplex
: IdDoubleComplex
- : isScalar() ? IdScalarDouble
+ : isScalar() ? IdScalarDouble
: IdDouble;
}
{
return isScalar() ? isComplex() ? IdScalarPolynomComplex
: IdScalarPolynom
- : isComplex() ? IdPolynomComplex
+ : isComplex() ? IdPolynomComplex
: IdPolynom;
}
const symbol::Symbol & sym = static_cast<ast::SimpleVar &>(e.getName()).getSymbol();
const std::wstring & name = sym.getName();
std::vector<TIType> vargs({ Rtype });
- uint64_t functionId = 0;
+ uint64_t functionId = 0;
std::vector<TIType> out = visitor.getDM().call(visitor, lhs, sym, vargs, &e, functionId);
if (Rtype.isintegral())
{
namespace analysis
{
- ConstantValue::ConstantValue(types::InternalType * _val) : val(_val), kind(ITVAL)
+ConstantValue::ConstantValue(types::InternalType * _val) : val(_val), kind(ITVAL)
+{
+ _val->IncreaseRef();
+}
+
+ConstantValue::ConstantValue(const ConstantValue & cv) : val(cv.val), kind(cv.kind)
+{
+ if (kind == ITVAL)
{
- _val->IncreaseRef();
+ val.pIT->IncreaseRef();
}
+}
- ConstantValue::ConstantValue(const ConstantValue & cv) : val(cv.val), kind(cv.kind)
+ConstantValue::~ConstantValue()
+{
+ if (kind == ITVAL)
{
- if (kind == ITVAL)
- {
- val.pIT->IncreaseRef();
- }
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
}
+}
- ConstantValue::~ConstantValue()
+ConstantValue & ConstantValue::operator=(const ConstantValue & R)
+{
+ if (kind == ITVAL)
{
- if (kind == ITVAL)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- }
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
+ }
+ val = R.val;
+ kind = R.kind;
+ if (kind == ITVAL)
+ {
+ val.pIT->IncreaseRef();
}
- ConstantValue & ConstantValue::operator=(const ConstantValue & R)
- {
- if (kind == ITVAL)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- }
- val = R.val;
- kind = R.kind;
- if (kind == ITVAL)
- {
- val.pIT->IncreaseRef();
- }
+ return *this;
+}
- return *this;
+ConstantValue & ConstantValue::operator=(types::InternalType * const pIT)
+{
+ if (kind == ITVAL)
+ {
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
}
+ val = pIT;
+ kind = ITVAL;
+ pIT->IncreaseRef();
- ConstantValue & ConstantValue::operator=(types::InternalType * const pIT)
- {
- if (kind == ITVAL)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- }
- val = pIT;
- kind = ITVAL;
- pIT->IncreaseRef();
+ return *this;
+}
- return *this;
+ConstantValue & ConstantValue::operator=(GVN::Value * const _val)
+{
+ if (kind == ITVAL)
+ {
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
}
+ val = _val;
+ kind = GVNVAL;
- ConstantValue & ConstantValue::operator=(GVN::Value * const _val)
+ return *this;
+}
+
+ConstantValue & ConstantValue::operator=(ConstantValue && R)
+{
+ if (kind == ITVAL)
{
- if (kind == ITVAL)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- }
- val = _val;
- kind = GVNVAL;
-
- return *this;
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
}
-
- ConstantValue & ConstantValue::operator=(ConstantValue && R)
+ val = R.val;
+ kind = R.kind;
+ R.kind = UNKNOWN;
+
+ return *this;
+}
+
+types::InternalType * ConstantValue::getIT() const
+{
+ if (kind == ITVAL)
{
- if (kind == ITVAL)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- }
- val = R.val;
- kind = R.kind;
- R.kind = UNKNOWN;
-
- return *this;
+ return val.pIT;
}
- types::InternalType * ConstantValue::getIT() const
+ return nullptr;
+}
+
+GVN::Value * ConstantValue::getGVNValue() const
+{
+ if (kind == GVNVAL)
{
- if (kind == ITVAL)
- {
- return val.pIT;
- }
-
- return nullptr;
+ return val.gvnVal;
}
-
- GVN::Value * ConstantValue::getGVNValue() const
- {
- if (kind == GVNVAL)
- {
- return val.gvnVal;
- }
- return nullptr;
- }
+ return nullptr;
+}
- void ConstantValue::merge(const ConstantValue & cv)
+void ConstantValue::merge(const ConstantValue & cv)
+{
+ if (kind != UNKNOWN && cv.kind != UNKNOWN)
{
- if (kind != UNKNOWN && cv.kind != UNKNOWN)
+ if (kind == cv.kind)
{
- if (kind == cv.kind)
+ switch (kind)
{
- switch (kind)
- {
case GVNVAL:
- if (val.gvnVal != cv.val.gvnVal)
- {
- kind = UNKNOWN;
- }
- break;
+ if (val.gvnVal != cv.val.gvnVal)
+ {
+ kind = UNKNOWN;
+ }
+ break;
case ITVAL:
- if (val.pIT != cv.val.pIT && *val.pIT != *cv.val.pIT)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- kind = UNKNOWN;
- }
+ if (val.pIT != cv.val.pIT && *val.pIT != *cv.val.pIT)
+ {
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
+ kind = UNKNOWN;
+ }
break;
default:
break;
- }
}
- else if (kind == GVNVAL)
+ }
+ else if (kind == GVNVAL)
+ {
+ // cv.kind == ITVAL
+ double x;
+ if (cv.getDblValue(x) && val.gvnVal->poly->isConstant(x))
{
- // cv.kind == ITVAL
- double x;
- if (cv.getDblValue(x) && val.gvnVal->poly->isConstant(x))
- {
- kind = ITVAL;
- val.pIT = cv.val.pIT;
- val.pIT->IncreaseRef();
- }
- else
- {
- kind = UNKNOWN;
- }
+ kind = ITVAL;
+ val.pIT = cv.val.pIT;
+ val.pIT->IncreaseRef();
}
else
{
- // kind == ITVAL
- double x;
- if (!getDblValue(x) || !cv.val.gvnVal->poly->isConstant(x))
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- kind = UNKNOWN;
- }
+ kind = UNKNOWN;
}
}
else
{
- if (kind == ITVAL)
- {
- val.pIT->DecreaseRef();
- val.pIT->killMe();
- }
- kind = UNKNOWN;
+ // kind == ITVAL
+ double x;
+ if (!getDblValue(x) || !cv.val.gvnVal->poly->isConstant(x))
+ {
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
+ kind = UNKNOWN;
+ }
}
}
-
- bool ConstantValue::getGVNValue(GVN & gvn, GVN::Value *& _val) const
+ else
{
- if (kind == GVNVAL)
+ if (kind == ITVAL)
{
- _val = val.gvnVal;
- return true;
+ val.pIT->DecreaseRef();
+ val.pIT->killMe();
}
- else if (kind == ITVAL)
+ kind = UNKNOWN;
+ }
+}
+
+bool ConstantValue::getGVNValue(GVN & gvn, GVN::Value *& _val) const
+{
+ if (kind == GVNVAL)
+ {
+ _val = val.gvnVal;
+ return true;
+ }
+ else if (kind == ITVAL)
+ {
+ if (val.pIT->isDouble() && static_cast<types::Double *>(val.pIT)->getSize() == 1)
{
- if (val.pIT->isDouble() && static_cast<types::Double *>(val.pIT)->getSize() == 1)
+ types::Double * pDbl = static_cast<types::Double *>(val.pIT);
+ if (!pDbl->isComplex() || pDbl->getImg(0) == 0)
{
- types::Double * pDbl = static_cast<types::Double *>(val.pIT);
- if (!pDbl->isComplex() || pDbl->getImg(0) == 0)
- {
- const double x = pDbl->get()[0];
- int64_t i;
- if (tools::asInteger(x, i))
- {
- _val = gvn.getValue(i);
- return true;
- }
+ const double x = pDbl->get()[0];
+ int64_t i;
+ if (tools::asInteger(x, i))
+ {
+ _val = gvn.getValue(i);
+ return true;
}
}
}
-
- return false;
}
- bool ConstantValue::getDblValue(double & _val) const
+ return false;
+}
+
+bool ConstantValue::getDblValue(double & _val) const
+{
+ if (kind == ITVAL)
{
- if (kind == ITVAL)
+ if (val.pIT->isDouble() && static_cast<types::Double *>(val.pIT)->getSize() == 1)
{
- if (val.pIT->isDouble() && static_cast<types::Double *>(val.pIT)->getSize() == 1)
+ types::Double * pDbl = static_cast<types::Double *>(val.pIT);
+ if (!pDbl->isComplex() || pDbl->getImg(0) == 0)
{
- types::Double * pDbl = static_cast<types::Double *>(val.pIT);
- if (!pDbl->isComplex() || pDbl->getImg(0) == 0)
- {
- _val = pDbl->get()[0];
- return true;
- }
+ _val = pDbl->get()[0];
+ return true;
}
}
- else if (kind == GVNVAL)
+ }
+ else if (kind == GVNVAL)
+ {
+ if (GVN::Value * gvnValue = val.gvnVal)
{
- if (GVN::Value * gvnValue = val.gvnVal)
+ if (gvnValue->poly->isConstant())
{
- if (gvnValue->poly->isConstant())
- {
- _val = (double)gvnValue->poly->constant;
- return true;
- }
+ _val = (double)gvnValue->poly->constant;
+ return true;
}
}
- return false;
}
+ return false;
+}
- bool ConstantValue::getBoolValue(bool & _val) const
+bool ConstantValue::getBoolValue(bool & _val) const
+{
+ if (kind == ITVAL)
{
- if (kind == ITVAL)
+ if (val.pIT->isBool() && static_cast<types::Bool *>(val.pIT)->getSize() == 1)
{
- if (val.pIT->isBool() && static_cast<types::Bool *>(val.pIT)->getSize() == 1)
- {
- _val = (bool)static_cast<types::Bool *>(val.pIT)->get(0);
- }
- else
- {
- _val = val.pIT->isTrue();
- }
- return true;
+ _val = (bool)static_cast<types::Bool *>(val.pIT)->get(0);
}
- else if (kind == GVNVAL)
+ else
{
- if (GVN::Value * gvnValue = val.gvnVal)
- {
- if (gvnValue->poly->isConstant())
- {
- _val = gvnValue->poly->constant != 0;
- return true;
- }
- }
+ _val = val.pIT->isTrue();
}
- return false;
+ return true;
}
-
- bool ConstantValue::getCplxValue(std::complex<double> & _val) const
+ else if (kind == GVNVAL)
{
- if (kind == ITVAL)
+ if (GVN::Value * gvnValue = val.gvnVal)
{
- if (val.pIT->isDouble() && static_cast<types::Double *>(val.pIT)->getSize() == 1)
+ if (gvnValue->poly->isConstant())
{
- types::Double * pDbl = static_cast<types::Double *>(val.pIT);
- if (pDbl->isComplex())
- {
- _val.real(pDbl->get(0));
- _val.imag(pDbl->getImg(0));
- }
- else
- {
- _val.real(pDbl->get(0));
- _val.imag(0);
- }
+ _val = gvnValue->poly->constant != 0;
return true;
}
}
- else if (kind == GVNVAL)
+ }
+ return false;
+}
+
+bool ConstantValue::getCplxValue(std::complex<double> & _val) const
+{
+ if (kind == ITVAL)
+ {
+ if (val.pIT->isDouble() && static_cast<types::Double *>(val.pIT)->getSize() == 1)
{
- if (GVN::Value * gvnValue = val.gvnVal)
+ types::Double * pDbl = static_cast<types::Double *>(val.pIT);
+ if (pDbl->isComplex())
{
- if (gvnValue->poly->isConstant())
- {
- _val.real((double)gvnValue->poly->constant);
- _val.imag(0.);
- return true;
- }
+ _val.real(pDbl->get(0));
+ _val.imag(pDbl->getImg(0));
}
+ else
+ {
+ _val.real(pDbl->get(0));
+ _val.imag(0);
+ }
+ return true;
}
- return false;
}
-
- bool ConstantValue::getStrValue(std::wstring & _val) const
+ else if (kind == GVNVAL)
{
- if (kind == ITVAL)
+ if (GVN::Value * gvnValue = val.gvnVal)
{
- if (val.pIT->isString() && static_cast<types::String *>(val.pIT)->getSize() == 1)
+ if (gvnValue->poly->isConstant())
{
- _val = std::wstring(static_cast<types::String *>(val.pIT)->get(0));
+ _val.real((double)gvnValue->poly->constant);
+ _val.imag(0.);
return true;
}
}
+ }
+ return false;
+}
- return false;
+bool ConstantValue::getStrValue(std::wstring & _val) const
+{
+ if (kind == ITVAL)
+ {
+ if (val.pIT->isString() && static_cast<types::String *>(val.pIT)->getSize() == 1)
+ {
+ _val = std::wstring(static_cast<types::String *>(val.pIT)->get(0));
+ return true;
+ }
}
+ return false;
+}
+
- std::wostream & operator<<(std::wostream & out, const ConstantValue & cv)
+std::wostream & operator<<(std::wostream & out, const ConstantValue & cv)
+{
+ switch (cv.kind)
{
- switch (cv.kind)
- {
case ConstantValue::GVNVAL:
out << *cv.val.gvnVal;
break;
case ConstantValue::ITVAL:
- {
- if (cv.val.pIT->isDouble() && static_cast<types::Double *>(cv.val.pIT)->getSize() == 1)
- {
- out << static_cast<types::Double *>(cv.val.pIT)->get(0, 0);
- }
- else
- {
- out << L"\"" << cv.val.pIT->getTypeStr() << L"\"";
- }
+ {
+ if (cv.val.pIT->isDouble() && static_cast<types::Double *>(cv.val.pIT)->getSize() == 1)
+ {
+ out << static_cast<types::Double *>(cv.val.pIT)->get(0, 0);
+ }
+ else
+ {
+ out << L"\"" << cv.val.pIT->getTypeStr() << L"\"";
+ }
break;
- }
+ }
default:
break;
- }
-
- return out;
}
+
+ return out;
+}
}
namespace analysis
{
- bool FindAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool FindAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs > 2)
{
- if (lhs > 2)
- {
- return false;
- }
+ return false;
+ }
- const ast::exps_t args = e.getArgs();
- if (args.size() != 1 && args.size() != 2)
- {
- return false;
- }
-
- ast::Exp * first = args[0];
- first->accept(visitor);
- Result & res = visitor.getResult();
- TIType & ty = res.getType();
- if (ty.ismatrix())
- {
- TIType type(visitor.getGVN(), TIType::DOUBLE, false);
- Result & _res = e.getDecorator().setResult(type);
- if (lhs == 1)
- {
- _res.setMaxIndex(ty.rows * ty.cols);
- visitor.setResult(_res);
+ const ast::exps_t args = e.getArgs();
+ if (args.size() != 1 && args.size() != 2)
+ {
+ return false;
+ }
- return true;
- }
- else if (lhs == 2)
- {
- std::vector<Result> & mlhs = visitor.getLHSContainer();
- mlhs.clear();
- mlhs.reserve(2);
- mlhs.emplace_back(type);
- mlhs.back().setMaxIndex(ty.rows);
- mlhs.emplace_back(type);
- mlhs.back().setMaxIndex(ty.cols);
+ ast::Exp * first = args[0];
+ first->accept(visitor);
+ Result & res = visitor.getResult();
+ TIType & ty = res.getType();
+ if (ty.ismatrix())
+ {
+ TIType type(visitor.getGVN(), TIType::DOUBLE, false);
+ Result & _res = e.getDecorator().setResult(type);
+ if (lhs == 1)
+ {
+ _res.setMaxIndex(ty.rows * ty.cols);
+ visitor.setResult(_res);
- return true;
- }
- }
+ return true;
+ }
+ else if (lhs == 2)
+ {
+ std::vector<Result> & mlhs = visitor.getLHSContainer();
+ mlhs.clear();
+ mlhs.reserve(2);
+ mlhs.emplace_back(type);
+ mlhs.back().setMaxIndex(ty.rows);
+ mlhs.emplace_back(type);
+ mlhs.back().setMaxIndex(ty.cols);
- return false;
+ return true;
+ }
}
+
+ return false;
+}
}
namespace analysis
{
- void GVN::clear()
+void GVN::clear()
+{
+ mapv.clear();
+ mapi64.clear();
+ maps.clear();
+ mapp.clear();
+ list.clear();
+ current = 0;
+}
+
+uint64_t GVN::getCurrentValue() const
+{
+ return current;
+}
+
+void GVN::insertValue(const MultivariatePolynomial & mp, Value & value)
+{
+ MapPolys::iterator i = mapp.find(mp);
+ if (i == mapp.end())
{
- mapv.clear();
- mapi64.clear();
- maps.clear();
- mapp.clear();
- list.clear();
- current = 0;
+ value.poly = &mapp.emplace(mp, &value).first->first;
}
-
- uint64_t GVN::getCurrentValue() const
+ else
{
- return current;
+ value.value = i->second->value;
+ value.poly = &i->first;
}
+}
- void GVN::insertValue(const MultivariatePolynomial & mp, Value & value)
+void GVN::setValue(const symbol::Symbol & sym, const MultivariatePolynomial & mp)
+{
+ MapPolys::iterator i = mapp.find(mp);
+ if (i != mapp.end())
{
- MapPolys::iterator i = mapp.find(mp);
- if (i == mapp.end())
- {
- value.poly = &mapp.emplace(mp, &value).first->first;
- }
- else
- {
- value.value = i->second->value;
- value.poly = &i->first;
- }
+ maps.emplace(sym, i->second->value)->second.poly = i->second->poly;
}
-
- void GVN::setValue(const symbol::Symbol & sym, const MultivariatePolynomial & mp)
+ else
{
- MapPolys::iterator i = mapp.find(mp);
- if (i != mapp.end())
- {
- maps.emplace(sym, i->second->value)->second.poly = i->second->poly;
- }
- else
+ Value & value = maps.emplace(sym, current++)->second;
+ insertValue(mp, value);
+ if (mp.isConstant() && mapi64.find(mp.constant) == mapi64.end())
{
- Value & value = maps.emplace(sym, current++)->second;
- insertValue(mp, value);
- if (mp.isConstant() && mapi64.find(mp.constant) == mapi64.end())
- {
- mapi64.emplace(mp.constant, value);
- }
+ mapi64.emplace(mp.constant, value);
}
}
+}
+
+void GVN::setValue(const symbol::Symbol & sym, const Value & LV)
+{
+ maps.emplace(sym, LV.value)->second.poly = LV.poly;
+}
+
+GVN::Value * GVN::getValue()
+{
+ list.emplace_back(current);
+ Value & value = list.back();
+ insertValue(current++, value);
+
+ return &value;
+}
- void GVN::setValue(const symbol::Symbol & sym, const Value & LV)
+GVN::Value * GVN::getValue(const MultivariatePolynomial & mp)
+{
+ const auto i = mapp.find(mp);
+ if (i != mapp.end())
+ {
+ return i->second;
+ }
+ else
{
- maps.emplace(sym, LV.value)->second.poly = LV.poly;
+ list.emplace_back(current++);
+ Value & val = list.back();
+ insertValue(mp, val);
+
+ return &val;
}
+}
- GVN::Value * GVN::getValue()
+GVN::Value * GVN::getValue(const symbol::Symbol & sym)
+{
+ const auto i = maps.equal_range(sym);
+ if (i.first == i.second)
{
- list.emplace_back(current);
- Value & value = list.back();
+ GVN::Value & value = maps.emplace(sym, current)->second;
insertValue(current++, value);
return &value;
}
-
- GVN::Value * GVN::getValue(const MultivariatePolynomial & mp)
+ else
{
- const auto i = mapp.find(mp);
- if (i != mapp.end())
- {
- return i->second;
- }
- else
- {
- list.emplace_back(current++);
- Value & val = list.back();
- insertValue(mp, val);
+ return &std::prev(i.second)->second;
+ }
+}
- return &val;
- }
+GVN::Value * GVN::getExistingValue(const symbol::Symbol & sym)
+{
+ const auto i = maps.equal_range(sym);
+ if (i.first == i.second)
+ {
+ return nullptr;
+ }
+ else
+ {
+ return &std::prev(i.second)->second;
}
+}
- GVN::Value * GVN::getValue(const symbol::Symbol & sym)
+GVN::Value * GVN::getValue(const double x)
+{
+ int64_t _x;
+ if (tools::asInteger(x, _x))
{
- const auto i = maps.equal_range(sym);
- if (i.first == i.second)
+ const auto i = mapi64.find(_x);
+ if (i == mapi64.end())
{
- GVN::Value & value = maps.emplace(sym, current)->second;
- insertValue(current++, value);
+ GVN::Value & value = mapi64.emplace(_x, current++).first->second;
+ insertValue(_x, value);
return &value;
}
else
{
- return &std::prev(i.second)->second;
+ return &i->second;
}
}
- GVN::Value * GVN::getExistingValue(const symbol::Symbol & sym)
+ return nullptr;
+}
+
+GVN::Value * GVN::getValue(const OpValue::Kind kind, const GVN::Value & LV)
+{
+ OpValue ov(kind, LV.value);
+
+ switch (kind)
{
- const auto i = maps.equal_range(sym);
- if (i.first == i.second)
- {
- return nullptr;
- }
- else
- {
- return &std::prev(i.second)->second;
- }
+ case OpValue::UNARYMINUS:
+ return getValue([](const MultivariatePolynomial & mp)
+ {
+ return -mp;
+ }, LV, ov);
+ default:
+ return getValue([](const MultivariatePolynomial & mp)
+ {
+ return MultivariatePolynomial::getInvalid();
+ }, LV, ov);
}
+}
+
+GVN::Value * GVN::getValue(const OpValue::Kind kind, const GVN::Value & LV, const GVN::Value & RV)
+{
+ OpValue ov(kind, LV.value, RV.value);
- GVN::Value * GVN::getValue(const double x)
+ switch (kind)
{
- int64_t _x;
- if (tools::asInteger(x, _x))
- {
- const auto i = mapi64.find(_x);
- if (i == mapi64.end())
+ case OpValue::PLUS:
+ return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
{
- GVN::Value & value = mapi64.emplace(_x, current++).first->second;
- insertValue(_x, value);
-
- return &value;
- }
- else
+ return LMP + RMP;
+ }, LV, RV, ov);
+ case OpValue::MINUS:
+ return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
{
- return &i->second;
- }
- }
-
- return nullptr;
+ return LMP - RMP;
+ }, LV, RV, ov);
+ case OpValue::TIMES:
+ case OpValue::DOTTIMES:
+ return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
+ {
+ return LMP * RMP;
+ }, LV, RV, ov);
+ case OpValue::RDIV:
+ case OpValue::DOTRDIV:
+ return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
+ {
+ return LMP / RMP;
+ }, LV, RV, ov);
+ case OpValue::POWER:
+ case OpValue::DOTPOWER:
+ return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
+ {
+ return LMP ^ RMP;
+ }, LV, RV, ov);
+ default:
+ return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
+ {
+ return MultivariatePolynomial::getInvalid();
+ }, LV, RV, ov);
}
+}
- GVN::Value * GVN::getValue(const OpValue::Kind kind, const GVN::Value & LV)
+std::map<std::wstring, uint64_t> GVN::getSymMap() const
+{
+ std::map<std::wstring, uint64_t> map;
+ for (const auto & p : maps)
{
- OpValue ov(kind, LV.value);
-
- switch (kind)
- {
- case OpValue::UNARYMINUS:
- return getValue([](const MultivariatePolynomial & mp)
- {
- return -mp;
- }, LV, ov);
- default:
- return getValue([](const MultivariatePolynomial & mp)
- {
- return MultivariatePolynomial::getInvalid();
- }, LV, ov);
- }
+ map.emplace(p.first.getName(), p.second.value);
}
- GVN::Value * GVN::getValue(const OpValue::Kind kind, const GVN::Value & LV, const GVN::Value & RV)
- {
- OpValue ov(kind, LV.value, RV.value);
+ return map;
+}
- switch (kind)
- {
- case OpValue::PLUS:
- return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
- {
- return LMP + RMP;
- }, LV, RV, ov);
- case OpValue::MINUS:
- return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
- {
- return LMP - RMP;
- }, LV, RV, ov);
- case OpValue::TIMES:
- case OpValue::DOTTIMES:
- return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
- {
- return LMP * RMP;
- }, LV, RV, ov);
- case OpValue::RDIV:
- case OpValue::DOTRDIV:
- return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
- {
- return LMP / RMP;
- }, LV, RV, ov);
- case OpValue::POWER:
- case OpValue::DOTPOWER:
- return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
- {
- return LMP ^ RMP;
- }, LV, RV, ov);
- default:
- return getValue([](const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP)
- {
- return MultivariatePolynomial::getInvalid();
- }, LV, RV, ov);
- }
+std::wostream & operator<<(std::wostream & out, const GVN & gvn)
+{
+ out << L"Constants:" << std::endl;
+ for (const auto & p : gvn.mapi64)
+ {
+ out << L" " << p.first << L" -> " << p.second.value << std::endl;
}
- std::map<std::wstring, uint64_t> GVN::getSymMap() const
+ out << L"Symbols:" << std::endl;
+ for (const auto & p : gvn.maps)
{
- std::map<std::wstring, uint64_t> map;
- for (const auto & p : maps)
- {
- map.emplace(p.first.getName(), p.second.value);
- }
+ out << L" " << p.first.getName().data() << L" -> " << p.second.value << std::endl;
+ }
- return map;
+ std::map<uint64_t, std::wstring> map;
+ for (const auto & p : gvn.maps)
+ {
+ map.emplace(p.second.value, p.first.getName());
}
- std::wostream & operator<<(std::wostream & out, const GVN & gvn)
+ out << L"OpValues:" << std::endl;
+ for (const auto & p : gvn.mapv)
{
- out << L"Constants:" << std::endl;
- for (const auto & p : gvn.mapi64)
- {
- out << L" " << p.first << L" -> " << p.second.value << std::endl;
- }
+ out << L" " << p.first << L" -> " << p.second.value << L", P: " << p.second.poly->print(map) << std::endl;
+ }
- out << L"Symbols:" << std::endl;
- for (const auto & p : gvn.maps)
- {
- out << L" " << p.first.getName().data() << L" -> " << p.second.value << std::endl;
- }
+ // Don't remove: useful to debug
- std::map<uint64_t, std::wstring> map;
- for (const auto & p : gvn.maps)
- {
- map.emplace(p.second.value, p.first.getName());
- }
+ /*const bool show_collisions = true;
+ out << std::endl << L"Map polynomials stats:" << std::endl;
+ tools::printMapInfo(out, gvn.mapp, show_collisions);
- out << L"OpValues:" << std::endl;
- for (const auto & p : gvn.mapv)
- {
- out << L" " << p.first << L" -> " << p.second.value << L", P: " << p.second.poly->print(map) << std::endl;
- }
+ out << std::endl << L"Map constants stats:" << std::endl;
+ tools::printMapInfo(out, gvn.mapi64, show_collisions);
- // Don't remove: useful to debug
+ out << std::endl << L"Map values stats:" << std::endl;
+ tools::printMapInfo(out, gvn.mapv, show_collisions);*/
- /*const bool show_collisions = true;
- out << std::endl << L"Map polynomials stats:" << std::endl;
- tools::printMapInfo(out, gvn.mapp, show_collisions);
+ return out;
+}
- out << std::endl << L"Map constants stats:" << std::endl;
- tools::printMapInfo(out, gvn.mapi64, show_collisions);
-
- out << std::endl << L"Map values stats:" << std::endl;
- tools::printMapInfo(out, gvn.mapv, show_collisions);*/
-
- return out;
+GVN::Value * GVN::getValue(const MultivariatePolynomial & mp, const OpValue & ov)
+{
+ if (mp.isConstant())
+ {
+ return getValue(mp.constant);
}
-
- GVN::Value * GVN::getValue(const MultivariatePolynomial & mp, const OpValue & ov)
+ else
{
- if (mp.isConstant())
+ const auto j = mapp.find(mp);
+ if (j == mapp.end())
{
- return getValue(mp.constant);
+ GVN::Value * value = &mapv.emplace(ov, current++).first->second;
+ value->poly = &mapp.emplace(mp, value).first->first;
+
+ return value;
}
else
{
- const auto j = mapp.find(mp);
- if (j == mapp.end())
- {
- GVN::Value * value = &mapv.emplace(ov, current++).first->second;
- value->poly = &mapp.emplace(mp, value).first->first;
-
- return value;
- }
- else
- {
- return j->second;
- }
+ return j->second;
}
}
+}
- GVN::Value * GVN::getValue(MultivariatePolynomial(OPER)(const MultivariatePolynomial & mp), const GVN::Value & LV, const OpValue & ov)
+GVN::Value * GVN::getValue(MultivariatePolynomial(OPER)(const MultivariatePolynomial & mp), const GVN::Value & LV, const OpValue & ov)
+{
+ const auto i = mapv.find(ov);
+ if (i == mapv.end())
{
- const auto i = mapv.find(ov);
- if (i == mapv.end())
- {
- return getValue(OPER(*LV.poly), ov);
- }
- else
- {
- return &i->second;
- }
+ return getValue(OPER(*LV.poly), ov);
+ }
+ else
+ {
+ return &i->second;
}
+}
- GVN::Value * GVN::getValue(MultivariatePolynomial(OPER)(const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP), const GVN::Value & LV, const GVN::Value & RV, const OpValue & ov)
+GVN::Value * GVN::getValue(MultivariatePolynomial(OPER)(const MultivariatePolynomial & LMP, const MultivariatePolynomial & RMP), const GVN::Value & LV, const GVN::Value & RV, const OpValue & ov)
+{
+ const auto i = mapv.find(ov);
+ if (i == mapv.end())
{
- const auto i = mapv.find(ov);
- if (i == mapv.end())
- {
- return getValue(OPER(*LV.poly, *RV.poly), ov);
- }
- else
- {
- return &i->second;
- }
+ return getValue(OPER(*LV.poly, *RV.poly), ov);
+ }
+ else
+ {
+ return &i->second;
}
+}
} // namespace analysis
namespace analysis
{
- bool IconvertAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool IconvertAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs != 1)
{
- if (lhs != 1)
- {
- return false;
- }
+ return false;
+ }
- const ast::exps_t args = e.getArgs();
- if (args.size() != 2)
- {
- return false;
- }
-
- ast::Exp * first = args.front();
- ast::Exp * second = args.back();
+ const ast::exps_t args = e.getArgs();
+ if (args.size() != 2)
+ {
+ return false;
+ }
- first->accept(visitor);
- Result R1 = visitor.getResult();
- TIType & type1 = R1.getType();
- if (!type1.ismatrix())
- {
- return false;
- }
- second->accept(visitor);
- Result & R2 = visitor.getResult();
+ ast::Exp * first = args.front();
+ ast::Exp * second = args.back();
- double val;
- unsigned char ival;
-
- if (R2.getConstant().getDblValue(val) && tools::asInteger<unsigned char>(val, ival))
- {
- TIType::Type type;
+ first->accept(visitor);
+ Result R1 = visitor.getResult();
+ TIType & type1 = R1.getType();
+ if (!type1.ismatrix())
+ {
+ return false;
+ }
+ second->accept(visitor);
+ Result & R2 = visitor.getResult();
+
+ double val;
+ unsigned char ival;
+
+ if (R2.getConstant().getDblValue(val) && tools::asInteger<unsigned char>(val, ival))
+ {
+ TIType::Type type;
- switch (ival)
- {
- case 0:
- type = TIType::DOUBLE;
- break;
- case 1:
- type = TIType::INT8;
- break;
- case 2:
- type = TIType::INT16;
- break;
- case 4:
- type = TIType::INT32;
- break;
- case 8:
- type = TIType::INT64;
- break;
- case 11:
- type = TIType::UINT8;
- break;
- case 12:
- type = TIType::UINT16;
- break;
- case 14:
- type = TIType::UINT32;
- break;
- case 18:
- type = TIType::UINT64;
- break;
- default:
- return false;
- }
+ switch (ival)
+ {
+ case 0:
+ type = TIType::DOUBLE;
+ break;
+ case 1:
+ type = TIType::INT8;
+ break;
+ case 2:
+ type = TIType::INT16;
+ break;
+ case 4:
+ type = TIType::INT32;
+ break;
+ case 8:
+ type = TIType::INT64;
+ break;
+ case 11:
+ type = TIType::UINT8;
+ break;
+ case 12:
+ type = TIType::UINT16;
+ break;
+ case 14:
+ type = TIType::UINT32;
+ break;
+ case 18:
+ type = TIType::UINT64;
+ break;
+ default:
+ return false;
+ }
- TIType typ(visitor.getGVN(), type, type1.rows, type1.cols);
- Result & res = e.getDecorator().setResult(typ);
- e.getDecorator().setCall(L"iconvert");
- visitor.setResult(res);
- return true;
- }
-
- return false;
+ TIType typ(visitor.getGVN(), type, type1.rows, type1.cols);
+ Result & res = e.getDecorator().setResult(typ);
+ e.getDecorator().setCall(L"iconvert");
+ visitor.setResult(res);
+ return true;
}
+
+ return false;
+}
}
namespace analysis
{
- bool InttypeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool InttypeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs != 1)
{
- if (lhs != 1)
- {
- return false;
- }
+ return false;
+ }
- const ast::exps_t args = e.getArgs();
- if (args.size() != 1)
- {
- return false;
- }
+ const ast::exps_t args = e.getArgs();
+ if (args.size() != 1)
+ {
+ return false;
+ }
- ast::Exp * arg = args.back();
- arg->accept(visitor);
- TIType & typ = visitor.getResult().getType();
- double code;
- switch (typ.type)
- {
+ ast::Exp * arg = args.back();
+ arg->accept(visitor);
+ TIType & typ = visitor.getResult().getType();
+ double code;
+ switch (typ.type)
+ {
case TIType::EMPTY :
- case TIType::DOUBLE :
+ case TIType::DOUBLE :
code = 0;
- break;
+ break;
case TIType::INT8 :
code = 1;
- break;
+ break;
case TIType::INT16 :
code = 2;
- break;
+ break;
case TIType::INT32 :
code = 4;
- break;
+ break;
case TIType::INT64 :
code = 8;
- break;
+ break;
case TIType::UINT8 :
code = 11;
- break;
+ break;
case TIType::UINT16 :
code = 12;
- break;
+ break;
case TIType::UINT32 :
code = 14;
- break;
+ break;
case TIType::UINT64 :
code = 18;
- break;
+ break;
default :
- code = -1;
- }
+ code = -1;
+ }
- if (code != -1)
- {
- TIType type(visitor.getGVN(), TIType::DOUBLE);
- Result & res = e.getDecorator().setResult(type);
- res.getConstant() = visitor.getGVN().getValue(code);
- e.getDecorator().setCall(L"inttype");
- visitor.setResult(res);
- return true;
- }
- else
- {
- return false;
- }
+ if (code != -1)
+ {
+ TIType type(visitor.getGVN(), TIType::DOUBLE);
+ Result & res = e.getDecorator().setResult(type);
+ res.getConstant() = visitor.getGVN().getValue(code);
+ e.getDecorator().setCall(L"inttype");
+ visitor.setResult(res);
+ return true;
}
+ else
+ {
+ return false;
+ }
+}
}
namespace analysis
{
- bool IsrealAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool IsrealAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs != 1)
+ {
+ return false;
+ }
+
+ const ast::exps_t args = e.getArgs();
+ const std::size_t size = args.size();
+ if (size == 0 || size > 2)
+ {
+ return false;
+ }
+
+ ast::Exp * first = args.front();
+ first->accept(visitor);
+ Result & R1 = visitor.getResult();
+ TIType & type1 = R1.getType();
+ int ret = -1;
+
+ if (type1.type == TIType::DOUBLE || type1.type == TIType::EMPTY)
{
- if (lhs != 1)
- {
- return false;
- }
-
- const ast::exps_t args = e.getArgs();
- const std::size_t size = args.size();
- if (size == 0 || size > 2)
- {
- return false;
- }
-
- ast::Exp * first = args.front();
- first->accept(visitor);
- Result & R1 = visitor.getResult();
- TIType & type1 = R1.getType();
- int ret = -1;
-
- if (type1.type == TIType::DOUBLE || type1.type == TIType::EMPTY)
- {
- ret = 1;
- }
- else if (type1.type == TIType::COMPLEX && size == 1)
- {
- ret = 0;
- }
-
- if (ret != -1)
- {
- TIType type(visitor.getGVN(), TIType::BOOLEAN);
- Result & res = e.getDecorator().setResult(type);
- res.getConstant() = new types::Bool(ret);
- e.getDecorator().setCall(L"isreal");
- visitor.setResult(res);
-
- return true;
- }
-
- return false;
+ ret = 1;
}
+ else if (type1.type == TIType::COMPLEX && size == 1)
+ {
+ ret = 0;
+ }
+
+ if (ret != -1)
+ {
+ TIType type(visitor.getGVN(), TIType::BOOLEAN);
+ Result & res = e.getDecorator().setResult(type);
+ res.getConstant() = new types::Bool(ret);
+ e.getDecorator().setCall(L"isreal");
+ visitor.setResult(res);
+
+ return true;
+ }
+
+ return false;
+}
}
namespace analysis
{
- bool IsscalarAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool IsscalarAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs != 1)
{
- if (lhs != 1)
- {
- return false;
- }
+ return false;
+ }
- const ast::exps_t args = e.getArgs();
- if (args.size() != 1)
- {
- return false;
- }
+ const ast::exps_t args = e.getArgs();
+ if (args.size() != 1)
+ {
+ return false;
+ }
- ast::Exp * first = args.front();
- first->accept(visitor);
- Result & R1 = visitor.getResult();
- TIType & type1 = R1.getType();
+ ast::Exp * first = args.front();
+ first->accept(visitor);
+ Result & R1 = visitor.getResult();
+ TIType & type1 = R1.getType();
- if (!type1.ismatrix())
- {
- return false;
- }
-
- if (type1.isscalar())
- {
- TIType type(visitor.getGVN(), TIType::BOOLEAN);
- Result & res = e.getDecorator().setResult(type);
- res.getConstant() = new types::Bool(1);
- e.getDecorator().setCall(L"isscalar");
- visitor.setResult(res);
- return true;
- }
+ if (!type1.ismatrix())
+ {
+ return false;
+ }
- return false;
+ if (type1.isscalar())
+ {
+ TIType type(visitor.getGVN(), TIType::BOOLEAN);
+ Result & res = e.getDecorator().setResult(type);
+ res.getConstant() = new types::Bool(1);
+ e.getDecorator().setCall(L"isscalar");
+ visitor.setResult(res);
+ return true;
}
+
+ return false;
+}
}
namespace analysis
{
- bool ListExpAnalyzer::analyze(ast::ListExp & e, SymbolicList & sl, TIType & type)
+bool ListExpAnalyzer::analyze(ast::ListExp & e, SymbolicList & sl, TIType & type)
+{
+ e.getStart().accept(*this);
+ Result Rstart = getResult();
+ e.getEnd().accept(*this);
+ Result Rend = getResult();
+ e.getStep().accept(*this);
+ Result & Rstep = getResult();
+
+ double start, step, end;
+ if (Rstart.getConstant().getDblValue(start) && Rstep.getConstant().getDblValue(step) && Rend.getConstant().getDblValue(end))
{
- e.getStart().accept(*this);
- Result Rstart = getResult();
- e.getEnd().accept(*this);
- Result Rend = getResult();
- e.getStep().accept(*this);
- Result & Rstep = getResult();
+ double out;
+ int type = ForList64::checkList(start, end, step, out);
- double start, step, end;
- if (Rstart.getConstant().getDblValue(start) && Rstep.getConstant().getDblValue(step) && Rend.getConstant().getDblValue(end))
+ switch (type)
{
- double out;
- int type = ForList64::checkList(start, end, step, out);
-
- switch (type)
- {
case 0:
- type = TIType(dm.getGVN(), TIType::EMPTY);
- break;
+ type = TIType(dm.getGVN(), TIType::EMPTY);
+ break;
case 1:
type = TIType(dm.getGVN(), TIType::DOUBLE);
- break;
+ break;
case 2:
{
const uint64_t N = ForList64::size(start, end, step);
type = TIType(getGVN(), TIType::DOUBLE, 1, N);
- sl = SymbolicList(start, step, end);
+ sl = SymbolicList(start, step, end);
break;
}
default:
break;
- }
- e.setValues(start, step, end, out);
- return true;
}
+ e.setValues(start, step, end, out);
+ return true;
+ }
- GVN::Value * gvnStart, * gvnStep, * gvnEnd;
- if (Rstart.getConstant().getDblValue(start))
- {
- if (tools::getIntType(start) == tools::NOTANINT)
- {
- gvnStart = getGVN().getValue((double)tools::cast<int>(start + step));
- }
- else
- {
- gvnStart = getGVN().getValue((double)tools::cast<int>(start));
- }
- }
- else
- {
- gvnStart = Rstart.getConstant().getGVNValue();
- if (!gvnStart)
- {
- Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
- setResult(res);
- return;
- }
- }
+ GVN::Value * gvnStart, * gvnStep, * gvnEnd;
+ if (Rstart.getConstant().getDblValue(start))
+ {
+ if (tools::getIntType(start) == tools::NOTANINT)
+ {
+ gvnStart = getGVN().getValue((double)tools::cast<int>(start + step));
+ }
+ else
+ {
+ gvnStart = getGVN().getValue((double)tools::cast<int>(start));
+ }
+ }
+ else
+ {
+ gvnStart = Rstart.getConstant().getGVNValue();
+ if (!gvnStart)
+ {
+ Result & res = e.getDecorator().setResult(Result(TIType(dm.getGVN(), Rstart.getType().type, false, true), -1));
+ setResult(res);
+ return;
+ }
+ }
+
+ GVN & gvn = getGVN();
+ if (Rstart.getConstant().getGVNValue(gvn, gvnStart) && Rstep.getConstant().getGVNValue(gvn, gvnStep) && Rend.getConstant().getGVNValue(gvn, gvnEnd))
+ {
+ sl = SymbolicList(gvnStart, gvnStep, gvnEnd);
+ if (gvnStep->poly->isConstant())
+ {
+ step = gvnStep->poly->constant;
+ if (step == 1 || step == -1)
+ {
- GVN & gvn = getGVN();
- if (Rstart.getConstant().getGVNValue(gvn, gvnStart) && Rstep.getConstant().getGVNValue(gvn, gvnStep) && Rend.getConstant().getGVNValue(gvn, gvnEnd))
- {
- sl = SymbolicList(gvnStart, gvnStep, gvnEnd);
- if (gvnStep->poly->isConstant())
- {
- step = gvnStep->poly->constant;
- if (step == 1 || step == -1)
- {
-
- }
- }
- }
+ }
+ }
}
}
+}
namespace analysis
{
- bool MatrixAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+bool MatrixAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e)
+{
+ if (lhs > 1)
+ {
+ return false;
+ }
+
+ const ast::exps_t args = e.getArgs();
+ const unsigned int size = args.size();
+ if (size != 2 && size != 3)
+ {
+ return false;
+ }
+
+ if (size == 2)
+ {
+ return analyze2Args(visitor, args, e);
+ }
+
+ ast::Exp * first = args[0];
+ ast::Exp * second = args[1];
+ ast::Exp * third = args[2];
+
+ first->accept(visitor);
+ Result R1 = visitor.getResult();
+ if (!R1.getType().ismatrix())
{
- if (lhs > 1)
+ return false;
+ }
+
+ second->accept(visitor);
+ Result R2 = visitor.getResult();
+ third->accept(visitor);
+ Result & R3 = visitor.getResult();
+
+ double val;
+ SymbolicDimension rows;
+ SymbolicDimension cols;
+
+ if (R2.getConstant().getDblValue(val))
+ {
+ const int nrows = tools::cast<int>(val);
+ if (nrows <= 0)
{
return false;
}
-
- const ast::exps_t args = e.getArgs();
- const unsigned int size = args.size();
- if (size != 2 && size != 3)
+ else
{
- return false;
+ rows = SymbolicDimension(visitor.getGVN(), nrows);
}
-
- if (size == 2)
- {
- return analyze2Args(visitor, args, e);
- }
-
- ast::Exp * first = args[0];
- ast::Exp * second = args[1];
- ast::Exp * third = args[2];
-
- first->accept(visitor);
- Result R1 = visitor.getResult();
- if (!R1.getType().ismatrix())
+ }
+ else if (GVN::Value * gvnValue = R2.getConstant().getGVNValue())
+ {
+ if (gvnValue->poly->isConstant() && gvnValue->poly->constant <= 0)
{
return false;
}
+ rows.setValue(gvnValue);
+ rows.setGVN(&visitor.getGVN());
+ }
+ else
+ {
+ return false;
+ }
- second->accept(visitor);
- Result R2 = visitor.getResult();
- third->accept(visitor);
- Result & R3 = visitor.getResult();
-
- double val;
- SymbolicDimension rows;
- SymbolicDimension cols;
-
- if (R2.getConstant().getDblValue(val))
+ if (R3.getConstant().getDblValue(val))
+ {
+ const int ncols = tools::cast<int>(val);
+ if (ncols <= 0)
{
- const int nrows = tools::cast<int>(val);
- if (nrows <= 0)
- {
- return false;
- }
- else
- {
- rows = SymbolicDimension(visitor.getGVN(), nrows);
- }
+ return false;
}
- else if (GVN::Value * gvnValue = R2.getConstant().getGVNValue())
+ else
{
- if (gvnValue->poly->isConstant() && gvnValue->poly->constant <= 0)
- {
- return false;
- }
- rows.setValue(gvnValue);
- rows.setGVN(&visitor.getGVN());
+ cols = SymbolicDimension(visitor.getGVN(), ncols);
}
- else
+ }
+ else if (GVN::Value * gvnValue = R3.getConstant().getGVNValue())
+ {
+ if (gvnValue->poly->isConstant() && gvnValue->poly->constant <= 0)
{
return false;
}
+ cols.setValue(gvnValue);
+ cols.setGVN(&visitor.getGVN());
+ }
+ else
+ {
+ return false;
+ }
- if (R3.getConstant().getDblValue(val))
+ const TIType & type = R1.getType();
+ SymbolicDimension prod1 = type.rows * type.cols;
+ SymbolicDimension prod2 = rows * cols;
+ bool res = visitor.getCM().check(ConstraintManager::EQUAL, prod1.getValue(), prod2.getValue());
+ if (res)
+ {
+ res = visitor.getCM().check(ConstraintManager::POSITIVE, rows.getValue());
+ if (!res)
{
- const int ncols = tools::cast<int>(val);
- if (ncols <= 0)
- {
- return false;
- }
- else
- {
- cols = SymbolicDimension(visitor.getGVN(), ncols);
- }
+ return false;
}
- else if (GVN::Value * gvnValue = R3.getConstant().getGVNValue())
+ }
+ else
+ {
+ return false;
+ }
+
+ TIType resT(visitor.getGVN(), R1.getType().type, rows, cols);
+ int tempId;
+ if (R1.getTempId() != -1)
+ {
+ tempId = R1.getTempId();
+ }
+ else
+ {
+ tempId = visitor.getDM().getTmpId(resT, false);
+ }
+ Result & _res = e.getDecorator().setResult(Result(resT, tempId));
+ visitor.setResult(_res);
+ return true;
+}
+
+bool MatrixAnalyzer::analyze2Args(AnalysisVisitor & visitor, const ast::exps_t & args, ast::CallExp & e)
+{
+ ast::Exp * first = args[0];
+ ast::Exp * second = args[1];
+
+ first->accept(visitor);
+ Result R1 = visitor.getResult();
+ if (!R1.getType().ismatrix())
+ {
+ return false;
+ }
+
+ SymbolicDimension rows;
+ SymbolicDimension cols;
+ bool hasRC = false;
+
+ if (second->isCallExp())
+ {
+ ast::CallExp & ce = static_cast<ast::CallExp &>(*second);
+ if (ce.getName().isSimpleVar())
{
- if (gvnValue->poly->isConstant() && gvnValue->poly->constant <= 0)
+ ast::SimpleVar & var = static_cast<ast::SimpleVar &>(ce.getName());
+ const symbol::Symbol & sym = var.getSymbol();
+ const std::wstring & name = sym.getName();
+ if (name == L"size" && visitor.getCM().checkGlobalConstant(sym))
{
- return false;
+ const ast::exps_t size_args = ce.getArgs();
+ if (size_args.size() == 1)
+ {
+ ast::Exp * e = size_args[0];
+ e->accept(visitor);
+ Result & res = visitor.getResult();
+ if (res.getType().ismatrix())
+ {
+ rows = res.getType().rows;
+ cols = res.getType().cols;
+ hasRC = true;
+ }
+ }
}
- cols.setValue(gvnValue);
- cols.setGVN(&visitor.getGVN());
- }
- else
- {
- return false;
}
+ }
+ if (hasRC)
+ {
const TIType & type = R1.getType();
SymbolicDimension prod1 = type.rows * type.cols;
SymbolicDimension prod2 = rows * cols;
bool res = visitor.getCM().check(ConstraintManager::EQUAL, prod1.getValue(), prod2.getValue());
if (res)
{
- res = visitor.getCM().check(ConstraintManager::POSITIVE, rows.getValue());
- if (!res)
+ TIType resT(visitor.getGVN(), R1.getType().type, rows, cols);
+ int tempId;
+ if (R1.getTempId() != -1)
{
- return false;
+ tempId = R1.getTempId();
}
- }
- else
- {
- return false;
- }
+ else
+ {
+ tempId = visitor.getDM().getTmpId(resT, false);
+ }
+ Result & _res = e.getDecorator().setResult(Result(resT, tempId));
+ visitor.setResult(_res);
- TIType resT(visitor.getGVN(), R1.getType().type, rows, cols);
- int tempId;
- if (R1.getTempId() != -1)
- {
- tempId = R1.getTempId();
- }
- else
- {
- tempId = visitor.getDM().getTmpId(resT, false);
- }
- Result & _res = e.getDecorator().setResult(Result(resT, tempId));
- visitor.setResult(_res);
- return true;
- }
-
- bool MatrixAnalyzer::analyze2Args(AnalysisVisitor & visitor, const ast::exps_t & args, ast::CallExp & e)
- {
- ast::Exp * first = args[0];
- ast::Exp * second = args[1];
-
- first->accept(visitor);
- Result R1 = visitor.getResult();
- if (!R1.getType().ismatrix())
- {
- return false;
+ return true;
}
-
- SymbolicDimension rows;
- SymbolicDimension cols;
- bool hasRC = false;
-
- if (second->isCallExp())
- {
- ast::CallExp & ce = static_cast<ast::CallExp &>(*second);
- if (ce.getName().isSimpleVar())
- {
- ast::SimpleVar & var = static_cast<ast::SimpleVar &>(ce.getName());
- const symbol::Symbol & sym = var.getSymbol();
- const std::wstring & name = sym.getName();
- if (name == L"size" && visitor.getCM().checkGlobalConstant(sym))
- {
- const ast::exps_t size_args = ce.getArgs();
- if (size_args.size() == 1)
- {
- ast::Exp * e = size_args[0];
- e->accept(visitor);
- Result & res = visitor.getResult();
- if (res.getType().ismatrix())
- {
- rows = res.getType().rows;
- cols = res.getType().cols;
- hasRC = true;
- }
- }
- }
- }
- }
-
- if (hasRC)
- {
- const TIType & type = R1.getType();
- SymbolicDimension prod1 = type.rows * type.cols;
- SymbolicDimension prod2 = rows * cols;
- bool res = visitor.getCM().check(ConstraintManager::EQUAL, prod1.getValue(), prod2.getValue());
- if (res)
- {
- TIType resT(visitor.getGVN(), R1.getType().type, rows, cols);
- int tempId;
- if (R1.getTempId() != -1)
- {
- tempId = R1.getTempId();
- }
- else
- {
- tempId = visitor.getDM().getTmpId(resT, false);
- }
- Result & _res = e.getDecorator().setResult(Result(resT, tempId));
- visitor.setResult(_res);
-
- return true;
- }
- }
-
- return false;
}
+
+ return false;
+}
}
namespace analysis
{
- std::wostream & operator<<(std::wostream & out, const OpValue & ov)
+std::wostream & operator<<(std::wostream & out, const OpValue & ov)
+{
+ switch (ov.kind)
{
- switch (ov.kind)
- {
case OpValue::UNARYMINUS:
out << L"-" << ov.lnum;
break;
default:
out << ov.lnum << L"??" << ov.rnum;
break;
- }
-
- return out;
}
+ return out;
+}
+
} // namespace analysis
namespace analysis
{
- bool AnalysisVisitor::operSymbolicRange(ast::OpExp & oe)
+bool AnalysisVisitor::operSymbolicRange(ast::OpExp & oe)
+{
+ const ast::OpExp::Oper oper = oe.getOper();
+ if (oper == ast::OpExp::plus || oper == ast::OpExp::minus || oper == ast::OpExp::times || oper == ast::OpExp::rdivide)
{
- const ast::OpExp::Oper oper = oe.getOper();
- if (oper == ast::OpExp::plus || oper == ast::OpExp::minus || oper == ast::OpExp::times || oper == ast::OpExp::rdivide)
- {
- Result & resL = oe.getLeft().getDecorator().getResult();
- Result & resR = oe.getRight().getDecorator().getResult();
- const SymbolicRange & rangeL = resL.getRange();
- const SymbolicRange & rangeR = resR.getRange();
- const bool validL = rangeL.isValid();
- const bool validR = rangeR.isValid();
- SymbolicRange rangeOpL, rangeOpR;
- bool have2Ranges = false;
- bool LisInt = false;
- bool RisInt = false;
- GVN::Value * gvnR;
- GVN::Value * gvnL;
+ Result & resL = oe.getLeft().getDecorator().getResult();
+ Result & resR = oe.getRight().getDecorator().getResult();
+ const SymbolicRange & rangeL = resL.getRange();
+ const SymbolicRange & rangeR = resR.getRange();
+ const bool validL = rangeL.isValid();
+ const bool validR = rangeR.isValid();
+ SymbolicRange rangeOpL, rangeOpR;
+ bool have2Ranges = false;
+ bool LisInt = false;
+ bool RisInt = false;
+ GVN::Value * gvnR;
+ GVN::Value * gvnL;
- if (validL && validR)
+ if (validL && validR)
+ {
+ rangeOpL = rangeL;
+ rangeOpR = rangeR;
+ have2Ranges = true;
+ }
+ else if (validL)
+ {
+ rangeOpL = rangeL;
+ if (resR.getConstant().getGVNValue(getGVN(), gvnR))
{
- rangeOpL = rangeL;
- rangeOpR = rangeR;
+ RisInt = true;
+ rangeOpR.set(getGVN(), gvnR, gvnR);
have2Ranges = true;
}
- else if (validL)
+ }
+ else if (validR)
+ {
+ rangeOpR = rangeR;
+ if (resL.getConstant().getGVNValue(getGVN(), gvnL))
{
- rangeOpL = rangeL;
- if (resR.getConstant().getGVNValue(getGVN(), gvnR))
- {
- RisInt = true;
- rangeOpR.set(getGVN(), gvnR, gvnR);
- have2Ranges = true;
- }
+ LisInt = true;
+ rangeOpL.set(getGVN(), gvnL, gvnL);
+ have2Ranges = true;
}
- else if (validR)
+ }
+
+ if (have2Ranges)
+ {
+ TIType typ(getGVN(), TIType::DOUBLE, 1, 1);
+ switch (oper)
{
- rangeOpR = rangeR;
- if (resL.getConstant().getGVNValue(getGVN(), gvnL))
+ case ast::OpExp::plus:
{
- LisInt = true;
- rangeOpL.set(getGVN(), gvnL, gvnL);
- have2Ranges = true;
+ if (LisInt)
+ {
+ resL.getConstant() = gvnL;
+ }
+ if (RisInt)
+ {
+ resR.getConstant() = gvnR;
+ }
+ Result & res = oe.getDecorator().setResult(typ);
+ res.getRange() = rangeOpL + rangeOpR;
+ oe.getDecorator().safe = true;
+ setResult(res);
+ return true;
+ }
+ case ast::OpExp::minus:
+ {
+ if (LisInt)
+ {
+ resL.getConstant() = gvnL;
+ }
+ if (RisInt)
+ {
+ resR.getConstant() = gvnR;
+ }
+ Result & res = oe.getDecorator().setResult(typ);
+ res.getRange() = rangeOpL - rangeOpR;
+ oe.getDecorator().safe = true;
+ setResult(res);
+ return true;
+ }
+ case ast::OpExp::times:
+ {
+ if (LisInt)
+ {
+ resL.getConstant() = gvnL;
+ }
+ if (RisInt)
+ {
+ resR.getConstant() = gvnR;
+ }
+ Result & res = oe.getDecorator().setResult(typ);
+ res.getRange() = rangeOpL * rangeOpR;
+ oe.getDecorator().safe = true;
+ setResult(res);
+ return true;
+ }
+ case ast::OpExp::rdivide:
+ {
+ if (rangeOpL.getStart()->poly->isDivisibleBy(*rangeOpR.getEnd()->poly) && rangeOpL.getEnd()->poly->isDivisibleBy(*rangeOpR.getStart()->poly))
+ {
+ if (LisInt)
+ {
+ resL.getConstant() = gvnL;
+ }
+ if (RisInt)
+ {
+ resR.getConstant() = gvnR;
+ }
+ Result & res = oe.getDecorator().setResult(typ);
+ res.getRange() = rangeOpL / rangeOpR;
+ oe.getDecorator().safe = true;
+ setResult(res);
+ return true;
+ }
}
- }
-
- if (have2Ranges)
- {
- TIType typ(getGVN(), TIType::DOUBLE, 1, 1);
- switch (oper)
- {
- case ast::OpExp::plus:
- {
- if (LisInt)
- {
- resL.getConstant() = gvnL;
- }
- if (RisInt)
- {
- resR.getConstant() = gvnR;
- }
- Result & res = oe.getDecorator().setResult(typ);
- res.getRange() = rangeOpL + rangeOpR;
- oe.getDecorator().safe = true;
- setResult(res);
- return true;
- }
- case ast::OpExp::minus:
- {
- if (LisInt)
- {
- resL.getConstant() = gvnL;
- }
- if (RisInt)
- {
- resR.getConstant() = gvnR;
- }
- Result & res = oe.getDecorator().setResult(typ);
- res.getRange() = rangeOpL - rangeOpR;
- oe.getDecorator().safe = true;
- setResult(res);
- return true;
- }
- case ast::OpExp::times:
- {
- if (LisInt)
- {
- resL.getConstant() = gvnL;
- }
- if (RisInt)
- {
- resR.getConstant() = gvnR;
- }
- Result & res = oe.getDecorator().setResult(typ);
- res.getRange() = rangeOpL * rangeOpR;
- oe.getDecorator().safe = true;
- setResult(res);
- return true;
- }
- case ast::OpExp::rdivide:
- {
- if (rangeOpL.getStart()->poly->isDivisibleBy(*rangeOpR.getEnd()->poly) && rangeOpL.getEnd()->poly->isDivisibleBy(*rangeOpR.getStart()->poly))
- {
- if (LisInt)
- {
- resL.getConstant() = gvnL;
- }
- if (RisInt)
- {
- resR.getConstant() = gvnR;
- }
- Result & res = oe.getDecorator().setResult(typ);
- res.getRange() = rangeOpL / rangeOpR;
- oe.getDecorator().safe = true;
- setResult(res);
- return true;
- }
- }
- }
}
}
-
- return false;
}
+
+ return false;
+}
}
namespace analysis
{
- PolymorphicMacroCache::PolymorphicMacroCache() : id(1) { }
+PolymorphicMacroCache::PolymorphicMacroCache() : id(1) { }
- PolymorphicMacroCache::~PolymorphicMacroCache() { }
-
- const bool PolymorphicMacroCache::getOutTypes(AnalysisVisitor & visitor, MacroDef * macrodef, std::vector<TIType> & in, std::vector<TIType> & out, uint64_t & functionId)
- {
- // TODO: handle varargin
- if (in.size() > macrodef->getRhs())
- {
- return false;
- }
+PolymorphicMacroCache::~PolymorphicMacroCache() { }
- std::vector<TIType> completeIn;
- if (!PolymorphicMacroCache::getCompleteIn(*macrodef, visitor, in, completeIn))
- {
- return false;
- }
+const bool PolymorphicMacroCache::getOutTypes(AnalysisVisitor & visitor, MacroDef * macrodef, std::vector<TIType> & in, std::vector<TIType> & out, uint64_t & functionId)
+{
+ // TODO: handle varargin
+ if (in.size() > macrodef->getRhs())
+ {
+ return false;
+ }
- MacroSignature signature(*macrodef, out.size(), completeIn);
- MacroSignMap::iterator i = signatures.find(signature);
- if (i == signatures.end())
- {
- i = signatures.emplace(signature, CompleteMacroSignature(gvn, id)).first;
- }
+ std::vector<TIType> completeIn;
+ if (!PolymorphicMacroCache::getCompleteIn(*macrodef, visitor, in, completeIn))
+ {
+ return false;
+ }
- CompleteMacroSignature & cms = i->second;
- std::vector<GVN::Value *> values;
- std::vector<const MultivariatePolynomial *> polys;
- for (auto & t : completeIn)
- {
- if (t.isscalar())
- {
- GVN::Value * v = t.rows.getValue();
- values.emplace_back(v);
- polys.emplace_back(v->poly);
- }
- else
- {
- GVN::Value * v = t.rows.getValue();
- values.emplace_back(v);
- polys.emplace_back(v->poly);
- v = t.cols.getValue();
- values.emplace_back(v);
- polys.emplace_back(v->poly);
- }
- }
+ MacroSignature signature(*macrodef, out.size(), completeIn);
+ MacroSignMap::iterator i = signatures.find(signature);
+ if (i == signatures.end())
+ {
+ i = signatures.emplace(signature, CompleteMacroSignature(gvn, id)).first;
+ }
- const MacroOut * mout = cms.getOutTypes(visitor, signature, macrodef, visitor.getDM(), in.size(), completeIn, values, functionId);
- if (mout)
+ CompleteMacroSignature & cms = i->second;
+ std::vector<GVN::Value *> values;
+ std::vector<const MultivariatePolynomial *> polys;
+ for (auto & t : completeIn)
+ {
+ if (t.isscalar())
{
- std::vector<TIType>::iterator i = out.begin();
- for (const auto & t : mout->tuple.types)
- {
- *i = t;
- GVN::Value * Rv = getValue(t.rows.getValue(), visitor, polys, mout->maxVarId);
- GVN::Value * Cv = getValue(t.cols.getValue(), visitor, polys, mout->maxVarId);
- i->rows.setValue(Rv);
- i->cols.setValue(Cv);
- i->invalidScalar();
- ++i;
- }
-
- //out.assign(mout->tuple.types.begin(), mout->tuple.types.end());
- return true;
+ GVN::Value * v = t.rows.getValue();
+ values.emplace_back(v);
+ polys.emplace_back(v->poly);
}
else
{
- return false;
+ GVN::Value * v = t.rows.getValue();
+ values.emplace_back(v);
+ polys.emplace_back(v->poly);
+ v = t.cols.getValue();
+ values.emplace_back(v);
+ polys.emplace_back(v->poly);
}
}
- bool PolymorphicMacroCache::getCompleteIn(MacroDef & macrodef, AnalysisVisitor & visitor, const std::vector<TIType> & in, std::vector<TIType> & completeIn)
+ const MacroOut * mout = cms.getOutTypes(visitor, signature, macrodef, visitor.getDM(), in.size(), completeIn, values, functionId);
+ if (mout)
{
- for (const auto & ty : in)
+ std::vector<TIType>::iterator i = out.begin();
+ for (const auto & t : mout->tuple.types)
{
- if (ty.type == TIType::UNKNOWN)
- {
- return false;
- }
+ *i = t;
+ GVN::Value * Rv = getValue(t.rows.getValue(), visitor, polys, mout->maxVarId);
+ GVN::Value * Cv = getValue(t.cols.getValue(), visitor, polys, mout->maxVarId);
+ i->rows.setValue(Rv);
+ i->cols.setValue(Cv);
+ i->invalidScalar();
+ ++i;
}
- const tools::SymbolOrdSet & globals = macrodef.getGlobals();
- completeIn.reserve(in.size() + globals.size());
- for (const auto & ty : in)
+ //out.assign(mout->tuple.types.begin(), mout->tuple.types.end());
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool PolymorphicMacroCache::getCompleteIn(MacroDef & macrodef, AnalysisVisitor & visitor, const std::vector<TIType> & in, std::vector<TIType> & completeIn)
+{
+ for (const auto & ty : in)
+ {
+ if (ty.type == TIType::UNKNOWN)
{
- completeIn.emplace_back(ty);
+ return false;
}
+ }
- const std::vector<symbol::Symbol> & declaredIn = macrodef.getIn();
- const unsigned int size = declaredIn.size();
- DataManager & dm = visitor.getDM();
+ const tools::SymbolOrdSet & globals = macrodef.getGlobals();
+ completeIn.reserve(in.size() + globals.size());
+ for (const auto & ty : in)
+ {
+ completeIn.emplace_back(ty);
+ }
- if (in.size() < size)
+ const std::vector<symbol::Symbol> & declaredIn = macrodef.getIn();
+ const unsigned int size = declaredIn.size();
+ DataManager & dm = visitor.getDM();
+
+ if (in.size() < size)
+ {
+ // we have less rhs than declared rhs:
+ // function foo(x,y,z)...endfunction
+ // called with foo(x) so y and z are globals
+ for (unsigned int i = in.size(); i < size; ++i)
{
- // we have less rhs than declared rhs:
- // function foo(x,y,z)...endfunction
- // called with foo(x) so y and z are globals
- for (unsigned int i = in.size(); i < size; ++i)
- {
- completeIn.emplace_back(dm.getType(declaredIn[i]));
- }
+ completeIn.emplace_back(dm.getType(declaredIn[i]));
}
+ }
- for (const auto & sym : globals)
+ for (const auto & sym : globals)
+ {
+ TIType ty = dm.getType(sym, /* global */ true);
+ completeIn.emplace_back(ty);
+ if (ty.type == TIType::UNKNOWN)
{
- TIType ty = dm.getType(sym, /* global */ true);
- completeIn.emplace_back(ty);
- if (ty.type == TIType::UNKNOWN)
- {
- return false;
- }
+ return false;
}
-
- return true;
}
- GVN::Value * PolymorphicMacroCache::getValue(const GVN::Value * value, AnalysisVisitor & visitor, const std::vector<const MultivariatePolynomial *> & polys, const int maxVarId) const
+ return true;
+}
+
+GVN::Value * PolymorphicMacroCache::getValue(const GVN::Value * value, AnalysisVisitor & visitor, const std::vector<const MultivariatePolynomial *> & polys, const int maxVarId) const
+{
+ if (value->poly->containsVarsGEq(maxVarId + 1))
{
- if (value->poly->containsVarsGEq(maxVarId + 1))
+ // we translate variables with an id which could conflict with ids in the poly
+ MultivariatePolynomial mp1 = value->poly->translateVariables(visitor.getGVN().getCurrentValue() + 1, maxVarId + 1);
+ MultivariatePolynomial mp2 = mp1.eval(polys);
+ if (mp2.containsVarsGEq(visitor.getGVN().getCurrentValue() + 1))
{
- // we translate variables with an id which could conflict with ids in the poly
- MultivariatePolynomial mp1 = value->poly->translateVariables(visitor.getGVN().getCurrentValue() + 1, maxVarId + 1);
- MultivariatePolynomial mp2 = mp1.eval(polys);
- if (mp2.containsVarsGEq(visitor.getGVN().getCurrentValue() + 1))
- {
- // after evaluation, we have always values coming from the function block GVN
- return visitor.getGVN().getValue();
- }
- else
- {
- return visitor.getGVN().getValue(mp2);
- }
+ // after evaluation, we have always values coming from the function block GVN
+ return visitor.getGVN().getValue();
}
else
{
- // the out poly is only an expression of the in values
- MultivariatePolynomial mp = value->poly->eval(polys);
- return visitor.getGVN().getValue(mp);
+ return visitor.getGVN().getValue(mp2);
}
}
-
- std::wostream & operator<<(std::wostream & out, const PolymorphicMacroCache & pmc)
+ else
{
- out << L"Macro cache" << "\n";
- tools::printMap(pmc.signatures, out, true);
- return out;
+ // the out poly is only an expression of the in values
+ MultivariatePolynomial mp = value->poly->eval(polys);
+ return visitor.getGVN().getValue(mp);
}
+}
+
+std::wostream & operator<<(std::wostream & out, const PolymorphicMacroCache & pmc)
+{
+ out << L"Macro cache" << "\n";
+ tools::printMap(pmc.signatures, out, true);
+ return out;
+}
} // namespace analysis
namespace analysis
{
- bool SymbolicList::getType(GVN & gvn, TIType & type) const
+bool SymbolicList::getType(GVN & gvn, TIType & type) const
+{
+ double dstart, dstep, dend;
+ bool known = false;
+ if (symbolic)
+ {
+ const MultivariatePolynomial & mpStart = *start.gvnVal->poly;
+ const MultivariatePolynomial & mpStep = *step.gvnVal->poly;
+ const MultivariatePolynomial & mpEnd = *end.gvnVal->poly;
+ if (mpStart.isConstant() && mpStep.isConstant() && mpEnd.isConstant())
+ {
+ dstart = mpStart.constant;
+ dstep = mpStep.constant;
+ dend = mpEnd.constant;
+ known = true;
+ }
+ }
+ else
{
- double dstart, dstep, dend;
- bool known = false;
- if (symbolic)
- {
- const MultivariatePolynomial & mpStart = *start.gvnVal->poly;
- const MultivariatePolynomial & mpStep = *step.gvnVal->poly;
- const MultivariatePolynomial & mpEnd = *end.gvnVal->poly;
- if (mpStart.isConstant() && mpStep.isConstant() && mpEnd.isConstant())
- {
- dstart = mpStart.constant;
- dstep = mpStep.constant;
- dend = mpEnd.constant;
- known = true;
- }
- }
- else
- {
- dstart = start.dval;
- dstep = step.dval;
- dend = end.dval;
- known = true;
- }
+ dstart = start.dval;
+ dstep = step.dval;
+ dend = end.dval;
+ known = true;
+ }
- if (known)
- {
- double out;
- int _type = ForList64::checkList(dstart, dend, dstep, out);
-
- switch (_type)
- {
+ if (known)
+ {
+ double out;
+ int _type = ForList64::checkList(dstart, dend, dstep, out);
+
+ switch (_type)
+ {
case 0:
- type = TIType(gvn, TIType::EMPTY);
- return true;
+ type = TIType(gvn, TIType::EMPTY);
+ return true;
case 1:
- type = TIType(gvn, TIType::DOUBLE);
- return true;
+ type = TIType(gvn, TIType::DOUBLE);
+ return true;
case 2:
{
const uint64_t N = ForList64::size(dstart, dend, dstep);
type = TIType(gvn, TIType::DOUBLE, 1, N);
- return true;
+ return true;
}
default:
- return false;
- }
- }
-
- GVN::Value * gvnStart = start.gvnVal, * gvnStep = step.gvnVal, * gvnEnd = end.gvnVal;
- if (!gvnStep->poly->isConstant())
- {
- return false;
- }
+ return false;
+ }
+ }
- dstep = gvnStep->poly->constant;
- if (dstep == 0)
- {
- type = TIType(gvn, TIType::EMPTY);
- return true;
- }
+ GVN::Value * gvnStart = start.gvnVal, * gvnStep = step.gvnVal, * gvnEnd = end.gvnVal;
+ if (!gvnStep->poly->isConstant())
+ {
+ return false;
+ }
- if (dstep != -1 && dstep != 1)
- {
- // TODO : we must be able to handle general step (even if -1 or 1 seem to be the most frequent values)
- // but it implies that we need a symbolic division on polynomials.
- return false;
- }
-
- GVN::Value * ONEValue = gvn.getValue(1.);
- SymbolicDimension ONE(gvn, ONEValue);
+ dstep = gvnStep->poly->constant;
+ if (dstep == 0)
+ {
+ type = TIType(gvn, TIType::EMPTY);
+ return true;
+ }
- if (gvnStart->value == gvnEnd->value)
- {
- type = TIType(gvn, TIType::DOUBLE, ONE, ONE);
- return true;
- }
+ if (dstep != -1 && dstep != 1)
+ {
+ // TODO : we must be able to handle general step (even if -1 or 1 seem to be the most frequent values)
+ // but it implies that we need a symbolic division on polynomials.
+ return false;
+ }
- GVN::Value * v;
- if (dstep == 1)
- {
- v = gvn.getValue(OpValue::Kind::MINUS, *gvnEnd, *gvnStart);
- }
- else
- {
- v = gvn.getValue(OpValue::Kind::MINUS, *gvnStart, *gvnEnd);
- }
- v = gvn.getValue(OpValue::Kind::PLUS, *v, *ONEValue);
- if (v->poly->constant < 0 && v->poly->isCoeffNegative(false))
- {
- type = TIType(gvn, TIType::EMPTY);
- return true;
- }
+ GVN::Value * ONEValue = gvn.getValue(1.);
+ SymbolicDimension ONE(gvn, ONEValue);
- type = TIType(gvn, TIType::DOUBLE, ONE, SymbolicDimension(gvn, v));
- return true;
+ if (gvnStart->value == gvnEnd->value)
+ {
+ type = TIType(gvn, TIType::DOUBLE, ONE, ONE);
+ return true;
}
- bool SymbolicList::get(AnalysisVisitor & visitor, ast::ListExp & le, SymbolicList & sl)
+ GVN::Value * v;
+ if (dstep == 1)
+ {
+ v = gvn.getValue(OpValue::Kind::MINUS, *gvnEnd, *gvnStart);
+ }
+ else
+ {
+ v = gvn.getValue(OpValue::Kind::MINUS, *gvnStart, *gvnEnd);
+ }
+ v = gvn.getValue(OpValue::Kind::PLUS, *v, *ONEValue);
+ if (v->poly->constant < 0 && v->poly->isCoeffNegative(false))
{
- le.getStart().accept(visitor);
- Result Rstart = visitor.getResult();
- le.getEnd().accept(visitor);
- Result Rend = visitor.getResult();
- le.getStep().accept(visitor);
- Result & Rstep = visitor.getResult();
+ type = TIType(gvn, TIType::EMPTY);
+ return true;
+ }
- double start, step, end;
- if (Rstart.getConstant().getDblValue(start) && Rstep.getConstant().getDblValue(step) && Rend.getConstant().getDblValue(end))
- {
- if (tools::isAnInt(start) && tools::isAnInt(step) && tools::isAnInt(end))
- {
- sl = SymbolicList(start, step, end);
- return true;
- }
- return false;
- }
+ type = TIType(gvn, TIType::DOUBLE, ONE, SymbolicDimension(gvn, v));
+ return true;
+}
- GVN::Value * gvnStart, * gvnStep, * gvnEnd;
- if (Rstart.getConstant().getDblValue(start))
- {
- int64_t _start;
- if (tools::asInteger(start, _start))
- {
- gvnStart = visitor.getGVN().getValue(_start);
- }
- else
- {
- return false;
- }
- }
- else if (GVN::Value * v = Rstart.getConstant().getGVNValue())
- {
- gvnStart = v;
- }
- else
- {
- return false;
- }
+bool SymbolicList::get(AnalysisVisitor & visitor, ast::ListExp & le, SymbolicList & sl)
+{
+ le.getStart().accept(visitor);
+ Result Rstart = visitor.getResult();
+ le.getEnd().accept(visitor);
+ Result Rend = visitor.getResult();
+ le.getStep().accept(visitor);
+ Result & Rstep = visitor.getResult();
- if (Rstep.getConstant().getDblValue(step))
- {
- int64_t _step;
- if (tools::asInteger(step, _step))
- {
- gvnStep = visitor.getGVN().getValue(_step);
- }
- else
- {
- return false;
- }
- }
- else if (GVN::Value * v = Rstep.getConstant().getGVNValue())
- {
- gvnStep = v;
- }
- else
- {
- return false;
- }
+ double start, step, end;
+ if (Rstart.getConstant().getDblValue(start) && Rstep.getConstant().getDblValue(step) && Rend.getConstant().getDblValue(end))
+ {
+ if (tools::isAnInt(start) && tools::isAnInt(step) && tools::isAnInt(end))
+ {
+ sl = SymbolicList(start, step, end);
+ return true;
+ }
+ return false;
+ }
- if (Rend.getConstant().getDblValue(end))
- {
- int64_t _end;
- if (tools::asInteger(end, _end))
- {
- gvnEnd = visitor.getGVN().getValue(_end);
- }
- else
- {
- return false;
- }
- }
- else if (GVN::Value * v = Rend.getConstant().getGVNValue())
- {
- gvnEnd = v;
- }
- else
- {
- return false;
- }
+ GVN::Value * gvnStart, * gvnStep, * gvnEnd;
+ if (Rstart.getConstant().getDblValue(start))
+ {
+ int64_t _start;
+ if (tools::asInteger(start, _start))
+ {
+ gvnStart = visitor.getGVN().getValue(_start);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (GVN::Value * v = Rstart.getConstant().getGVNValue())
+ {
+ gvnStart = v;
+ }
+ else
+ {
+ return false;
+ }
- sl = SymbolicList(gvnStart, gvnStep, gvnEnd);
+ if (Rstep.getConstant().getDblValue(step))
+ {
+ int64_t _step;
+ if (tools::asInteger(step, _step))
+ {
+ gvnStep = visitor.getGVN().getValue(_step);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (GVN::Value * v = Rstep.getConstant().getGVNValue())
+ {
+ gvnStep = v;
+ }
+ else
+ {
+ return false;
+ }
- return true;
+ if (Rend.getConstant().getDblValue(end))
+ {
+ int64_t _end;
+ if (tools::asInteger(end, _end))
+ {
+ gvnEnd = visitor.getGVN().getValue(_end);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (GVN::Value * v = Rend.getConstant().getGVNValue())
+ {
+ gvnEnd = v;
+ }
+ else
+ {
+ return false;
}
- void SymbolicList::evalDollar(GVN & gvn, const GVN::Value * dollarVal)
+ sl = SymbolicList(gvnStart, gvnStep, gvnEnd);
+
+ return true;
+}
+
+void SymbolicList::evalDollar(GVN & gvn, const GVN::Value * dollarVal)
+{
+ if (GVN::Value * const dollar = gvn.getExistingValue(symbol::Symbol(L"$")))
{
- if (GVN::Value * const dollar = gvn.getExistingValue(symbol::Symbol(L"$")))
- {
- if (GVN::Value * v = evalDollar(gvn, getStart(), dollar, dollarVal))
- {
- setStart(v);
- }
+ if (GVN::Value * v = evalDollar(gvn, getStart(), dollar, dollarVal))
+ {
+ setStart(v);
+ }
- if (GVN::Value * v = evalDollar(gvn, getStep(), dollar, dollarVal))
- {
- setStep(v);
- }
+ if (GVN::Value * v = evalDollar(gvn, getStep(), dollar, dollarVal))
+ {
+ setStep(v);
+ }
- if (GVN::Value * v = evalDollar(gvn, getEnd(), dollar, dollarVal))
- {
- setEnd(v);
- }
- }
+ if (GVN::Value * v = evalDollar(gvn, getEnd(), dollar, dollarVal))
+ {
+ setEnd(v);
+ }
}
+}
- bool SymbolicList::checkAsIndex(const GVN::Value * dim)
+bool SymbolicList::checkAsIndex(const GVN::Value * dim)
+{
+ if (symbolic)
{
- if (symbolic)
- {
- if (getStep()->poly->constant > 0 && getStep()->poly->isCoeffPositive(false))
- {
- // step is positive
-
- }
- else if (getStep()->poly->constant < 0 && getStep()->poly->isCoeffNegative(false))
- {
- // step is negative
-
- }
- else
- {
+ if (getStep()->poly->cons