<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <font face="Courier New">Stéphane,<br>
      <br>
      Thanks for your solution.<br>
      <br>
      I've found another solution that is even slightly faster: I've
      modified the function intsplin(), changing<br>
      both instances of sum by cumsum (and some formal details), so the
      same interpolator is used for the whole set of data.<br>
      <br>
      Regards,<br>
      <br>
      Federico Miyara<br>
    </font><br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 11/02/2020 04:23, Stéphane Mottelet
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:d664b4d3-61f0-ea2b-69db-ae91de896ef0@utc.fr">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Sorry the ode call should be (y0 first, then x0)<br>
      </p>
      <pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(0,0,0);">y</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">ode</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);">x0</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">x1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(50,185,185);">list</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">f</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">x1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">y1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">d1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span></pre>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">The elapsed time seems OK:</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">--> tic;y =
        ode(-1,x0,x1,list(f,x1,y1,d1));toc<br>
         ans  =<br>
        <br>
           0.002235</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">S.</div>
      <div class="moz-cite-prefix"><br>
      </div>
      <div class="moz-cite-prefix">Le 11/02/2020 à 08:17, Stéphane
        Mottelet a écrit :<br>
      </div>
      <blockquote type="cite"
        cite="mid:edf554cb-9bcc-a96e-4b45-341f25c7c4d7@utc.fr">
        <meta http-equiv="Content-Type" content="text/html;
          charset=UTF-8">
        <p>Hello,</p>
        <p>The usual way to compute a primitive would be to use ode,
          like this:</p>
        <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(131,67,16);font-weight:bold;">out</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(0,0,0);text-decoration:underline;">f</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">x</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">y</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">x1</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">y1</span><span style="color:rgb(0,0,0);">, </span><span style="color:rgb(131,67,16);font-weight:bold;">d1</span><span style="color:rgb(74,85,219);">)</span>
    <span style="color:rgb(131,67,16);font-weight:bold;">out</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">interp</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(131,67,16);font-weight:bold;">x</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(131,67,16);font-weight:bold;">x1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(131,67,16);font-weight:bold;">y1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(131,67,16);font-weight:bold;">d1</span><span style="color:rgb(74,85,219);">)</span>
<span style="color:rgb(176,24,19);">endfunction</span>

<span style="color:rgb(0,0,0);">x0</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);">x1</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">0</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,143,143);">0.01</span><span style="color:rgb(255,170,0);">:</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%pi</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">y1</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">sin</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">x1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>

<span style="color:rgb(0,0,0);">d1</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">splin</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">x1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">y1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>

<span style="color:rgb(0,0,0);">y</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">ode</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">x0</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(0,0,0);">x1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(50,185,185);">list</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);text-decoration:underline;">f</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">x1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">y1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">d1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(74,85,219);">)</span></pre>
        <div class="moz-cite-prefix">Your proposition is very slow
          because you are recomputing the spline many times. <br>
        </div>
        <div class="moz-cite-prefix"><br>
        </div>
        <div class="moz-cite-prefix">S.<br>
        </div>
        <div class="moz-cite-prefix"><br>
        </div>
        <div class="moz-cite-prefix">Le 10/02/2020 à 20:52, Federico
          Miyara a écrit :<br>
        </div>
        <blockquote type="cite"
          cite="mid:79e31a97-9afb-414e-9723-082735e6c903@fceia.unr.edu.ar">
          <meta http-equiv="content-type" content="text/html;
            charset=UTF-8">
          <br>
          <font face="Courier New">Dear all,<br>
            <br>
            The function integrate() is very handy to obtain a numerical
            primtive of a function, particularly useful when there is no
            closed form for the primitive or it is too involved.
            According to the documentation<br>
            <br>
          </font>
          <blockquote><font face="Courier New">x = integrate(expr, v,
              x0, x1 [, atol [, rtol]])</font><br>
            <br>
            <font face="Courier New">expr: </font><font face="Courier
              New">a character string defining a Scilab expression.<br>
              v:    a character string, the integration variable name<br>
            </font></blockquote>
          <font face="Courier New"><br>
            However there is a case that would be interesting to handle,
            and it is when one has a set of experimental (or simulated)
            data xk, yk. Here there is no expression defining a
            function.<br>
            <br>
            One way to circumvent this is using as the expression some
            sort of interpolator such as <br>
            <br>
            x = integrate("interp1(xk, yk, x, ''spline'')", "x", x0, x1)<br>
            <br>
            This works, but for some reason I don't quite understand it
            is very slow.<br>
            <br>
            For instance,<br>
            <br>
            x0 = 0<br>
            x1 = 0:0.01:2*%pi;<br>
            y1 = sin(x1);<br>
            <br>
            tic<br>
            X = integrate("interp1(x1, y1, x, ''spline'')", "x", x0,
            x1);<br>
            toc<br>
            <br>
            Requires 27 s to execute. In the meantime, control is
            seemingly returned to the console, one can enter
            instructions, but then the program freezes until the
            integrate comand finishes.<br>
            <br>
            Changing "spline" to "linear" even worsens it rising to 33
            s.<br>
            <br>
            Has anybody an idea of what can be happening?<br>
            <br>
            Maybe it computes the full interpolator for each single
            point? Even if so, I have only 629 values of the independent
            variable.<br>
            <br>
            Regards,<br>
            <br>
            Federico Miyara<br>
             <br>
            <br>
            <br>
          </font> <br>
          <fieldset class="mimeAttachmentHeader"></fieldset>
          <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org" moz-do-not-send="true">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users" moz-do-not-send="true">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
        </blockquote>
        <pre class="moz-signature" cols="72">-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.utc.fr/~mottelet" moz-do-not-send="true">http://www.utc.fr/~mottelet</a>
</pre>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org" moz-do-not-send="true">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users" moz-do-not-send="true">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
      </blockquote>
      <pre class="moz-signature" cols="72">-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet" moz-do-not-send="true">http://www.utc.fr/~mottelet</a>
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-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>