static bool read_string_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo_v1* _pInfo)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    char** pstData = NULL;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);

    _pInfo->iDims = 2;
    _pInfo->piDims[0] = iRows;
    _pInfo->piDims[1] = iCols;

    pstData = (char **)MALLOC(iRows * iCols * sizeof(char *));
    memset(pstData, 0x00, iRows * iCols * sizeof(char *));
    iRet = readStringMatrix_v1(_iDatasetId, iRows, iCols, pstData);

    for (int i = 0 ; i < iRows * iCols ; i++)
    {
        _pInfo->iSize += (int)strlen(pstData[i]) * 4;
        FREE(pstData[i]);
    }

    FREE(pstData);
    //always full double size
    _pInfo->iSize += (8 - (_pInfo->iSize % 8));
    //header + offset
    _pInfo->iSize += 16 + (1 + iRows * iCols) * 4;

    generateInfo_v1(_pInfo, "string");
    return true;
}
static bool read_poly_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo_v1* _pInfo)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iComplex = 0;
    char pstVarName[64] = { 0 };
    double **pdblReal = NULL;
    double **pdblImg = NULL;
    int *piNbCoef = NULL;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    if (iRet)
    {
        return false;
    }

    iComplex = isComplexData_v1(_iDatasetId);

    _pInfo->iDims = 2;
    _pInfo->piDims[0] = iRows;
    _pInfo->piDims[1] = iCols;
    _pInfo->iSize = 8 * 4 + (iRows * iCols + 1) * 4;

    if (iComplex)
    {
        piNbCoef = (int *)MALLOC(iRows * iCols * sizeof(int));
        pdblReal = (double **)MALLOC(iRows * iCols * sizeof(double *));
        pdblImg = (double **)MALLOC(iRows * iCols * sizeof(double *));
        iRet = readPolyComplexMatrix_v1(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
    }
    else
    {
        piNbCoef = (int *)MALLOC(iRows * iCols * sizeof(int));
        pdblReal = (double **)MALLOC(iRows * iCols * sizeof(double *));
        iRet = readPolyMatrix_v1(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal);
    }

    for (int i = 0 ; i < iRows * iCols ; i++)
    {
        _pInfo->iSize += piNbCoef[i] * 8 * (iComplex + 1);
        FREE(pdblReal[i]);
        if (iComplex)
        {
            FREE(pdblImg[i]);
        }
    }

    FREE(piNbCoef);
    FREE(pdblReal);
    if (iComplex)
    {
        FREE(pdblImg);
    }

    generateInfo_v1(_pInfo, "polynomial");
    return true;
}
int getSparseDimension_v1(int _iDatasetId, int *_piRows, int *_piCols, int *_piNbItem)
{
    int iRet = 0;
    int iDummy = 0;

    //get number of item in the sparse matrix
    getDatasetDims_v1(_iDatasetId, _piRows, _piCols);
    *_piNbItem = readIntAttribute_v1(_iDatasetId, g_SCILAB_CLASS_ITEMS);

    return iRet;
}
static int readPoly_v1(int _iDatasetId, int *_piNbCoef, double **_pdblData)
{
    int iRows = 0;
    int iCols = 0;

    //Get the datatype and its size.
    getDatasetDims_v1(_iDatasetId, &iRows, &iCols);

    *_piNbCoef = iRows * iCols;
    *_pdblData = (double *)MALLOC(*_piNbCoef * sizeof(double));

    //Read the data and return result.
    return readDoubleMatrix_v1(_iDatasetId, 1, *_piNbCoef, *_pdblData);
}
static bool import_boolean_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int *piData = NULL;
    int iRows = 0;
    int iCols = 0;
    SciErr sciErr;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    if (iRet)
    {
        return false;
    }

    if (iRows * iCols == 0)
    {
        return false;
    }
    piData = (int *)MALLOC(iRows * iCols * sizeof(int));
    iRet = readBooleanMatrix_v1(_iDatasetId, iRows, iCols, piData);
    if (iRet)
    {
        FREE(piData);
        return false;
    }

    if (_piAddress == NULL)
    {
        sciErr = createNamedMatrixOfBoolean(pvCtx, _pstVarname, iRows, iCols, piData);
    }
    else                        //if not null this variable is in a list
    {
        sciErr = createMatrixOfBooleanInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
    }

    FREE(piData);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

