<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">Hello,<br>
      <br>
      You will find a description of the actual problem which is solved
      by the generated code : <a class="moz-txt-link-freetext" href="http://arxiv.org/pdf/1206.5072v1.pdf">http://arxiv.org/pdf/1206.5072v1.pdf</a><br>
      See particularly page 6, where I explain the way the code
      generation works. However, be warned that the code snipplets are
      quite obsolete, since the generated code is now more efficient.<br>
      <br>
      For matrices M_k(v) (the ones the thread is about), Antoine's
      answer give a solution because the element of this matrix are
      linear combinations of the v(i)'s.<br>
      But for other matrices, wich are derivatives of the fonctions
      expressing the non-linear system with respect to state or
      parameters, the terms to assemble are non-linear algebraic
      expressions mixing states and v(i)'s. <br>
      <br>
      S.<br>
      <br>
      <br>
      <br>
      Le 24/04/2015 15:19, 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><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="col
 or:rgb(1
 8
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>
    <br>
  </body>
</html>