Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.1 - 日本語

Scilab 6.0.1
Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Scilabヘルプ >> API Scilab > legacy > Low level functions > 整数の精度 (Scilabゲートウェイ)

整数の精度 (Scilabゲートウェイ)

整数行列の精度を取得する方法.

呼び出し手順

SciErr getMatrixOfIntegerPrecision(void* _pvCtx, int* _piAddress, int* _piPrecision)
SciErr getNamedMatrixOfIntegerPrecision(void* _pvCtx, const char* _pstName, int* _piPrecision)

引数

_pvCtx

Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.

_piAddress

変数のアドレス.

_pstName

"名前指定"関数の場合の変数名.

_piPrecision

返される整数変数の精度. ( SCI_INT8, SCI_UINT8, SCI_INT16, ... )

SciErr

エラー構造体で,エラーメッセージ履歴と最初のエラー番号を格納します.

説明

このヘルプは整数行列の精度を取得する方法を示します.

ゲートウェイのソース

#include "api_scilab.h"
SciErr printf_info(int _iVar);
int common_function(char *fname,void* pvApiCtx)
{
    SciErr sciErr;
    int i;
    int *piAddr1    = NULL;
    int iBool       = 0;
    for(i = 0 ; i < nbInputArgument(pvApiCtx) ; i++)
    {
        sciErr = printf_info(i + 1);
        if(sciErr.iErr)
        {
            printError(&sciErr, 0);
            break;
        }
        sciprint("\n\n");
    }
    // trueの場合は1, それ以外は 0
    iBool = sciErr.iErr == 0 ? 1 : 0;
    sciErr = createMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 1, 1, &iBool);
    if(sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }
    // 確保された変数を左辺に代入
    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
    return 0;
}
SciErr printf_info(int _iVar)
{
    SciErr sciErr;
    int* piAddr     = NULL;
    int iType       = 0;
    int iRows       = 0;
    int iCols       = 0;
    int iItem       = 0;
    int iComplex    = 0;
    sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddr);
    if(sciErr.iErr)
    {
        return sciErr;
    }
    sciprint("Variable %d information:\n", _iVar);
    sciErr = getVarType(pvApiCtx, piAddr, &iType);
    if(sciErr.iErr)
    {
        return sciErr;
    }
    sciprint("\tType: ");
    switch(iType)
    {
        case sci_matrix :
            sciprint("double\n");
            break;
        case sci_poly :
            sciprint("polynomial\n");
            break;
        case sci_boolean :
            sciprint("boolean\n");
            break;
        case sci_sparse :
            sciprint("sparse\n");
            break;
        case sci_boolean_sparse :
            sciprint("boolean_sparse\n");
            break;
        case sci_ints :
        {
            char pstSigned[]    = "signed";
            char pstUnsigned[]  = "unsigned";
            char* pstSign       = pstSigned;
            int iPrec           = 0;
            sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr, &iPrec);
            if(sciErr.iErr)
            {
                return sciErr;
            }
            if(iPrec > 10)
            {
                pstSign = pstUnsigned;
            }
            sciprint("%s integer %d bits\n", pstSign, (iPrec % 10) * 8);
        }
        break;
        case sci_strings :
            sciprint("strings\n");
            break;
        case sci_list :
            sciprint("list\n");
            break;
        case sci_tlist :
            sciprint("tlist\n");
            break;
        case sci_mlist :
            sciprint("mlist\n");
            break;
        default :
            sciprint("Not manage by this function\n");
            return sciErr;
    }
    if(isVarComplex(pvApiCtx, piAddr))
    {
        sciprint("\tComplex: Yes\n");
    }
    sciprint("\tDimensions: ");
    if(isVarMatrixType(pvApiCtx, piAddr))
    {
        sciErr = getVarDimension(pvApiCtx, piAddr, &iRows, &iCols);
        if(sciErr.iErr)
        {
            return sciErr;
        }
        sciprint("%d x %d", iRows, iCols);
    }
    else
    {
        sciErr = getListItemNumber(pvApiCtx, piAddr, &iItem);
        if(sciErr.iErr)
        {
            return sciErr;
        }
        sciprint("%d", iItem);
    }
    return sciErr;
}

Scilabテストスクリプト

l1 = [1,2*%i,3;%i,2,3*%i];
l2 = ["may","the";"puffin","be";"with","you"];
l3 = int8([1,2,3]);
l4 = uint16([1000,2000,3000]);
l5 = list(l1,l2,l3);
l = list(l1,l2,l3,l4,l5);
common_function(l(1:$))
Report an issue
<< ハンドルの書き込み (Scilab ゲートウェイ) Low level functions 整数の読み込み (Scilab ゲートウェイ) >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Feb 12 23:12:44 CET 2018