#ifdef PRINT_DEBUG
    char pstMsg[512];

    sprintf(pstMsg, "boolean_%d (%d x %d)", _iItemPos, iRows, iCols);
    print_tree(pstMsg);
#endif
    return true;
}
static bool read_boolean_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo_v1* _pInfo)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);

    _pInfo->iDims = 2;
    _pInfo->piDims[0] = iRows;
    _pInfo->piDims[1] = iCols;
    _pInfo->iSize = (3 + iRows * iCols) * 4;

    generateInfo_v1(_pInfo, "boolean");
    return true;
}
static int readComplexPoly_v1(int _iDatasetId, int *_piNbCoef, double **_pdblReal, double **_pdblImg)
{
    int iRows = 0;
    int iCols = 0;

    //Get the datatype and its size.
    getDatasetDims_v1(_iDatasetId, &iRows, &iCols);

    //Allocate space for string data.
    *_piNbCoef = iRows * iCols;
    *_pdblReal = (double *)MALLOC(*_piNbCoef * sizeof(double));
    *_pdblImg = (double *)MALLOC(*_piNbCoef * sizeof(double));

    //Read the data and return result.
    return readDoubleComplexMatrix_v1(_iDatasetId, 1, *_piNbCoef, *_pdblReal, *_pdblImg);
}
static bool read_integer_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo_v1* _pInfo)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iPrec = 0;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    iRet = getDatasetPrecision_v1(_iDatasetId, &iPrec);

    _pInfo->iDims = 2;
    _pInfo->piDims[0] = iRows;
    _pInfo->piDims[1] = iCols;
    _pInfo->iSize = 16 + iRows * iCols * (iPrec % 10);

    generateInfo_v1(_pInfo, "integer");
    return true;
}
static bool read_double_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, VarInfo_v1* _pInfo)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iComplex = 0;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    iComplex = isComplexData_v1(_iDatasetId);

    _pInfo->iDims = 2;
    _pInfo->piDims[0] = iRows;
    _pInfo->piDims[1] = iCols;
    _pInfo->iSize = (2 + (iRows * iCols * (iComplex + 1))) * 8;

    generateInfo_v1(_pInfo, "constant");
    return true;
}
static bool import_poly_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iComplex = 0;
    char pstVarName[64] = { 0 };
    double **pdblReal = NULL;
    double **pdblImg = NULL;
    int *piNbCoef = NULL;
    SciErr sciErr;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    if (iRet)
    {
        return false;
    }

    iComplex = isComplexData_v1(_iDatasetId);

    if (iComplex)
    {
        piNbCoef = (int *)MALLOC(iRows * iCols * sizeof(int));
        pdblReal = (double **)MALLOC(iRows * iCols * sizeof(double *));
        pdblImg = (double **)MALLOC(iRows * iCols * sizeof(double *));
        iRet = readPolyComplexMatrix_v1(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
    }
    else
    {
        piNbCoef = (int *)MALLOC(iRows * iCols * sizeof(int));
        pdblReal = (double **)MALLOC(iRows * iCols * sizeof(double *));
        iRet = readPolyMatrix_v1(_iDatasetId, pstVarName, iRows, iCols, piNbCoef, pdblReal);
    }

    if (iRet)
    {
        FREE(piNbCoef);
        for (int i = 0; i < iRows * iCols; i++)
        {
            FREE(pdblReal[i]);
        }

        FREE(pdblReal);

        if (iComplex)
        {
            for (int i = 0; i < iRows * iCols; i++)
            {
                FREE(pdblImg[i]);
            }

            FREE(pdblImg);
        }

        return false;
    }

    if (_piAddress == NULL)
    {
        if (iComplex)
        {
            sciErr = createNamedComplexMatrixOfPoly(pvCtx, _pstVarname, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
        }
        else
        {
            sciErr = createNamedMatrixOfPoly(pvCtx, _pstVarname, pstVarName, iRows, iCols, piNbCoef, pdblReal);
        }
    }
    else                        //if not null this variable is in a list
    {
        if (iComplex)
        {
            sciErr =
                createComplexMatrixOfPolyInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, iRows, iCols, piNbCoef, pdblReal,
                        pdblImg);
        }
        else
        {
            sciErr = createMatrixOfPolyInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, pstVarName, iRows, iCols, piNbCoef, pdblReal);
        }
    }

    FREE(piNbCoef);
    for (int i = 0; i < iRows * iCols; i++)
    {
        FREE(pdblReal[i]);
    }

    FREE(pdblReal);

    if (iComplex)
    {
        for (int i = 0; i < iRows * iCols; i++)
        {
            FREE(pdblImg[i]);
        }

        FREE(pdblImg);
    }

    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

