Homework 1: Hadamard, Kronecker and Khatro-Rao Products Product
Homework 1: Hadamard, Kronecker and Khatro-Rao Products Product
Homework 1:
Hadamard, Kronecker and Khatro-Rao products
Fortaleza - 2019
Contents
1 Problem 1 2
2 Problem 2 2
3 Problem 3 3
1 Problem 1
In the first problem we are asked to implement a function in MATLAB that allows us
to calculate the Hadamard product of two matrices A ∈ CN×N and B ∈ CN×N , named
hadamard prod( ), that are randomly generated using the function randn( ).
Our Hadamard function consists in going through two for loops while multiplying
the respective elements of A and B. In the sequence, we compare this function with
the MATLAB operator .*, by plotting their execution time curves as a function of N ∈
{2, 4, 8, 16, 32, 64, 128}.
The resulting curves are presented below:
Figure 1: Results.
2 Problem 2
In this problem we have implemented a function, in MATLAB, in order to compute
the Kronecker product of two matrices A ∈ CN×N and B ∈ CN×N , named kron prod().
It consists in going through the elements of A and multiply each of them by the matrix
B and store the result in a block matrix.
We have compared its performance with the MATLAB function kron( ) by plotting
their execution time curves as a function of N ∈ {2, 4, 8, 16, 32, 64, 128}.
2
The resulting curves are presented below:
Figure 2: Results.
Similarly to what was observed in the previous section, we obtain better results using
the MATLAB function. It can be also seen that the execution time increases exponentially
if we increase the parameter N.
3 Problem 3
Here out task was to implement a function, in MATLAB, that allows us to calculate
the Khatri-Rao product of two matrices A and B, named khatri prod( ). It consisted in
going through the respective columns of A and B and apply the kron prod( ) function.