matrixMultiply: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{Wikipedia *\| *([a-zA-Z0-9_#]+) *\| *([a-zA-Z0-9_ #]+) *\}\}" to "{{Link|https://en.wikipedia.org/$1|$2}}")
m (Text replacement - "Link\|https:\/\/en\.wikipedia\.org\/([^w][^i])" to "Link|https://en.wikipedia.org/wiki/$1")
Line 8: Line 8:


|descr= [[Image:matrixMultiply.jpg|right|600px]]
|descr= [[Image:matrixMultiply.jpg|right|600px]]
Returns resulting matrix from the {{Link|https://en.wikipedia.org/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 {{hl|columns}} matrix1 == {{hl|rows}} matrix2. The resulting matrix will be of the size n × m. If the shapes do not match, empty array [] will be returned.
Returns resulting matrix from the {{Link|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 {{hl|columns}} matrix1 == {{hl|rows}} matrix2. The resulting matrix will be of the size n × m. If the shapes do not match, empty array [] will be returned.


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

Revision as of 22:11, 23 February 2023

Hover & click on the images for description

Description

Description:
matrixMultiply.jpg
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.
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:
matrixTranspose vectorAdd vectorMagnitude vectorNormalized vectorMultiply vectorDotProduct vectorCrossProduct vectorDistance vectorLinearConversion vectorCos vectorFromTo vectorModelToWorld vectorWorldToModel BIS_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
oOKexOo - c
Posted on Jun 30, 2019 - 03:53 (UTC)
Note that this command won't automatically transform a 1D array 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]]