#ifdef PRINT_DEBUG
    char pstMsg[512];

    sprintf(pstMsg, "poly_%d (%d x %d)", _iItemPos, iRows, iCols);
    print_tree(pstMsg);
#endif

    return true;
}
static bool import_integer_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iPrec = 0;
    SciErr sciErr;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    if (iRet)
    {
        return false;
    }

    iRet = getDatasetPrecision_v1(_iDatasetId, &iPrec);
    if (iRet)
    {
        return false;
    }

    switch (iPrec)
    {
        case SCI_INT8:
        {
            char *pcData = NULL;

            pcData = (char *)MALLOC(sizeof(char) * iRows * iCols);
            iRet = readInteger8Matrix_v1(_iDatasetId, iRows, iCols, pcData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfInteger8(pvCtx, _pstVarname, iRows, iCols, pcData);
            }
            else
            {
                sciErr = createMatrixOfInteger8InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pcData);
            }

            FREE(pcData);
        }
        break;
        case SCI_UINT8:
        {
            unsigned char *pucData = NULL;

            pucData = (unsigned char *)MALLOC(sizeof(unsigned char) * iRows * iCols);
            iRet = readUnsignedInteger8Matrix_v1(_iDatasetId, iRows, iCols, pucData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfUnsignedInteger8(pvCtx, _pstVarname, iRows, iCols, pucData);
            }
            else
            {
                sciErr = createMatrixOfUnsignedInteger8InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pucData);
            }

            FREE(pucData);
        }
        break;
        case SCI_INT16:
        {
            short *psData = NULL;

            psData = (short *)MALLOC(sizeof(short) * iRows * iCols);
            iRet = readInteger16Matrix_v1(_iDatasetId, iRows, iCols, psData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfInteger16(pvCtx, _pstVarname, iRows, iCols, psData);
            }
            else
            {
                sciErr = createMatrixOfInteger16InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, psData);
            }

            FREE(psData);
        }
        break;
        case SCI_UINT16:
        {
            unsigned short *pusData = NULL;

            pusData = (unsigned short *)MALLOC(sizeof(unsigned short) * iRows * iCols);
            iRet = readUnsignedInteger16Matrix_v1(_iDatasetId, iRows, iCols, pusData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfUnsignedInteger16(pvCtx, _pstVarname, iRows, iCols, pusData);
            }
            else
            {
                sciErr = createMatrixOfUnsignedInteger16InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pusData);
            }

            FREE(pusData);
        }
        break;
        case SCI_INT32:
        {
            int *piData = NULL;

            piData = (int *)MALLOC(sizeof(int) * iRows * iCols);
            iRet = readInteger32Matrix_v1(_iDatasetId, iRows, iCols, piData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfInteger32(pvCtx, _pstVarname, iRows, iCols, piData);
            }
            else
            {
                sciErr = createMatrixOfInteger32InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
            }

            FREE(piData);
        }
        break;
        case SCI_UINT32:
        {
            unsigned int *puiData = NULL;

            puiData = (unsigned int *)MALLOC(sizeof(unsigned int) * iRows * iCols);
            iRet = readUnsignedInteger32Matrix_v1(_iDatasetId, iRows, iCols, puiData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfUnsignedInteger32(pvCtx, _pstVarname, iRows, iCols, puiData);
            }
            else
            {
                sciErr = createMatrixOfUnsignedInteger32InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, puiData);
            }

            FREE(puiData);
        }
        break;
        case SCI_INT64:
        {
#ifdef __SCILAB_INT64__
            long long *pllData = NULL;

            pllData = (long long *)MALLOC(sizeof(long long) * iRows * iCols);
            iRet = readInteger64Matrix_v1(_iDatasetId, iRows, iCols, pllData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfInteger64(pvCtx, _pstVarname, iRows, iCols, pllData);
            }
            else
            {
                sciErr = createMatrixOfInteger64InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pllData);
            }

            FREE(pllData);
