Re: [Scilab-users] is vectorization possible

2016-09-27 Thread Serge Steer

Le 27/09/2016 à 09:08, paul.carr...@free.fr a écrit :

Hi All

Is the vectorization possible for the example herebellow? everything I 
tried failed !

if a is a vector, it is quite straight forward: sum(matrix(a,w,-1),1).'
k=100;a=rand(k,1);w=5;n=k/w;
tmp = zeros(n,1);
for i = 1 : n
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
end
tmp-sum(sum(matrix(a,w,n,-1),3),1).'


If a is matrix it is more tricky: sum(sum(matrix(a,w,n,-1),3),1).'
k=100;a=rand(k,4);w=5;n=k/w;

tmp = zeros(n,1);
for i = 1 : n
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
end
tmp-sum(sum(matrix(a,w,n,-1),3),1).'


Serge


Thanks for any help

Paul

##
mode(0)

k = 100;
a = rand(k,1);

w = 5;
n = (k/w);

i = [1 : n]';

tmp = zeros(n,1);

// using vectorization
tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:)
abort


// same using a loop
for i = 1 : n
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
end

tmp


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] scilab 6 and vectorization

2016-09-27 Thread paul . carrico
Hi

I cannot say if this topic has ever been discussed so far, but I installed 
Scilab 6.0 in order to work with a huge amount of data ; unlike the current 
stable data that is limited to 2 Go, the 6.0 one is announced to not be limited 
...
... I tried a code using vectorization and I've been disappointed to notice 
that it doesn't work

Is there a document summarizing the changes regarding this topic?

Regards

Paul

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] System Identification for First order delay and dead time

2016-09-27 Thread Tim Wescott
First, you're not doing what I recommended you do.  Yet you are
addressing me for help with your solution, when I've already suggested
two.  Why?

Second, your prototype transfer function is 11th order, and you instruct
time_id to find the best fit to a second-order transfer function.  You
are surprised that get a transfer function in return that's not a good
fit.  Why?

Third, you've been told that Scilab does not have a pre-packaged way of
doing a fit to a system with pure time delay, and you've been given more
than one suggestion for how to roll your own.  You don't seem to have
taken any of these suggestions.  Why?

