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 matrices
A = [1 5; 10 20]
B = [2 6; 11 21]
#matrix multiplication
display(*(A,B))

Explanation

  • Lines 2 and 4: We declare and initialize two matrices, A and B.
  • Line 7: We use the * operator to multiply the A and B matrices, and then use display() to print the result.

Free Resources