I have a program which calls many functions which construct matrices by
repeated use of element-wise multiplications and additions starting from
other matrices. Its part of an attempt at an electronic structure program.
The code is very slow (although that is subjective) and I believe it is
because of the definitions of many intermediate arrays in each function. As
a short example, a small part of the code of one of such functions is:
All these are N x 1 arrays, with N in the tens or even low hundreds. There
are MANY such functions, and this is a very small part.
I think that I'm defining too many arrays such as dxx_s_px_s_0, etc, and
that if I do something like:
d_s_p_s_1 = zeros(ni,nj);
and then fill up the matrices like this:
I'm looking for some general advice on how to make this type of code, which
is already vectorized, more efficient. The code was automatically generated
with Python programs that I made. In order to change the code I need to
modify the generator, so I can try things but it takes me some days to
produce a new syntax. That's why I'm asking before trying several approaches
and benchmarking. I also would like to understand better how memory and
other resources are handled by Octave.
Thank you very much!