On Tue, 2016-09-27 at 07:30 -0700, Fukashiimo wrote:
> Dear Tim, 
> 
> Thank you for yor advise. 
> 
> However, u is the step signal, such as 50% ==>60% ==> 50%. 
> u and y are sampled with constant interval, such as one second. 
> 
> 
> 
> I made following Scilabe code, using time_id: 
> 
> // 
> z=poly(0,'z'); 
> h=(0.065/(z-0.934))*(1/z^10)//<== 10 Sampling period dead time 
> u=zeros(1,100); 
> for i=10:1:100 
> u(1,i)=2.0; 
> end 
> t=1:1:100; 
> rep=flts(u,tf2ss(h)); 
> plot(t,rep,t,u)//  <== We can see the step type process input with
> amplitude=2 and its process response with 10 sampling period dead
> time. 
> k=find(rep<>0,1) //here the threshold has to be improved in case of
> noisy signal 
> //H=time_id(1,"step",rep(k:$)) 
> H=time_id(2,u,rep) 
> rep=flts(u,tf2ss(H)); 
> plot(t,rep,'.r')// <== We can see the process response by identified
> model. 
> H 
> 
> 
> h  = 
>   
>0.065   
> ---   
>   10  11   
>   - 0.934z + z 
> 
> 
> H  = 
>   
>   0.0265880 
> -   
>   - 0.9779092 + z 
> 
> 
> h is the discreate transfer function to provide operation data. 
> H is the identified transfer function obtained from the opeartion data
> using time_id. 
> 
> I have two issues. 
> 1. H is not similar to h even the data doesn't include any noise. How
> I can obtain transfer function nearly same as h? 
> 2. I would like to have continuous transfer function. How I should
> convert the discreate transfer function to continuous transfer
> function. 
> 
> 
> I am lokking for a solution for these two issues. 
> May I ask your advise again? 
> 
> 
> Thanks. 
> 
> 
> - 元のメッセージ - 
> 差出人: "Tim Wescott [via Scilab / Xcos - Mailing Lists Archives]"
> <[hidden email]> 
> 宛先: "Fukashiimo" <[hidden email]> 
> 送信済み: 2016年9月26日(月曜日) 04:07:52 
> 件名: Re: System Identification for First order delay and dead time 
> 
> Heh.  I just realized a better way to do this: 
> 
> I assume that you've sampled u and y at a constant rate, and that you 
> have captured some reasonable amount of the response.  This will be 
> perfect if u is periodic. 
> 
> If u is periodic, then for some integer number of periods, take U = 
> fft(u) and Y = fft(y).  If u isn't periodic, then take FFT's of u and
> y 
> after windowing them both with identical windows. 
> 
> Now calculate the frequencies for each bin of the above fft's. 
> 
> Define H(w) = ( K ./ (%i * tau * w + 1) ) .* exp(-%i * w * T). 
> 
> Calculate Ymodel = U .* H(w) 
> 
> Now, thanks to the magic of Parseval's Theorem, 
> norm(Y - Ymodel) is the same as, or just a constant multiplier away
> from 
> being, norm(y - ymodel) -- but you never actually have to compute 
> ymodel. 
> 
> So optimize on tau and T as described before.  You should only have
> to 
> take your FFTs once at the beginning -- the rest will be repeatedly 
> calculating H(w) for the various values of tau and T (and K, if you
> want 
> to be lazy and just toss it into optim, although it'll be much faster
> to 
> determine it using least-squares fit). 
> 
> On Sun, 2016-09-25 at 01:07 -0700, Fukashiimo wrote: 
> 
> > Thank you for your suggestion. However, I am not sure how I should 
> > formulate my Laplace domain equation. Could you please advise me
> more 
> > specifically? 
> > 
> > Thanks. 
> > 
> > 
> > 2016/09/25 午前9:33 "Tim Wescott [via Scilab / Xcos - Mailing Lists 
> > Archives]" <[hidden email]>: 
> > I suggest that you roll your own cost function, and use 
> > optim. 
> > 
> > Where possible, with optim, if part of the problem is 
> > nonlinear and part 
> > is linear, it's good to use a plain old linear
> least-squares 
> > fit for the 
> > plain old linear part.  In your case, that's K.  Tau and Td 
> > will have to 
> > be determined by optim. 
> > 
> > The cost function should generate a vector for ymodel with K
> = 
> > 1, then 
> > find the best fit for K with 
> > 
> > K = y / ymodel; 
> > 
> > then return a cost 
> > 
> > cost = norm(y - K * ymodel); 
> > 
> > wrap that all up in NDCost and then optim, and away you'll 
> > go. 
> > 
> > On 2016-09-24 06:59, Fukashiimo wrote: 
> > 
> > > Hello, 
> >  

Re: [Scilab-users] issue with "sum"

2016-09-27 Thread paul . carrico
"remember"  heuhhh ... :-)

Thanks Stephane

- Mail original -
De: "Stéphane Mottelet" 
À: "Users mailing list for Scilab" 
Envoyé: Mardi 27 Septembre 2016 15:09:36
Objet: Re: [Scilab-users] issue with "sum"

paul,

remember the transpose is *conjugate transpose*, use .' instead.

S.

Le 27/09/2016 à 15:04, paul.carr...@free.fr a écrit :
> Hi again
>
> In the following example, the sum lead to an opposite sign for the complex 
> part … Am I doing something wrong ?
>
> thanks for any highlight
>
> Paul
>
> 
> mode(0)
>
> A = [
> - 3.
> 6.123D-17
> 3.
> - 3.
> - 3.062D-17 - 5.303D-17*%i
> - 1.5 + 2.5980762*%i
> - 3.
> - 3.062D-17 + 5.303D-17*%i
>   - 1.5 - 2.5980762*%i]
>
> mat = matrix(A,3,3)
>
> sum1 = sum(mat,'r')' // reference matrix
>
> sum_c1 = sum(mat(:,1)) // sum of the 1rst column of sum1 matrix
> sum_c2 = sum(mat(:,2)) // 2nd column of sum1 matrix
> sum_c3 = sum(mat(:,3)) // 3rd column of sum1 matrix
>
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] issue with "sum"

