Scilab 6.0.0
- Scilabヘルプ
- API Scilab
- legacy
- Low level functions
- AssignOutputVariable
- CallOverloadFunction
- CheckInputArgument
- CheckOutputArgument
- ReturnArguments
- 論理値の読み込み (Scilabゲートウェイ)
- 論理値の書き込み (Scilabゲートウェイ)
- 論理値疎行列の読み込み (Scilabゲートウェイ)
- 論理値の疎行列の書き込み (Scilabゲートウェイ)
- 変数の次元を確認 (Scilabゲートウェイ)
- 変数リファレンス (Scilabゲートウェイ)
- 変数の次元 (Scilabゲートウェイ)
- 変数の型 (Scilabゲートウェイ)
- 複素数変数 (Scilabゲートウェイ)
- 行列型 (Scilab ゲートウェイ)
- deleteNamedVariable
- doubleの読み込み (Scilabゲートウェイ)
- doubleの書き込み (Scilabゲートウェイ)
- getNbInputArgument (Scilabゲートウェイ)
- getNbOutputArgument (Scilabゲートウェイ)
- ハンドルの読み込み (Scilab ゲートウェイ)
- ハンドルの書き込み (Scilab ゲートウェイ)
- 整数の精度 (Scilabゲートウェイ)
- 整数の読み込み (Scilab ゲートウェイ)
- 整数の書き込み (Scilabゲートウェイ)
- nbInputArgument (Scilab ゲートウェイ)
- ポインタの読み込み (Scilabゲートウェイ)
- ポインタの書き込み (Scilabゲートウェイ)
- 多項式の記号変数 (Scilabゲートウェイ)
- 多項式の読み込み (Scilabゲートウェイ)
- 多項式の書き込み (Scilabゲートウェイ)
- 疎行列の読み込み (Scilab ゲートウェイ)
- 疎行列の書き込み (Scilab ゲートウェイ)
- 文字列の読み込み (Scilab ゲートウェイ)
- 文字列の書き込み (Scilab ゲートウェイ)
- UpdateStack
Scilabヘルプ >> API Scilab > legacy > Low level functions > 疎行列の読み込み (Scilab ゲートウェイ)
疎行列の読み込み (Scilab ゲートウェイ)
ゲートウェイで疎行列を読み込む方法.
呼び出し手順
入力引数プロファイル:
SciErr getSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal)
SciErr getComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg)
名前指定変数プロファイル:
SciErr readNamedSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal)
SciErr readNamedComplexSparseMatrix(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg)
引数
- _pvCtx
Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.
- _piAddress
Scilab変数のアドレス.
- _pstName
"名前指定"関数の場合の変数名.
- _piRows
返される行数.
- _piCols
返される列数.
- _piNbItem
返される非ゼロ値の数.
- _piNbItemRow
返される各行の要素数 (大きさ: _iRows).
- _piColPos
返される各要素の列方向の位置 (大きさ: _iNbItem).
- _pdblReal
返される実部データ配列のアドレス (大きさ: _iCols * _iRows) "名前指定" 関数の場合, _pdblReal は 関数コール前にメモリを確保する必要があります.
- _pdblImg
返される虚部データ配列のアドレス (大きさ: _iCols * _iRows) "名前指定" 関数の場合, _pdblImg は 関数コール前にメモリを確保する必要があります.
- SciErr
エラー構造体で,エラーメッセージ履歴と最初のエラー番号を格納します.
説明
このヘルプはScilab APIにより疎行列を処理する方法を示します.
ゲートウェイのソース
#include "api_scilab.h" int read_sparse(char *fname,void* pvApiCtx) { SciErr sciErr; int i,j,k; int* piAddr = NULL; int iRows = 0; int iCols = 0; int iNbItem = 0; int* piNbItemRow = NULL; int* piColPos = NULL; double* pdblReal = NULL; double* pdblImg = NULL; CheckInputArgument(pvApiCtx, 1, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } if(isVarComplex(pvApiCtx, piAddr)) { sciErr = getComplexSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg); } else { sciErr = getSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal); } if(sciErr.iErr) { printError(&sciErr, 0); return 0; } sciprint("Sparse %d item(s)\n", iNbItem); k = 0; for(i = 0 ; i < iRows ; i++) { for(j = 0 ; j < piNbItemRow[i] ; j++) { sciprint("(%d,%d) = %f", i+1, piColPos[k], pdblReal[k]); if(isVarComplex(pvApiCtx, piAddr)) { sciprint(" %+fi", pdblImg[k]); } sciprint("\n"); k++; } } //assign allocated variables to Lhs position AssignOutputVariable(pvApiCtx, 1) = 0; return 0; }
Scilab テストスクリプト
sp=sparse([1,2;4,5;3,10],[1 + 2*%i,2 - 3*%i,-3 + 4*%i]); read_sparse(sp);
Comments
Add a comment:
Please login to comment this page.