matrixMultiply: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Killzone Kid (talk | contribs) (format) |
||
Line 13: | Line 13: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | Returns resulting matrix from 2 matrix multiplication. 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.|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>[[2],[2]] [[matrixMultiply]] [ [3] ]/ | |x1= <code>[ | ||
|x2= <code>[[-1,0,0], [0,-1,0] | [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= | |mp= - |Multiplayer Behaviour= | ||
| |See Also= | | [[matrixTranspose]] |See Also= | ||
}} | }} | ||
Revision as of 14:16, 31 October 2019
Description
- Description:
- Returns resulting matrix from 2 matrix multiplication. 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.
- Multiplayer:
- -
- Groups:
- Uncategorised
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:
- matrixTranspose
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]]