2016-09-27 Thread Stéphane Mottelet

paul,

remember the transpose is *conjugate transpose*, use .' instead.

S.

Le 27/09/2016 à 15:04, paul.carr...@free.fr a écrit :

Hi again

In the following example, the sum lead to an opposite sign for the complex part 
… Am I doing something wrong ?

thanks for any highlight

Paul


mode(0)

A = [
- 3.
6.123D-17
3.
- 3.
- 3.062D-17 - 5.303D-17*%i
- 1.5 + 2.5980762*%i
- 3.
- 3.062D-17 + 5.303D-17*%i
  - 1.5 - 2.5980762*%i]

mat = matrix(A,3,3)

sum1 = sum(mat,'r')' // reference matrix

sum_c1 = sum(mat(:,1)) // sum of the 1rst column of sum1 matrix
sum_c2 = sum(mat(:,2)) // 2nd column of sum1 matrix
sum_c3 = sum(mat(:,3)) // 3rd column of sum1 matrix

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] issue with "sum"

2016-09-27 Thread paul . carrico
Hi again

In the following example, the sum lead to an opposite sign for the complex part 
… Am I doing something wrong ?

thanks for any highlight

Paul


mode(0)

A = [
- 3.
6.123D-17
3.
- 3.
- 3.062D-17 - 5.303D-17*%i
- 1.5 + 2.5980762*%i
- 3.
- 3.062D-17 + 5.303D-17*%i
 - 1.5 - 2.5980762*%i]

mat = matrix(A,3,3)

sum1 = sum(mat,'r')' // reference matrix

sum_c1 = sum(mat(:,1)) // sum of the 1rst column of sum1 matrix
sum_c2 = sum(mat(:,2)) // 2nd column of sum1 matrix
sum_c3 = sum(mat(:,3)) // 3rd column of sum1 matrix

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread Dang Ngoc Chan, Christophe
Hello,

> De :  paul.carr...@free.fr
> Envoyé : mardi 27 septembre 2016 09:08
>
> for i = 1 : n
> tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
> end

So you want to sum on a window which width is w, isn't it?

Not full vectorization,
but you might loop on w (=5) instead of n (=20),
something like

for i = 1:w
   tmp = tmp + a(i : n-w-1 + i)
end

It might be faster.

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error), please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] {EXT} Re: is vectorization possible

2016-09-27 Thread Dang Ngoc Chan, Christophe
Hello,

> De : paul.carr...@free.fr
> Envoyé : mardi 27 septembre 2016 10:27
>
> It works now

To have it complete, my solution, once debugged,
is twice slower than the vectorised solution
(but faster than the initial loop)

tic()
indices0 = 0:w:(k-1);
tmp3 = zeros(n,1);
for i = 1 : w
indices = indices0 + i;
tmp3 = tmp3 + a(indices);
end
duree_loop3 = toc()

(my email delivery seems quite slow today, so you might see this a bit late).

regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error), please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread paul . carrico
thanks to both of you

I works now

Paul

###
mode(0)

k = 1E6;
a = rand(k,1);

w = 2;
n = (k/w);


// same using a loop
tic()
tmp2 = zeros(n,1);
for i = 1 : n
tmp2(i,1) = sum(a([1 + (i-1)*w : i*w],:));
end
duree_loop = toc()

// using vectorization
tic()
tmp = zeros(n,1);
tmp = sum(matrix(a,w,n),'r')';
duree_vectorization = toc()


max_error = max(abs(tmp - tmp2))

- Mail original -
De: "ol.bond" 
À: users@lists.scilab.org
Envoyé: Mardi 27 Septembre 2016 09:59:12
Objet: Re: [Scilab-users] is vectorization possible



As just mentioned by Tim, you have to transform your vector 'a' to a matrix, 
and then apply summation: 


