matrixMultiply: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(WIP - someone who has knowledge of this please write more information)
 
mNo edit summary
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|=
{{Command|Comments=
____________________________________________________________________________________________
____________________________________________________________________________________________


| arma3 |Game=
| arma3 |Game=


|1.92|Game Version =(number surrounded by NO SPACES)
|1.92|Game Version =


|arg=  |Multiplayer Arguments =("local" or "global")
|arg=  |Multiplayer Arguments =


|eff=  |Multiplayer Effects =("local" or "global")
|eff=  |Multiplayer Effects =


|exec=  |Multiplayer Execution =("server" or empty)
|serverExec=  |Multiplayer Execution ("server" or empty)=
 
|gr1= Math |=GROUP1
|gr2= Vectors |=GROUP2
____________________________________________________________________________________________
____________________________________________________________________________________________


| Resulting matrix of matrix multiplication{{wip}} |Description=
| 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>
[[Image:matrixMultiply.jpg|600px]]|Description=
____________________________________________________________________________________________
____________________________________________________________________________________________


| matrix1 [[matrixMultiply]] matrix2 |Syntax=
| matrix1 [[matrixMultiply]] matrix2 |Syntax=


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


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


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


|x1= <code></code> |Example 1=
|x1= <code>[
[2],
[2]
]
[[matrixMultiply]]
[
[3]
]
/* returns
[
[6],
[6]
] */</code> |Example 1=
|x2= <code>[
[-1,0,0],
[0,-1,0]
]
[[matrixMultiply]]
[
[1,2],
[3,1],
[2,3]
]
/* returns
[
[-1,-2],
[-3,-1]
] */</code> |Example 2=
____________________________________________________________________________________________
____________________________________________________________________________________________


|mp= - |Multiplayer Behaviour=
[[matrixTranspose]], [[vectorAdd]], [[vectorMagnitude]], [[vectorNormalized]], [[vectorMultiply]], [[vectorDotProduct]], [[vectorCrossProduct]], [[vectorDistance]], [[vectorLinearConversion]], [[vectorCos]], [[vectorFromTo]], [[vectorModelToWorld]], [[vectorWorldToModel]], [[BIS_fnc_transformVectorDirAndUp]] |See Also=
 
|  |See Also=
}}
}}


<dl class="command_description">
<dl class="command_description">
<!-- BEGIN Note Section -->
<!-- BEGIN Note Section -->
<!-- For example:
<dd class="notedate">Posted on 30 Jun, 2019
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
<dt class="note">[[User:oOKexOo| oOKexOo]]<dd class="note">
<dt class="note">'''[[User:User Name|User Name]]'''</dt>
Note that this command won't transform a 1D array automatically into a column vector
<dd class="note">This is an example note. It is true and verifiable, and contains a little code snippet.
<code>
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
[[-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]] [[1], [2], [3]] // correct, will return [[-1], [-2], [-3]]
</code>
<!-- END Note Section -->
<!-- END Note Section -->
</dl>
</dl>

Revision as of 17:11, 15 September 2020

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:
MathVectors

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]]

Bottom Section