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

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

Please note that the recommended version of Scilab is 2024.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 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);
Report an issue
<< ReturnArguments Low level functions 疎行列の書き込み (Scilab ゲートウェイ) >>

Copyright (c) 2022-2023 (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:
Tue Feb 14 15:10:43 CET 2017