tmp = sum(matrix(a,w,n)','c'); 







2016-09-27 16:56 GMT+09:00 Tim Wescott [via Scilab / Xcos - Mailing Lists 
Archives] < [hidden email] > : 


OK. I think I see where I went wrong. 

There's a way to do this but it's a bit mind boggling. 

If you can let ix be a rectangular matrix of indexes, then a(ix) will be 
a column vector of indexed values. Then you can use 'matrix' to 
reassembly a(ix) into a rectangular matrix, the rows or columns of which 
you can sum up. I don't know if it'll be faster than the for loop, 
though. 

There may be an even better way of doing it, but I don't know what it 
is. 



On 2016-09-27 00:28, [hidden email] wrote: 


> Thanks Tim for the answer, nevertheless it cannot work. 
> 
> I want to make the sum of blocks of rows; here 
> - 'i' is a vector 
> - tmp is a vector of 20 rows in the current example 
> - the loop does the job, but I do not understand why the vectorization 
> fails ... is it a synthax error ? 
> 
> Paul 
> 
> pb: in my understanding, 'c' means 'column' and 'r' means row => for 
> matrix operations 
> 
> 
> 
> - Mail original - 
> De: "Tim Wescott" < [hidden email] > 
> À: [hidden email] 
> Envoyé: Mardi 27 Septembre 2016 09:17:30 
> Objet: Re: [Scilab-users] is vectorization possible 
> 
> tmp = sum(a( [1 + (i-1)*n : i*n],:), 'c') 
> 
> Or sum(..., 'r'). I can't remember which is which. One makes a row, 
> the other makes a column, but I can never remember if it's "sum all 
> columns" or "sum into a column". 
> 
> On Tue, 2016-09-27 at 09:08 +0200, [hidden email] wrote: 
>> Hi All 
>> 
>> Is the vectorization possible for the example herebellow? everything I 
>> tried failed ! 
>> 
>> Thanks for any help 
>> 
>> Paul 
>> 
>> ## 
>> mode(0) 
>> 
>> 
>> k = 100; 
>> a = rand(k,1); 
>> 
>> 
>> w = 5; 
>> n = (k/w); 
>> 
>> 
>> i = [1 : n]'; 
>> 
>> 
>> tmp = zeros(n,1); 
>> 
>> 
>> // using vectorization 
>> tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:) 
>> abort 
>> 
>> 
>> 
>> 
>> // same using a loop 
>> for i = 1 : n 
>> tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:)); 
>> end 
>> 
>> 
>> tmp 
>> ___ 
>> users mailing list 
>> [hidden email] 
>> http://lists.scilab.org/mailman/listinfo/users 
> 
> -- 
> 
> Tim Wescott 
> www.wescottdesign.com 
> Control & Communications systems, circuit & software design. 
> Phone:  target="_blank">503.631.7815 
> Cell:  target="_blank">503.349.8432 
> 
> 
> ___ 
> users mailing list 
> [hidden email] 
> http://lists.scilab.org/mailman/listinfo/users 
> ___ 
users mailing list 
[hidden email] 
http://lists.scilab.org/mailman/listinfo/users 







If you reply to this email, your message will be added to the discussion below: 
http://mailinglists.scilab.org/Scilab-users-is-vectorization-possible-tp4034639p4034644.html
 


To start a new topic under Scilab users - Mailing Lists Archives, email [hidden 
email] 
To unsubscribe from Scilab users - Mailing Lists Archives, click here . 
NAML 


View this message in context: Re: is vectorization possible 
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com. 

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread ol.bond
As just mentioned by Tim, you have to transform your vector 'a' to a
matrix, and then apply summation:

