Matrix multiplication: Difference between revisions
Content added Content deleted
(→{{header|ZPL}}: Added zkl) |
|||
Line 2,054:
=={{header|Mathematica}}==
<lang mathematica>M1 = {{1, 2},▼
The Wolfram Language supports both dot products and element-wise multiplication of matrices.
This computes a dot product:
<lang mathematica>{{1, 2}, {3, 4}, {5, 6}, {7, 8}}.{{1, 2, 3}, {4, 5, 6}}</lang>▼
<lang mathematica>Dot[{{a, b}, {c, d}}, {{w, x}, {y, z}}]</lang>
<lang mathematica>{{9, 12, 15}, {19, 26, 33}, {29, 40, 51}, {39, 54, 69}}</lang>▼
This also computes a dot product, using the infix . notation:
This does element-wise multiplication of matrices:
<lang mathematica>Times[{{a, b}, {c, d}}, {{w, x}, {y, z}}]</lang>
With the following infix notations '*' and ' ' (space):
In all cases matrices can be fully symbolic or numeric or mixed symbolic and numeric.
Numeric matrices support arbitrary numerical magnitudes, arbitrary precision as well
as complex numbers.
=={{header|MATLAB}} / {{header|Octave }}==
|