Is there a way to improve this basic level multiplication?

Hi all,
I am trying to reduce the computational time of my programme. And I have seen that right now the biggest computational cost is spent on the computation of the matrix T. Here k is a complex number, nodes and point are large matrix. And basically what I'm trying to reproduce is where X and Y are vectors, one from the nodes matrix and the other from the points matrix. So my idea was to first create a matrix of distances between nodes and points and then multiply each component of this matrix by the exponential factor. For now this is working properly but takes the most computational time and I would like to ask if you know if there is a possible way to reduce this computational time?
P.S. It is my first post in this forum so forgive me for any mistakes I've could done. And feel free to ask whatever.
Thank you all!
dst = pdist2(nodes, points,"euclidean")';
T = exp(-1i*k.*dst)./dst;

3 Comments

Please post some relevant input data, e.g. created by rand().
Of course, the inputs could be:
nodes = rand(1000,3)
points = rand(1000,3)
k = 0.123 + 0.123i
exp() is very expensive. I've tried to calculate the real and imaginary part separately, but this does not help here.

Sign in to comment.

Answers (0)

Asked:

on 20 Jun 2022

Commented:

Jan
on 27 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!