行列サイズの変更

Namespace: FVIL.Data
Assembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)

Syntax

C#
public virtual void Resize(
	int rows,
	int columns
)
Visual Basic
Public Overridable Sub Resize ( 
	rows As Integer,
	columns As Integer
)

Parameters

rows
Type: System..::..Int32
行数 (1~)
columns
Type: System..::..Int32
列数 (1~)

Remarks

現在の行列を指定されたサイズで再確保します。 全ての要素は 0.0 に初期化されます。

確保に失敗した場合は例外を発行します。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。

エラーコード:

ErrorCode メンバ内容
11FVIL.ErrorCode.INVALID_PARAMETER引数に指定された値が不正です。
1FVIL.ErrorCode.FAILED_TO_ALLOCATEメモリの確保に失敗しました。

Examples

ソースコード:
C# Copy imageCopy
//    $Revision: 1.2 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;    // FvPluginXXXX attribute requires fvalgcli

namespace User.SampleCode
{
    public partial class Matrix
    {
        /// <summary>
        /// 行列サイズの変更.
        /// </summary> 
        [FvPluginExecute]
        public void Resize()
        {
            int rows = 3;
            int columns = 3;
            // 1) インスタンスの準備.
            FVIL.Data.CFviMatrix mat = new FVIL.Data.CFviMatrix(rows, columns);

            // 2) 行列の要素の設定.
            mat[0, 0] = 1.0; mat[0, 1] = 3.0; mat[0, 2] = 3.0;
            mat[1, 0] = 4.0; mat[1, 1] = -2.0; mat[1, 2] = 1.0;
            mat[2, 0] = 2.0; mat[2, 1] = 5.0; mat[2, 2] = -1.0;

            // 3) 実行.
            mat.Resize(5, 4);

            // 確認) 処理結果の出力.
            Console.Write("CFviMatrix.Resize -> rows={0}, columns={1}\n",mat.Rows, mat.Columns);
            for (int r = 0; r < mat.Rows; r++)
            {
                for (int c = 0; c < mat.Columns; c++)
                {
                    Console.Write("[{0},{1}]={2} ", r, c, mat[r, c]);
                }
                Console.Write("\n");
            }
            Console.WriteLine("");
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli
' FvPluginXXXX attribute requires fvalgcli
Namespace SampleCode
    Public Partial Class Matrix
        ''' <summary>
        ''' 行列サイズの変更.
        ''' </summary> 
        <FvPluginExecute> _
        Public Sub Resize()
            Dim rows As Integer = 3
            Dim columns As Integer = 3
            ' 1) インスタンスの準備.
            Dim mat As New FVIL.Data.CFviMatrix(rows, columns)

            ' 2) 行列の要素の設定.
            mat(0, 0) = 1.0
            mat(0, 1) = 3.0
            mat(0, 2) = 3.0
            mat(1, 0) = 4.0
            mat(1, 1) = -2.0
            mat(1, 2) = 1.0
            mat(2, 0) = 2.0
            mat(2, 1) = 5.0
            mat(2, 2) = -1.0

            ' 3) 実行.
            mat.Resize(5, 4)

            ' 確認) 処理結果の出力.
            Console.Write("CFviMatrix.Resize -> rows={0}, columns={1}" & vbLf, mat.Rows, mat.Columns)
            For r As Integer = 0 To mat.Rows - 1
                For c As Integer = 0 To mat.Columns - 1
                    Console.Write("[{0},{1}]={2} ", r, c, mat(r, c))
                Next
                Console.Write(vbLf)
            Next
            Console.WriteLine("")
        End Sub
    End Class
End Namespace
【関数の出力】
CFviMatrix.Resize -> rows=5, columns=4
[0,0]=0 [0,1]=0 [0,2]=0 [0,3]=0 
[1,0]=0 [1,1]=0 [1,2]=0 [1,3]=0 
[2,0]=0 [2,1]=0 [2,2]=0 [2,3]=0 
[3,0]=0 [3,1]=0 [3,2]=0 [3,3]=0 
[4,0]=0 [4,1]=0 [4,2]=0 [4,3]=0 
	

Exceptions

ExceptionCondition
FVIL..::..CFviExceptionこの例外の原因については、上記のエラーコード表をご参照ください。

See Also