[pydstool-users] Improving code generation for constant mass matrix
Status: Beta
Brought to you by:
robclewley
|
From: Juan P. C. <jua...@ug...> - 2013-03-13 21:41:36
|
Hello,
When a DAE is defined with a constant mass matrix the C code generated
has one line per element in the matrix. This causes very long
compilation times for big matrices
number of rows in massmatrix, size of c-code (KB), size of .so (KB),
time to compile (seconds)
3 33 963 2
4 102 1100 4
5 265 1400 12
6 591 1800 58
7 1200 2400 238
8 2100 3200 831
When replaced with a nested for loop the compilation time for rows==7
goes down to 4 seconds.
I tried to improve FuncSpec to print a for loop fr the case of
constant matrix, but I can't cause the for loop is parsed as a macro
by QuantSpec.
Is there a way to prevent enumeration of the mass matrix and just get
code of the kind
# C integrators expect column-major matrices
body_processed += "unsigned int i,j;\n" + \
"for (i=0;i<" + str(n) + ";i++)\n" + \
"\tfor (j=0;j<" + str(m) + ";j++)\n" + \
"\t\t f_[i][j] = 0;\n\n"
for col in range(n):
for row in range(m):
try:
if specdict[specvars[row]][col]:
body_processed += "f_[" + str(col) + "][" + str(row) \
+ "] = " +
specdict[specvars[row]][col] + ";\n"
(this was my attemp in FuncSpec.py line 1688)
Thanks
--
---------------
Dr. sc. nat. Juan Pablo Carbajal
Reservoir Computing Lab
Department of Electronics and Information Systems (ELIS)
Ghent University
Sint Pietersnieuwstraat 41
9000 Ghent
Belgium
web: http://users.elis.ugent.be/~jcarbaja/
|