#else
            return false;
#endif
        }
        break;
        case SCI_UINT64:
        {
#ifdef __SCILAB_INT64__
            unsigned long long *pullData = NULL;

            pullData = (unsigned long long *)MALLOC(sizeof(unsigned long long) * iRows * iCols);
            iRet = readUnsignedInteger64Matrix_v1(_iDatasetId, iRows, iCols, pullData);
            if (iRet)
            {
                return false;
            }

            if (_piAddress == NULL)
            {
                sciErr = createNamedMatrixOfUnsignedInteger64(pvCtx, _pstVarname, iRows, iCols, pullData);
            }
            else
            {
                sciErr = createMatrixOfUnsignedInteger64InNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pullData);
            }

            FREE(pullData);
#else
            return false;
#endif
        }
        break;
        default:
            return false;
    }

#ifdef PRINT_DEBUG
    char pstMsg[512];

    sprintf(pstMsg, "integer_%d (%d x %d)", _iItemPos, iRows, iCols);
    print_tree(pstMsg);
#endif

    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

    return true;
}
static bool import_string_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int i = 0;
    int iRows = 0;
    int iCols = 0;
    char **pstData = NULL;
    SciErr sciErr;

#ifdef TIME_DEBUG
    LARGE_INTEGER iStart1, iEnd1, iStart2, iEnd2, iStart3, iEnd3, iFreq;

    QueryPerformanceFrequency(&iFreq);
    QueryPerformanceCounter(&iStart1);
#endif
    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    if (iRet)
    {
        return false;
    }

    pstData = (char **)MALLOC(iRows * iCols * sizeof(char *));
    memset(pstData, 0x00, iRows * iCols * sizeof(char *));

#ifdef TIME_DEBUG
    QueryPerformanceCounter(&iStart1);
#endif

    iRet = readStringMatrix_v1(_iDatasetId, iRows, iCols, pstData);
    if (iRet)
    {
        freeArrayOfString(pstData, iRows * iCols);
        return false;
    }

#ifdef TIME_DEBUG
    QueryPerformanceCounter(&iEnd1);
#endif
#ifdef TIME_DEBUG
    QueryPerformanceCounter(&iStart2);
#endif

    if (_piAddress == NULL)
    {
        sciErr = createNamedMatrixOfString(pvCtx, _pstVarname, iRows, iCols, pstData);
    }
    else                        //if not null this variable is in a list
    {
        sciErr = createMatrixOfStringInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pstData);
    }

    freeArrayOfString(pstData, iRows * iCols);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

#ifdef TIME_DEBUG
    QueryPerformanceCounter(&iEnd2);
    QueryPerformanceCounter(&iStart3);
