What is matrix multiplication in Julia?
Overview
In Julia, we can do matrix multiplication on two variables with a Matrix data type. We can use the asterisk (*) operator for this purpose.
Syntax
Here is how we can use matrix multiplication.
*(A, B)
Parameters
A and B are matrices.
Return value
The above code line returns the resultant matrix after multiplying matrices A and B.
Example
Let's take a look at an example.
#given two matricesA = [1 5; 10 20]B = [2 6; 11 21]#matrix multiplicationdisplay(*(A,B))
Explanation
- Lines 2 and 4: We declare and initialize two matrices,
AandB. - Line 7: We use the
*operator to multiply theAandBmatrices, and then usedisplay()to print the result.