0% found this document useful (0 votes)
46 views

Homework 1: Hadamard, Kronecker and Khatro-Rao Products Product

This document appears to be a homework assignment on tensor algebra from a post-graduate program in telecommunications engineering. It includes 3 problems involving matrix operations: 1) implementing and comparing Hadamard products using a custom function and MATLAB's built-in operator, 2) implementing and comparing Kronecker products using a custom function and MATLAB's kron, and 3) implementing a Khatri-Rao product function. For each problem, execution time curves are plotted and show an exponential increase in time with matrix dimension for all approaches, with MATLAB's built-ins performing better.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Homework 1: Hadamard, Kronecker and Khatro-Rao Products Product

This document appears to be a homework assignment on tensor algebra from a post-graduate program in telecommunications engineering. It includes 3 problems involving matrix operations: 1) implementing and comparing Hadamard products using a custom function and MATLAB's built-in operator, 2) implementing and comparing Kronecker products using a custom function and MATLAB's kron, and 3) implementing a Khatri-Rao product function. For each problem, execution time curves are plotted and show an exponential increase in time with matrix dimension for all approaches, with MATLAB's built-ins performing better.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Universidade Federal do Ceará

Programa de Pós-graduação do Departamento de Engenharia de


Teleinformática

Homework 1:
Hadamard, Kronecker and Khatro-Rao products

Student: Michel Gonzaga dos Santos - 504504


Subject: Tensor Algebra
Professors: André Lima Ferrer de Almeida
Maryam Dehgan
Data: 14/12/2020

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:

(a) Results using hadamard prod( ). (b) Results using .* .

(c) Functions comparison.

Figure 1: Results.

As it can be seen, for both functions, if we increase matrices dimension, N, the


execution time increases according to an exponential behavior. We may notice, that we
have better results using the MATLAB operator, probably due to the way this function
was implemented.

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:

(a) Results using kron prod()( ). (b) Results using kron( ).

(c) Functions comparison.

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.

You might also like