Re: [Scilab-users] any suggestion to make my Scilab code faster would be welcome:

2018-05-16 Thread Heinz Nabielek
Histogram shows distribution of d and comparison with my model prediction.
Heinz


> On 16.05.2018, at 19:44, Heinz Nabielek  wrote:
> 
> Yes- factor 10. Great many thanks for all the help.
> Heinz
> 
>> On 16.05.2018, at 08:40, kjubo  wrote:
>> 
>> Hello,
>> 
>> d = zeros(n,1);
>> for ii=1:n;
>> //SqDist   = (X-X(i))^2 + (Y-Y(i))^2 + (Z-Z(i))^2;
>>   SqDist   = (X-X(ii)).*(X-X(ii)) + (Y-Y(ii)).*(Y-Y(ii)) +
>> (Z-Z(ii)).*(Z-Z(ii));
>>   SqDist(ii)= [];
>>   d(ii)= sqrt(min(SqDist));
>> end; 
>> 
>> some comments:
>> * preallocate matrix
>> * avoid unnecessary assign of variables (this slow down scilab more than
>> expected)
>> * as seen in previous meesages here, use X*X instead of X^2
>> 
>> for me speed up factor is ~10
>> 
>> Regards.
> 

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


Re: [Scilab-users] any suggestion to make my Scilab code faster would be welcome:

2018-05-16 Thread Heinz Nabielek
Yes- factor 10. Great many thanks for all the help.
Heinz

> On 16.05.2018, at 08:40, kjubo  wrote:
> 
> Hello,
> 
> d = zeros(n,1);
> for ii=1:n;
> //SqDist   = (X-X(i))^2 + (Y-Y(i))^2 + (Z-Z(i))^2;
>SqDist   = (X-X(ii)).*(X-X(ii)) + (Y-Y(ii)).*(Y-Y(ii)) +
> (Z-Z(ii)).*(Z-Z(ii));
>SqDist(ii)= [];
>d(ii)= sqrt(min(SqDist));
> end; 
> 
> some comments:
> * preallocate matrix
> * avoid unnecessary assign of variables (this slow down scilab more than
> expected)
> * as seen in previous meesages here, use X*X instead of X^2
> 
> for me speed up factor is ~10
> 
> Regards.

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


Re: [Scilab-users] any suggestion to make my Scilab code faster would be welcome:

2018-05-16 Thread Wozai
Hi,

A very similar problem was discussed
here

  
in length. You'll find there numerous hints how to make your code faster.

Cheers

Wozai



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] any suggestion to make my Scilab code faster would be welcome:

2018-05-16 Thread kjubo
Hello,

d = zeros(n,1);
for ii=1:n;
//SqDist   = (X-X(i))^2 + (Y-Y(i))^2 + (Z-Z(i))^2;
SqDist   = (X-X(ii)).*(X-X(ii)) + (Y-Y(ii)).*(Y-Y(ii)) +
(Z-Z(ii)).*(Z-Z(ii));
SqDist(ii)= [];
d(ii)= sqrt(min(SqDist));
end; 

some comments:
* preallocate matrix
* avoid unnecessary assign of variables (this slow down scilab more than
expected)
* as seen in previous meesages here, use X*X instead of X^2

for me speed up factor is ~10

Regards.



--
Sent from: 
http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users