加算オペレータ(行列+行列
Namespace: FVIL.DataAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
public static CFviMatrix operator +( CFviMatrix ope1, CFviMatrix ope2 ) |
Visual Basic |
---|
Public Shared Operator + ( ope1 As CFviMatrix, ope2 As CFviMatrix ) As CFviMatrix |
Return Value
Type: CFviMatrix左辺値(行列)と右辺値(行列)を加算した結果を返します。 行列数が一致している必要があります。
Remarks
処理に失敗した場合は例外を発行します。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。
エラーコード:
値 | ErrorCode メンバ | 内容 |
---|---|---|
51 | FVIL.ErrorCode.LICENSE_ERROR | ライセンスがありません。 |
1 | FVIL.ErrorCode.FAILED_TO_ALLOCATE | メモリの確保に失敗しました。 |
11 | FVIL.ErrorCode.INVALID_PARAMETER | パラメータが不正です。 |
12 | FVIL.ErrorCode.INVALID_OBJECT | メモリが確保されていません。 |
29 | FVIL.ErrorCode.NOT_CALCULABLE | 計算できません。 |
Examples
ソースコード:
【関数の出力】
C# | Copy |
---|---|
// $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 Addition_mm() { int rows = 2; int columns = 3; // 1) インスタンスの準備. FVIL.Data.CFviMatrix mat1 = new FVIL.Data.CFviMatrix(rows, columns); FVIL.Data.CFviMatrix mat2 = new FVIL.Data.CFviMatrix(rows, columns); // 2) 行列の要素の設定. mat1[0, 0] = 1.0; mat1[0, 1] = 3.0; mat1[0, 2] = 3.0; mat1[1, 0] = 4.0; mat1[1, 1] =-2.0; mat1[1, 2] = 1.0; mat2[0, 0] = 3.0; mat2[0, 1] = 8.0; mat2[0, 2] = 1.0; mat2[1, 0] = 0.0; mat2[1, 1] =-2.0; mat2[1, 2] = 5.0; // 3) 計算実行. FVIL.Data.CFviMatrix result = mat1 + mat2; // 確認) 処理結果の出力. Console.Write("CFviMatrix.Addition(matrix+matrix)\n"); for (int row = 0; row < result.Rows; row++) { for (int column = 0; column < result.Columns; column++) { Console.Write("[{0}][{1}]={2} ", row, column, result[row, column]); } Console.Write("\n"); } } } } |
Visual Basic | Copy |
---|---|
' $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 Addition_mm() Dim rows As Integer = 2 Dim columns As Integer = 3 ' 1) インスタンスの準備. Dim mat1 As New FVIL.Data.CFviMatrix(rows, columns) Dim mat2 As New FVIL.Data.CFviMatrix(rows, columns) ' 2) 行列の要素の設定. mat1(0, 0) = 1.0 mat1(0, 1) = 3.0 mat1(0, 2) = 3.0 mat1(1, 0) = 4.0 mat1(1, 1) = -2.0 mat1(1, 2) = 1.0 mat2(0, 0) = 3.0 mat2(0, 1) = 8.0 mat2(0, 2) = 1.0 mat2(1, 0) = 0.0 mat2(1, 1) = -2.0 mat2(1, 2) = 5.0 ' 3) 計算実行. Dim result As FVIL.Data.CFviMatrix = mat1 + mat2 ' 確認) 処理結果の出力. Console.Write("CFviMatrix.Addition(matrix+matrix)" & vbLf) For row As Integer = 0 To result.Rows - 1 For column As Integer = 0 To result.Columns - 1 Console.Write("[{0}][{1}]={2} ", row, column, result(row, column)) Next Console.Write(vbLf) Next End Sub End Class End Namespace |
CFviMatrix.Addition(matrix+matrix) [0][0]=4 [0][1]=11 [0][2]=4 [1][0]=4 [1][1]=-4 [1][2]=6
Exceptions
Exception | Condition |
---|---|
FVIL..::..CFviException | この例外の原因については、上記のエラーコード表をご参照ください。 |