<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 27/09/2016 à 09:08,
<a class="moz-txt-link-abbreviated" href="mailto:paul.carrico@free.fr">paul.carrico@free.fr</a> a écrit :<br>
</div>
<blockquote
cite="mid:959886027.322449082.1474960095931.JavaMail.root@zimbra5-e1.priv.proxad.net"
type="cite">
<style type="text/css">p { margin: 0; }</style>
<div style="font-family: times new roman,new york,times,serif;
font-size: 12pt; color: #000000"><font face="times new roman,
new york, times, serif"><span style="font-size: 12pt;">Hi All</span></font><br>
<br>
<font face="times new roman, new york, times, serif"><span
style="font-size: 12pt;">Is the vectorization possible for
the example herebellow? everything I tried failed !</span></font><br>
</div>
</blockquote>
<font face="times new roman, new york, times, serif">if a is a
vector, it is quite straight forward: <font color="#3366ff">sum(matrix(a,w,-1),1).'</font><br>
</font><font face="times new roman, new york, times, serif"><font
face="times new roman, new york, times, serif">k=100;a=rand(k,1);w=5;n=k/w;</font></font><br>
<div><font face="times new roman, new york, times, serif">tmp =
zeros(n,1);</font></div>
<div><font face="times new roman, new york, times, serif">for i = 1
: n</font></div>
<div><font face="times new roman, new york, times, serif">
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));</font></div>
<div><font face="times new roman, new york, times, serif">end<br>
tmp-</font><font face="times new roman, new york, times, serif">sum(sum(matrix(a,w,n,-1),3),1).'</font></div>
<br>
<br>
<font face="times new roman, new york, times, serif">If a is matrix
it is more tricky: <font color="#3366ff">sum(sum(matrix(a,w,n,-1),3),1).'</font><br>
k=100;a=rand(k,4);w=5;n=k/w;<br>
</font><br>
<div><font face="times new roman, new york, times, serif">tmp =
zeros(n,1);</font></div>
<div><font face="times new roman, new york, times, serif">for i = 1
: n</font></div>
<div><font face="times new roman, new york, times, serif">
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));</font></div>
<div><font face="times new roman, new york, times, serif">end<br>
tmp-</font><font face="times new roman, new york, times, serif">sum(sum(matrix(a,w,n,-1),3),1).'<br>
<br>
<br>
Serge<br>
</font></div>
<font face="times new roman, new york, times, serif"></font>
<blockquote
cite="mid:959886027.322449082.1474960095931.JavaMail.root@zimbra5-e1.priv.proxad.net"
type="cite">
<div style="font-family: times new roman,new york,times,serif;
font-size: 12pt; color: #000000"><br>
<font face="times new roman, new york, times, serif"><span
style="font-size: 12pt;">Thanks for any help</span></font><br>
<br>
<font face="times new roman, new york, times, serif"><span
style="font-size: 12pt;">Paul</span></font><br>
<br>
<font face="times new roman, new york, times, serif"><span
style="font-size: 12pt;">##################################################################</span></font><br>
<div>
<div><font face="times new roman, new york, times, serif">mode(0)</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">k =
100;</font></div>
<div><font face="times new roman, new york, times, serif">a =
rand(k,1);</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">w =
5;</font></div>
<div><font face="times new roman, new york, times, serif">n =
(k/w);</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">i =
[1 : n]';</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">tmp
= zeros(n,1);</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">//
using vectorization</font></div>
<div><font face="times new roman, new york, times, serif">tmp(i,1)
= sum(a( [1 + (i-1)*n : i*n],:)</font></div>
<div><font face="times new roman, new york, times, serif">abort</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">//
same using a loop</font></div>
<div><font face="times new roman, new york, times, serif">for
i = 1 : n</font></div>
<div><font face="times new roman, new york, times, serif">
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));</font></div>
<div><font face="times new roman, new york, times, serif">end</font></div>
<div><font face="times new roman, new york, times, serif"><br>
</font></div>
<div><font face="times new roman, new york, times, serif">tmp</font></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>
<p><br>
</p>
</body>
</html>