#endif
#ifdef PRINT_DEBUG
    char pstMsg[512];

    sprintf(pstMsg, "string_%d (%d x %d)", _iItemPos, iRows, iCols);
    print_tree(pstMsg);
#endif

#ifdef TIME_DEBUG
    QueryPerformanceCounter(&iEnd3);

    //double dblTime    =((iEnd1.QuadPart - iStart1.QuadPart) * 1000.0) / iFreq.QuadPart;
    //printf("HDF5 : %0.3f ms\n", dblTime);
    //dblTime   =((iEnd2.QuadPart - iStart2.QuadPart) * 1000.0) / iFreq.QuadPart;
    //printf("Stack : %0.3f ms\n", dblTime);
    //dblTime   =((iEnd3.QuadPart - iStart3.QuadPart) * 1000.0) / iFreq.QuadPart;
    //printf("Clear : %0.3f ms\n", dblTime);
    double dblTime = ((iEnd3.QuadPart - iStart1.QuadPart) * 1000.0) / iFreq.QuadPart;

    printf("Total String: %0.3f ms\n\n", dblTime);
#endif
    return true;
}
static bool import_double_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    double *pdblReal = NULL;
    double *pdblImg = NULL;
    int iRows = 0;
    int iCols = 0;
    int iComplex = 0;
    SciErr sciErr;

#ifdef TIME_DEBUG
    LARGE_INTEGER iStart, iEnd, iFreq;

    QueryPerformanceFrequency(&iFreq);
    QueryPerformanceCounter(&iStart);
#endif

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    iComplex = isComplexData_v1(_iDatasetId);
    if (iRet)
    {
        return false;
    }

    if (iRows * iCols != 0)
    {
        if (iComplex)
        {
            pdblReal = (double *)MALLOC(iRows * iCols * sizeof(double));
            pdblImg = (double *)MALLOC(iRows * iCols * sizeof(double));
            iRet = readDoubleComplexMatrix_v1(_iDatasetId, iRows, iCols, pdblReal, pdblImg);
        }
        else
        {
            pdblReal = (double *)MALLOC(iRows * iCols * sizeof(double));
            iRet = readDoubleMatrix_v1(_iDatasetId, iRows, iCols, pdblReal);
        }

        if (iRet)
        {
            FREE(pdblReal);
            if (iComplex)
            {
                FREE(pdblImg);
            }

            return false;
        }
    }
    else
    {
        /*bug 7224 : to close dataset */
        iRet = readEmptyMatrix_v1(_iDatasetId);
        if (iRet)
        {
            return false;
        }

        pdblReal = (double*)MALLOC(sizeof(double) * 1);
        pdblReal[0] = 0;
        iComplex = 0;
    }

    if (_piAddress == NULL)
    {
        if (iComplex)
        {
            sciErr = createNamedComplexMatrixOfDouble(pvCtx, _pstVarname, iRows, iCols, pdblReal, pdblImg);
        }
        else
        {
            sciErr = createNamedMatrixOfDouble(pvCtx, _pstVarname, iRows, iCols, pdblReal);
        }
    }
    else                        //if not null this variable is in a list
    {
        if (iComplex)
        {
            sciErr = createComplexMatrixOfDoubleInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pdblReal, pdblImg);
        }
        else
        {
            sciErr = createMatrixOfDoubleInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, pdblReal);
        }
    }

    FREE(pdblReal);
    if (iComplex)
    {
        FREE(pdblImg);
    }

    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

#ifdef PRINT_DEBUG
    char pstMsg[512];

    sprintf(pstMsg, "double_%d (%d x %d)", _iItemPos, iRows, iCols);
    print_tree(pstMsg);
#endif

#ifdef TIME_DEBUG
    QueryPerformanceCounter(&iEnd);
    double dblTime = ((iEnd.QuadPart - iStart.QuadPart) * 1000.0) / iFreq.QuadPart;

    printf("Total Double : %0.3f ms\n\n", dblTime);
