<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hello Antoine </div><div><br></div><div>I think your idea is excellent in my context, I Will try it and keep you informed of the actual improvement,</div><div><br></div><div>S.</div><div><br>Le 24 avr. 2015 à 13:31, Antoine Monmayrant <<a href="mailto:antoine.monmayrant@laas.fr">antoine.monmayrant@laas.fr</a>> a écrit :<br><br></div><blockquote type="cite"><div>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<div class="moz-cite-prefix">Hi again,<br>
<br>
Another way you might improve your code: can you write it as a
matrix-vector product?<br>
Like<br>
<br>
M1_v=A*v; <br>
Where A is a matrix of size (839,172) that corresponds to your
weird combination of v(i) to build M1_v.<br>
It seems to me that you should be able to write it that way, which
would save a lot of time as matrix product are fast in Scilab.<br>
<br>
Antoine<br>
<br>
<br>
Le 04/23/2015 11:51 PM, Stéphane Mottelet a écrit :<br>
</div>
<blockquote cite="mid:55396964.7030103@utc.fr" type="cite">Hello,
<br>
<br>
I am currently working on a project where Scilab code is
automatically generated, and after many code optimization, the
remaining bottleneck is the time that Scilab spends to execute
simple code like this (full script (where the vector has 839
lines) with timings is attached) :
<br>
<br>
M1_v=[v(17)
<br>
v(104)
<br>
v(149)
<br>
-(v(18)+v(63)+v(103))
<br>
-(v(18)+v(63)+v(103))
<br>
v(17)
<br>
...
<br>
v(104)
<br>
v(149)
<br>
]
<br>
<br>
This kind of large vectors are the used to build a sparse matrix
each time the vector v changes, but with a constant sparsity
pattern. Actually, the time spent by Scilab in the statement
<br>
<br>
M1=sparse(M1_ij,M1_v,[n1,n2])
<br>
<br>
is negligible compared to the time spent to build f M1_v...
<br>
<br>
I have also noticed that if you need to define such a matrix with
more that one column, the time elapsed is not linear with respect
to the number of columns: typically 4 times slower for 2 columns.
In fact the statement
<br>
<br>
v=[1 1
<br>
...
<br>
1000 1000]
<br>
<br>
is even two times slower than
<br>
<br>
v1=[1
<br>
...
<br>
1000];
<br>
v2=[1
<br>
....
<br>
1000];
<br>
v=[v1 v2];
<br>
<br>
So my question to users who have the experience of dynamic link of
user code : do you think that using dynamic link of compiled
generated C code could improve the timings ?
<br>
<br>
In advance, thanks for your help !
<br>
<br>
S.
<br>
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
<br>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>users mailing list</span><br><span><a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a></span><br><span><a href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a></span><br></div></blockquote></body></html>