MatMul
行列とベクトルの乗算を可能にするMatMulメソッドには、いくつかのオーバーロードがあります。
Multiplying a matrix by a matrix: matrix[M][K] * matrix[K][N] = matrix[M][N]
matrix matrix::MatMul(
|
Multiplying a vector by a matrix: horizontal vector[K] * matrix[K][N] = horizontal vector[N]
vector vector::MatMul(
|
Multiplying a matrix by a vector: matrix[M][K] * vertical vector[K] = vertical vector[M]
vector matrix::MatMul(
|
Scalar vector multiplication: horizontal vector * vertical vector = dot value
scalar vector::MatMul(
|
パラメータ
b
[in] 行列/ベクトル
戻り値
使用するメソッドに応じて、行列、ベクトル、またはスカラー。
注意事項
行列は乗算に対応している必要があります。つまり、1番目の行列の列数は2番目の行列の行数と等しくなければなりません。行列の乗算は可換ではありません。一般に、1番目の行列に2番目の行列を掛けた結果は、2番目の行列に最初の行列を掛けた結果と等しくありません。
行列積は、最初の行列の行ベクトルと 2 番目の行列の列ベクトルのスカラー積のすべての可能な組み合わせで構成されます。
スカラー乗算では、ベクトルは同じ長さでなければなりません。
ベクトルと行列を乗算する場合、ベクトルの長さは行列の列数と正確に一致する必要があります。
次は、MQL5での単純な行列乗算アルゴリズムです。
matrix MatrixProduct(const matrix& matrix_a, const matrix& matrix_b)
|
行列乗算例
matrix a={{1, 0, 0},
|
水平ベクトルに行列を乗算する例
//+------------------------------------------------------------------+
|
An example of how to multiply a matrix by a vertical vector
//+------------------------------------------------------------------+
|
ベクトルのスカラー(ドット)積の例
void OnStart()
|
参照