<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 24/04/2015 15:35, Samuel Gougeon a
écrit :<br>
</div>
<blockquote cite="mid:553A46AD.1050403@free.fr" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Le 24/04/2015 14:50, Stéphane
Mottelet a écrit :<br>
</div>
<blockquote cite="mid:B13FDE21-0CA8-4F8A-8B9B-73E221C3546D@utc.fr"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<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
moz-do-not-send="true"
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=ISO-8859-1"
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>
</div>
</div>
</blockquote>
</blockquote>
<br>
The test:<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(0,0,0);"><span style="color:rgb(0,0,0);">A</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">sign</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(174,92,176);text-decoration:underline;">sprand</span><span style="color:rgb(74,85,219);">(</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);">172</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(92,92,92);">/</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);">"</span><span style="color:rgb(188,143,143);">normal</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span>
<span st
y
le="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">i</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(0,0,0);">A</span><span style="color:rgb(92,92,92);">></span><span style="color:rgb(188,143,143);">0</span><span style="color:rgb(0,0,0);">;</span> <span style="color:rgb(0,0,0);">A</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">i</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">1</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">i</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(0,0,0);">A</span><span style="color:rgb(92,92,92);"><</span><span style="color:rgb(188,143,143);">0</span><span style="color:rgb(0,0,0);">;</span> <span style="color:rgb(0,0,0);">A</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">i</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1</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);">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(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);">A</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(0,0,0);">p</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(160,32,240);">end</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><span style="color:rgb(74,85,219);"></span></pre>
gives<br>
-->toc()<br>
ans =<br>
0.156 <br>
<br>
But somewhere you will somehow have to actually preset<br>
A(1,17) = 1;<br>
A(2,104) = 1;<br>
A(3,149) = 1;<br>
A(4, [18 63 103]) = -1;<br>
A(5, [18 63 103]) = -1;<br>
A(6,17) = 1;<br>
...<br>
A(838, 104) = 1;<br>
A(839, 149) = 1;<br>
<br>
A priori, this is a bit more human-readable, but also more
time-consuming... I am afraid that doing this in this way you will
loose the gain "got" with matrix multiplication.<br>
<br>
Samuel<br>
</blockquote>
<br>
No it is not a problem because the A matrix has to be created only
once, since its sparsity pattern won't change later on.<br>
<br>
S.<br>
<br>
<blockquote cite="mid:553A46AD.1050403@free.fr" type="cite"> <br>
<blockquote cite="mid:B13FDE21-0CA8-4F8A-8B9B-73E221C3546D@utc.fr"
type="cite">
<blockquote type="cite">
<div>
<div class="moz-cite-prefix"> <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>
</blockquote>
</div>
</blockquote>
</blockquote>
<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>
</body>
</html>