matrixMultiply: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " " to " ")
m (Text replacement - " \| *(game[0-9]|version[0-9]|gr[0-9]|serverExec|mp|pr|descr|s[0-9]|p[0-9]{1,3}|r[0-9]|x1?[0-9]|seealso) *= +" to " |$1= ")
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma3
|game1= arma3
 
|version1= 1.92
|1.92
 
|arg=
 
|eff=
 
|serverExec=


|gr1= Math
|gr1= Math
|gr2= Math - Vectors
|gr2= Math - Vectors


| Returns resulting matrix from the [https://en.wikipedia.org/wiki/Matrix_multiplication multiplication] of two matrices. First matrix must be of the size n ✕ '''k''', while the second must be of the size '''k''' ✕ m, i.e <tt>columns</tt> matrix1 <nowiki>==</nowiki> <tt>rows</tt> matrix2. The resulting matrix will be of the size n ✕ m. If the shapes do not match, empty array [] will be returned.<br><br>
|descr= Returns resulting matrix from the {{Wikipedia|Matrix_multiplication|multiplication}} of two matrices. First matrix must be of the size n ✕ '''k''', while the second must be of the size '''k''' ✕ m, i.e <tt>columns</tt> matrix1 <nowiki>==</nowiki> <tt>rows</tt> matrix2. The resulting matrix will be of the size n ✕ m. If the shapes do not match, empty array [] will be returned.<br><br>
[[Image:matrixMultiply.jpg|600px]]
[[Image:matrixMultiply.jpg|600px]]


| matrix1 [[matrixMultiply]] matrix2
|s1= matrix1 [[matrixMultiply]] matrix2


|p1=matrix1: [[Array]] - matrix of the size <tt>n</tt>''(rows)'' ✕ <tt>k</tt>''(columns)''
|p1=matrix1: [[Array]] - matrix of the size <tt>n</tt>''(rows)'' ✕ <tt>k</tt>''(columns)''
Line 23: Line 16:
|p2=matrix2: [[Array]] - matrix of the size <tt>k</tt>''(rows)'' ✕ <tt>m</tt>''(columns)''
|p2=matrix2: [[Array]] - matrix of the size <tt>k</tt>''(rows)'' ✕ <tt>m</tt>''(columns)''


| [[Array]] - resulting matrix of the size <tt>n</tt>''(rows)'' ✕ <tt>m</tt>''(columns)''
|r1= [[Array]] - resulting matrix of the size <tt>n</tt>''(rows)'' ✕ <tt>m</tt>''(columns)''


|x1= <code>[
|x1= <code>[
Line 54: Line 47:
] */</code>
] */</code>


| [[matrixTranspose]], [[vectorAdd]], [[vectorMagnitude]], [[vectorNormalized]], [[vectorMultiply]], [[vectorDotProduct]], [[vectorCrossProduct]], [[vectorDistance]], [[vectorLinearConversion]], [[vectorCos]], [[vectorFromTo]], [[vectorModelToWorld]], [[vectorWorldToModel]], [[BIS_fnc_transformVectorDirAndUp]]
|seealso= [[matrixTranspose]], [[vectorAdd]], [[vectorMagnitude]], [[vectorNormalized]], [[vectorMultiply]], [[vectorDotProduct]], [[vectorCrossProduct]], [[vectorDistance]], [[vectorLinearConversion]], [[vectorCos]], [[vectorFromTo]], [[vectorModelToWorld]], [[vectorWorldToModel]], [[BIS_fnc_transformVectorDirAndUp]]
}}
}}


<dl class="command_description">
<dl class="command_description">
<!-- BEGIN Note Section -->
 
<dt></dt>
<dd class="notedate">Posted on 30 Jun, 2019</dd>
<dd class="notedate">Posted on 30 Jun, 2019</dd>
<dt class="note">[[User:oOKexOo| oOKexOo]]<dd class="note">
<dt class="note">[[User:oOKexOo| oOKexOo]]</dt>
<dd class="note">
Note that this command won't transform a 1D array automatically into a column vector
Note that this command won't transform a 1D array automatically into a column vector
<code>
<code>[[-1,0,0],[0,-1,0],[0,0,-1]] [[matrixMultiply]] [1,2,3] // wrong, syntax error
[[-1,0,0],[0,-1,0],[0,0,-1]] [[matrixMultiply]] [1,2,3] // wrong, syntax error
[[-1,0,0],[0,-1,0],[0,0,-1]] [[matrixMultiply]] &#91;[1,2,3]] // wrong, will return []
[[-1,0,0],[0,-1,0],[0,0,-1]] [[matrixMultiply]] &#91;[1,2,3]] // wrong, will return []
[[-1,0,0],[0,-1,0],[0,0,-1]] [[matrixMultiply]] [[1], [2], [3]] // correct, will return [[-1], [-2], [-3]]
[[-1,0,0],[0,-1,0],[0,0,-1]] [[matrixMultiply]] [[1], [2], [3]] // correct, will return [[-1], [-2], [-3]]
</code>
</code>
<!-- END Note Section -->
</dl>
</dl>
{{GameCategory|arma3|Scripting Commands}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Revision as of 23:20, 19 June 2021

Hover & click on the images for description

Description

Description:
Returns resulting matrix from the multiplication of two matrices. First matrix must be of the size n ✕ k, while the second must be of the size k ✕ m, i.e columns matrix1 == rows matrix2. The resulting matrix will be of the size n ✕ m. If the shapes do not match, empty array [] will be returned.

matrixMultiply.jpg
Groups:
MathMath - Vectors

Syntax

Syntax:
matrix1 matrixMultiply matrix2
Parameters:
matrix1: Array - matrix of the size n(rows)k(columns)
matrix2: Array - matrix of the size k(rows)m(columns)
Return Value:
Array - resulting matrix of the size n(rows)m(columns)

Examples

Example 1:
[ [2], [2] ] matrixMultiply [ [3] ] /* returns [ [6], [6] ] */
Example 2:
[ [-1,0,0], [0,-1,0] ] matrixMultiply [ [1,2], [3,1], [2,3] ] /* returns [ [-1,-2], [-3,-1] ] */

Additional Information

See also:
matrixTransposevectorAddvectorMagnitudevectorNormalizedvectorMultiplyvectorDotProductvectorCrossProductvectorDistancevectorLinearConversionvectorCosvectorFromTovectorModelToWorldvectorWorldToModelBIS_fnc_transformVectorDirAndUp

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Posted on 30 Jun, 2019
oOKexOo
Note that this command won't transform a 1D array automatically into a column vector [[-1,0,0],[0,-1,0],[0,0,-1]] matrixMultiply [1,2,3] // wrong, syntax error [[-1,0,0],[0,-1,0],[0,0,-1]] matrixMultiply [[1,2,3]] // wrong, will return [] [[-1,0,0],[0,-1,0],[0,0,-1]] matrixMultiply [[1], [2], [3]] // correct, will return [[-1], [-2], [-3]]