<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 04/24/2015 03:19 PM, Brian Bouterse
a écrit :<br>
</div>
<blockquote
cite="mid:CAKBMpNbsKpbgHWcpiB-XJ3GKetxn3s=MMD4aoWMT00acmDvPFQ@mail.gmail.com"
type="cite">
<div dir="ltr">I don't know much about scilab optimizations, but
trying to hand-optimize auto-generated code almost certainly
will result in correctness problems. It's likely better to make
your improvements in the software that is generating the scilab
code. I think the main feature there is to have it generate a
vectorized implementation instead of a procedural one (as you
have now).</div>
</blockquote>
<br>
I agree with you: scilab is fast with linear algebra and slow for
the rest and so far you have not generated your scilab code with
scilab strength and weakness in mind.<br>
So if you stick with Scilab, you should go for a matrix form (maybe
a sparse matrix) or follow Samuel's version.<br>
<br>
Cheers,<br>
<br>
Antoine<br>
<br>
<blockquote
cite="mid:CAKBMpNbsKpbgHWcpiB-XJ3GKetxn3s=MMD4aoWMT00acmDvPFQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>-Brian</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Apr 24, 2015 at 8:34 AM,
Stéphane Mottelet <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:stephane.mottelet@utc.fr" target="_blank">stephane.mottelet@utc.fr</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Hello,<br>
<br>
this is not trivial indexing, in fact some terms are
linear combination of v's components <br>
<span> <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>
</span> How do you take this into account in your
proposed method ? These combinations are sums of
influxes in a metabolic network, and the code is
automatically generated.<span><font color="#888888"><br>
<br>
<br>
S.</font></span>
<div>
<div><br>
<br>
<br>
Le 24/04/2015 13:48, Samuel Gougeon a écrit :<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div>
<div>Le 24/04/2015 13:36, Samuel Gougeon a écrit :<br>
</div>
<blockquote type="cite">
<div>Hello Stephane,<br>
<br>
You can speed up by a factor larger than 100
just by calling v once (or 3 times) instead of
~1000, as shown by this test:<br>
</div>
</blockquote>
<br>
Actually, to be more accurate, the right
comparative test is the following:<br>
<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:12.0"><span style="color:rgb(176,24,19)">function</span> <span style="color:rgb(0,0,0);text-decoration:underline">test2</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(0,0,0)">v</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">rand</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">172</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">p</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">grand</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">839</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">unf</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">173</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(100,174,100);font-style:italic">// Part 1: 1 call to v()</span>
<span style="color:rgb(174,92,176);text-decoration:underline">tic</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(160,32,240)">for</span> <span style="color:rgb(0,0,0)">i</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(255,170,0)">:</span><span style="color:rgb(188,143,143)">1000</span>
<span style="color:rgb(0,0,0)">m1_v</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">v</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">p</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(160,32,240)">end</span>
<span style="color:rgb(50,185,185)">disp</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(174,92,176);text-decoration:underline">toc</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(100,174,100);font-style:italic">// Part 2 : 839 calls to v()</span>
<span style="color:rgb(50,185,185)">deff</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">test3()</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">for i=1:1000, M1_v = [ </span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(92,92,92)">+</span><span style="color:rgb(50,185,185)">strcat</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">v(</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(92,92,92)">+</span><span style="color:rgb(50,185,185)">string</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">p</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(92,92,92)">+</span><span>"</span><span style="co!
lor:rgb(18
8,143,143)">) </span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(92,92,92)">+</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">], end</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(174,92,176);text-decoration:underline">tic</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(0,0,0)">test3</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(50,185,185)">disp</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(174,92,176);text-decoration:underline">toc</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(176,24,19)">endfunction
</span></pre>
In this version, the compilation time used by
execstr() is no longer taken into account.<br>
<br>
The results are still explicit:<br>
-->test2()<br>
<br>
0.016 <br>
<br>
0.78 <br>
<br>
So, a speed-up by ~x 50<br>
<br>
Samuel<br>
<br>
<br>
<fieldset></fieldset>
<br>
</div>
</div>
<span>
<pre>_______________________________________________
users mailing list
<a moz-do-not-send="true" href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
<a moz-do-not-send="true" href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</span></blockquote>
<br>
</div>
<br>
_______________________________________________<br>
users mailing list<br>
<a moz-do-not-send="true"
href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a moz-do-not-send="true"
href="http://lists.scilab.org/mailman/listinfo/users"
target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div>
<div dir="ltr">Brian Bouterse<br>
</div>
</div>
</div>
</div>
<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>
</body>
</html>