tmp = sum(matrix(a,w,n)','c');



2016-09-27 16:56 GMT+09:00 Tim Wescott [via Scilab / Xcos - Mailing Lists
Archives] :

> OK.  I think I see where I went wrong.
>
> There's a way to do this but it's a bit mind boggling.
>
> If you can let ix be a rectangular matrix of indexes, then a(ix) will be
> a column vector of indexed values.  Then you can use 'matrix' to
> reassembly a(ix) into a rectangular matrix, the rows or columns of which
> you can sum up.  I don't know if it'll be faster than the for loop,
> though.
>
> There may be an even better way of doing it, but I don't know what it
> is.
>
> On 2016-09-27 00:28, [hidden email]
>  wrote:
>
> > Thanks Tim for the answer, nevertheless it cannot work.
> >
> > I want to make the sum of blocks of rows; here
> > - 'i' is a vector
> > - tmp is a vector of 20 rows in the current example
> > - the loop does the job, but I do not understand why the vectorization
> > fails ... is it a synthax error ?
> >
> > Paul
> >
> > pb: in my understanding, 'c' means 'column' and 'r' means row => for
> > matrix operations
> >
> >
> >
> > - Mail original -
> > De: "Tim Wescott" <[hidden email]
> >
> > À: [hidden email]
> 
> > Envoyé: Mardi 27 Septembre 2016 09:17:30
> > Objet: Re: [Scilab-users] is vectorization possible
> >
> > tmp = sum(a( [1 + (i-1)*n : i*n],:), 'c')
> >
> > Or sum(..., 'r').  I can't remember which is which.  One makes a row,
> > the other makes a column, but I can never remember if it's "sum all
> > columns" or "sum into a column".
> >
> > On Tue, 2016-09-27 at 09:08 +0200, [hidden email]
>  wrote:
> >> Hi All
> >>
> >> Is the vectorization possible for the example herebellow? everything I
> >> tried failed !
> >>
> >> Thanks for any help
> >>
> >> Paul
> >>
> >> ##
> >> mode(0)
> >>
> >>
> >> k = 100;
> >> a = rand(k,1);
> >>
> >>
> >> w = 5;
> >> n = (k/w);
> >>
> >>
> >> i = [1 : n]';
> >>
> >>
> >> tmp = zeros(n,1);
> >>
> >>
> >> // using vectorization
> >> tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:)
> >> abort
> >>
> >>
> >>
> >>
> >> // same using a loop
> >> for i = 1 : n
> >> tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
> >> end
> >>
> >>
> >> tmp
> >> ___
> >> users mailing list
> >> [hidden email] 
> >> http://lists.scilab.org/mailman/listinfo/users
> >
> > --
> >
> > Tim Wescott
> > www.wescottdesign.com
> > Control & Communications systems, circuit & software design.
> > Phone: 503.631.7815
> > Cell:  503.349.8432
> >
> >
> > ___
> > users mailing list
> > [hidden email] 
> > http://lists.scilab.org/mailman/listinfo/users
>
> ___
> users mailing list
> [hidden email] 
> http://lists.scilab.org/mailman/listinfo/users
>
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
> http://mailinglists.scilab.org/Scilab-users-is-vectorization-possible-
> tp4034639p4034644.html
> To start a new topic under Scilab users - Mailing Lists Archives, email
> ml-node+s994242n2602246...@n3.nabble.com
> To unsubscribe from Scilab users - Mailing Lists Archives, click here
> 
> .
> NAML
> 
>




--
View this message in context: 
http://mailinglists.scilab.org/Scilab-users-is-vectorization-possible-tp4034639p4034646.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at 
Nabble.com.___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread tim
On 2016-09-27 00:48, Samuel Gougeon wrote:

> Le 27/09/2016 09:17, Tim Wescott a écrit : 
> 
>> .../...
>> 
>> Or sum(..., 'r').  I can't remember which is which.  One makes a row,
>> the other makes a column, but I can never remember if it's "sum all
>> columns" or "sum into a column".
> :)
> Never did i, until i realized that operating ACROSS Rows yields a Row, or 
> across Columns Yields a Column.
> Nevertheless i vaguely remember having met very few functions for which it is 
> the opposite (but for good understandable reasons).

I just make a matrix 'thing', then do size(sum(thing, 'c')).  Then I
know. ___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread tim

OK.  I think I see where I went wrong.

There's a way to do this but it's a bit mind boggling.

If you can let ix be a rectangular matrix of indexes, then a(ix) will be 
a column vector of indexed values.  Then you can use 'matrix' to 
reassembly a(ix) into a rectangular matrix, the rows or columns of which 
you can sum up.  I don't know if it'll be faster than the for loop, 
though.


