連立一次方程式の計算

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

Syntax

C#
public virtual CFviVector solve(
	CFviVector vector
)
Visual Basic
Public Overridable Function solve ( 
	vector As CFviVector
) As CFviVector

Parameters

vector
Type: FVIL.Data..::..CFviVector
連立一次方程式の右辺

Return Value

Type: CFviVector
演算結果のベクトルを返します。

Remarks

ax=b をLU分解を使用して解きます。

  • a ... 現在の行列
  • b ... 引数に指定されたベクトル
  • x ... 返されるベクトル
a は NxN 行列(正方行列)、b は次元 N でなければなりません。 a, b の次元が不正な場合は例外を発行します。

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

エラーコード:

ErrorCode メンバ内容
51FVIL.ErrorCode.LICENSE_ERRORライセンスがありません。
1FVIL.ErrorCode.FAILED_TO_ALLOCATEメモリの確保に失敗しました。
11FVIL.ErrorCode.INVALID_PARAMETERパラメータが不正です。
12FVIL.ErrorCode.INVALID_OBJECTメモリが確保されていません。
29FVIL.ErrorCode.NOT_CALCULABLE計算できません。

関連する FIE 関数:

fnFIE_mat_solve

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 solve()
        {
            int rows = 3;
            int columns = 3;
            // 1) インスタンスの準備.
            FVIL.Data.CFviMatrix mat = new FVIL.Data.CFviMatrix(rows, columns);
            FVIL.Data.CFviVector vector = new FVIL.Data.CFviVector(rows);

            // 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;

            vector[0] = 3.0; vector[1] = 6.0; vector[2] = 8.0;

            // 3) 計算実行.
            FVIL.Data.CFviVector result = mat.solve(vector);

            // 確認) 処理結果の出力.
            Console.Write("CFviMatrix.solve\n");
            for (int dim = 0; dim < result.Dim; dim++)
            {
                Console.Write("[{0}]={1} ", dim, result[dim]);
            }
            Console.Write("\n");
        }
    }
}


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 solve()
            Dim rows As Integer = 3
            Dim columns As Integer = 3
            ' 1) インスタンスの準備.
            Dim mat As New FVIL.Data.CFviMatrix(rows, columns)
            Dim vector As New FVIL.Data.CFviVector(rows)

            ' 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

            vector(0) = 3.0
            vector(1) = 6.0
            vector(2) = 8.0

            ' 3) 計算実行.
            Dim result As FVIL.Data.CFviVector = mat.solve(vector)

            ' 確認) 処理結果の出力.
            Console.Write("CFviMatrix.solve" & vbLf)
            For [dim] As Integer = 0 To result.[Dim] - 1
                Console.Write("[{0}]={1} ", [dim], result([dim]))
            Next
            Console.Write(vbLf)
        End Sub
    End Class
End Namespace
【関数の出力】
CFviMatrix.solve
[0]=1.96551724137931 [1]=0.735632183908046 [2]=-0.39080459770115 
	

Exceptions

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

See Also