#endif

    return true;
}
static bool import_hypermat_v1(int* pvCtx, int _iDatasetId, int _iVarType, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int iRows = 0;
    int iCols = 0;
    int iItems = 0;
    hobj_ref_t *piItemRef = NULL;

    // an hypermatrix is stored in an mlist
    if (_iVarType != sci_mlist)
    {
        return false;
    }

    iRet = getListDims_v1(_iDatasetId, &iItems);
    if (iRet)
    {
        return false;
    }

    if (iItems != 3)
    {
        // hypermatrix have 3 elements
        return false;
    }

    iRet = getListItemReferences_v1(_iDatasetId, &piItemRef);
    if (iRet)
    {
        return false;
    }

    // get first item
    int iItemDataset = 0;
    iRet = getListItemDataset_v1(_iDatasetId, piItemRef, 0, &iItemDataset);
    if (iRet || iItemDataset == 0)
    {
        return false;
    }

    // get first item type
    int iItemType = getScilabTypeFromDataSet_v1(iItemDataset);
    if (iItemType != sci_strings)
    {
        return false;
    }

    // get size of first item
    iRet = getDatasetDims_v1(iItemDataset, &iRows, &iCols);
    if (iRet < 0)
    {
        return false;
    }

    if (iRows * iCols != 3)
    {
        return false;
    }

    // get data of first item for check the type of mlist
    char** pstData = new char*[iRows * iCols];
    iRet = readStringMatrix_v1(iItemDataset, iRows, iCols, pstData);
    if (iRet || strcmp(pstData[0], "hm") != 0)
    {
        FREE(piItemRef);
        for (int i = 0; i < iRows * iCols; i++)
        {
            FREE(pstData[i]);
        }
        delete[] pstData;
        return false;
    }

    for (int i = 0; i < iRows * iCols; i++)
    {
        FREE(pstData[i]);
    }
    delete[] pstData;
    pstData = NULL;

    // get second item, the Size of hypermatrix
    iRet = getListItemDataset_v1(_iDatasetId, piItemRef, 1, &iItemDataset);
    if (iRet)
    {
        return false;
    }

    iRet = getDatasetDims_v1(iItemDataset, &iRows, &iCols);
    if (iRet < 0)
    {
        return false;
    }

    if (iRows != 1)
    {
        return false;
    }

    int* piDimsArray = new int[iCols];
    iRet = readInteger32Matrix_v1(iItemDataset, iRows, iCols, piDimsArray);
    if (iRet)
    {
        delete[] piDimsArray;
        return false;
    }

    // get third item, the Data of hypermatrix
    // import data like a "type" (Double, Int, ...) instead of mlist
    iRet = getListItemDataset_v1(_iDatasetId, piItemRef, 2, &iItemDataset);
    bool bRet = import_data_v1(pvCtx, iItemDataset, _iItemPos, _piAddress, _pstVarname);
    if (bRet == false)
    {
        delete[] piDimsArray;
        return false;
    }

    // get imported hypermatrix from List or Context
    types::GenericType* pGT = NULL;
    types::InternalType* pIT = NULL;
    if (_piAddress)
    {
        types::List* pL = (types::List*)_piAddress;
        pIT = pL->get(_iItemPos - 1);
    }
    else
    {
        wchar_t* pwcsName = to_wide_string(_pstVarname);
        pIT = symbol::Context::getInstance()->getCurrentLevel(symbol::Symbol(pwcsName));
        FREE(pwcsName);
    }

    // reshape data with size of hypermatrix
    pGT = pIT->getAs<types::GenericType>();
    pGT->reshape(piDimsArray, iCols);

    delete[] piDimsArray;


    iRet = deleteListItemReferences_v1(_iDatasetId, piItemRef);
    if (iRet)
    {
        return false;
    }

    return true;
}