<?xml version="1.0" encoding="utf-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2013  - Scilab Enterprises - Calixte DENIZET
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getHypermatOfDouble" xml:lang="ja">
    <refnamediv>
        <refname>getHypermatOfDouble</refname>
        <refpurpose>
            double変数のハイパー行列を取得.
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>呼び出し手順</title>
        <synopsis>SciErr getHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double* _pdblReal)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>引数</title>
        <variablelist>
            <varlistentry>
                <term>_pvCtx</term>
                <listitem>
                    <para>
                        Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>_piAddress</term>
                <listitem>
                    <para>
                        Scilab 変数のアドレス.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>_dims</term>
                <listitem>
                    <para>
                        ハイパー行列の次元
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>_ndims</term>
                <listitem>
                    <para>
                        次元の数.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>_pdblReal</term>
                <listitem>
                    <para>
                        double値.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>戻り値</title>
        <para>SciErr構造体, フィールド iErr は
            エラー番号を保持します (エラーがない場合は 0).
        </para>
    </refsection>
    <refsection>
        <title>ゲートウェイのソース</title>
        <programlisting role="code_gateway">
            <![CDATA[
#include "api_scilab.h"

int hypermatExample(char *fname, void* pvApiCtx)
{
    SciErr sciErr;
    int* piAddr = NULL;
    int iType   = 0;
    int iRet    = 0;
    CheckInputArgument(pvApiCtx, 1, 1);
    CheckOutputArgument(pvApiCtx, 0, 1);
    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }
    if (isEmptyMatrix(pvApiCtx, piAddr))
    {
        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
        if (iRet)
        {
            return iRet;
        }
        AssignOutputVariable(pvApiCtx, 1) = 0;
    }
    else if (isHypermatType(pvApiCtx, piAddr))
    {
        int * dims = NULL;
        int ndims;
        double* pdblReal = NULL;
        double* pdblImg = NULL;
        if (isHypermatComplex(pvApiCtx, piAddr))
        {
            sciErr = getComplexHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal, &pdblImg);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                return sciErr.iErr;
            }
            sciErr = createComplexHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal, pdblImg);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                return sciErr.iErr;
            }
        }
        else
        {
            sciErr = getHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                return sciErr.iErr;
            }
            sciErr = createHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                return sciErr.iErr;
            }
        }
        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
    }
    return 0;
}]]>
        </programlisting>
    </refsection>
    <refsection>
        <title>Scilab テストスクリプト</title>
        <programlisting role="code_scilab"><![CDATA[
a = matrix(ones(1,6), [1 2 3]);
b = a + %i*matrix(1:6, [1 2 3]);

hypermatExample(a) == a
hypermatExample(b) == b
 ]]></programlisting>
    </refsection>
</refentry>