There may be an even better way of doing it, but I don't know what it 
is.


On 2016-09-27 00:28, paul.carr...@free.fr wrote:

Thanks Tim for the answer, nevertheless it cannot work.

I want to make the sum of blocks of rows; here
- 'i' is a vector
- tmp is a vector of 20 rows in the current example
- the loop does the job, but I do not understand why the vectorization
fails ... is it a synthax error ?

Paul

pb: in my understanding, 'c' means 'column' and 'r' means row => for
matrix operations



- Mail original -
De: "Tim Wescott" 
À: users@lists.scilab.org
Envoyé: Mardi 27 Septembre 2016 09:17:30
Objet: Re: [Scilab-users] is vectorization possible

tmp = sum(a( [1 + (i-1)*n : i*n],:), 'c')

Or sum(..., 'r').  I can't remember which is which.  One makes a row,
the other makes a column, but I can never remember if it's "sum all
columns" or "sum into a column".

On Tue, 2016-09-27 at 09:08 +0200, paul.carr...@free.fr wrote:

Hi All

Is the vectorization possible for the example herebellow? everything I
tried failed !

Thanks for any help

Paul

##
mode(0)


k = 100;
a = rand(k,1);


w = 5;
n = (k/w);


i = [1 : n]';


tmp = zeros(n,1);


// using vectorization
tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:)
abort




// same using a loop
for i = 1 : n
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
end


tmp
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


--

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread Samuel Gougeon

Le 27/09/2016 09:17, Tim Wescott a écrit :

.../...

Or sum(..., 'r').  I can't remember which is which.  One makes a row,
the other makes a column, but I can never remember if it's "sum all
columns" or "sum into a column".

:)
Never did i, until i realized that operating *across* Rows yields a Row, 
or across Columns Yields a Column.
Nevertheless i vaguely remember having met very few functions for which 
it is the opposite (but for good understandable reasons).


Samuel

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] is vectorization possible

2016-09-27 Thread paul . carrico
Thanks Tim for the answer, nevertheless it cannot work.

I want to make the sum of blocks of rows; here 
- 'i' is a vector
- tmp is a vector of 20 rows in the current example
- the loop does the job, but I do not understand why the vectorization fails 
... is it a synthax error ?

Paul

pb: in my understanding, 'c' means 'column' and 'r' means row => for matrix 
operations



- Mail original -
De: "Tim Wescott" 
À: users@lists.scilab.org
Envoyé: Mardi 27 Septembre 2016 09:17:30
Objet: Re: [Scilab-users] is vectorization possible

tmp = sum(a( [1 + (i-1)*n : i*n],:), 'c')

Or sum(..., 'r').  I can't remember which is which.  One makes a row,
the other makes a column, but I can never remember if it's "sum all
columns" or "sum into a column".

On Tue, 2016-09-27 at 09:08 +0200, paul.carr...@free.fr wrote:
> Hi All
> 
> Is the vectorization possible for the example herebellow? everything I
> tried failed !
> 
> Thanks for any help
> 
> Paul
> 
> ##
> mode(0)
> 
> 
> k = 100;
> a = rand(k,1);
> 
> 
> w = 5;
> n = (k/w);
> 
> 
> i = [1 : n]';
> 
> 
> tmp = zeros(n,1);
> 
> 
> // using vectorization
> tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:)
> abort
> 
> 
> 
> 
> // same using a loop
> for i = 1 : n
> tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));
> end
> 
> 
> tmp
> ___
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] is vectorization possible

2016-09-27 Thread paul . carrico
Hi All 

Is the vectorization possible for the example herebellow? everything I tried 
failed ! 

Thanks for any help 

Paul 

## 


mode(0) 


k = 100; 
a = rand(k,1); 


w = 5; 
n = (k/w); 


i = [1 : n]'; 


tmp = zeros(n,1); 


// using vectorization 
tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:) 
abort 




// same using a loop 
for i = 1 : n 
tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:)); 
end 


tmp ___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users