[Scilab-users] Advice from Scilab community (including parallelization)
Samuel Gougeon
sgougeon at free.fr
Sat Oct 26 15:18:42 CEST 2013
Le 26/10/2013 11:08, Paul Carrico a écrit :
>
> printf("Search for duplicates............\n");
>
> ///tic()/
>
> fori = 1 : (number_of_blocks + k)
>
> printf("block ref %d/%d ...\n",i,(number_of_blocks+k));
>
> _tic_()
>
> for j = 1 : (number_of_blocks + k)
>
> s2 = "...
>
> if (j == i) then , ...
>
> [nb,loc] = members(splited"+ string(i) + ",splited" +
> string(j) + ", ""rows"",""shuffle"",""last"") , ...
>
> splited"+ string(j) + "(loc(find(nb >= 2)),:) = [] , ...
>
> else , ...
>
> [nb,loc] = members(splited"+ string(i) + ",splited" +
> string(j) + ", ""rows"",""shuffle"") , ...
>
> splited"+ string(j) + "(loc(find(nb >= 1)),:) = [] , ...
>
> end , ...
>
> ";
>
> execstr(s2);
>
> end
>
> time=_toc_();
>
> printf("..... time on this loop= %g\n",time)
>
> end
>
> ///time = toc()/
>
Removing lines duplicated through permutations may be done without members()
but using the same remark & strategy:
// generating an example
m = grand(10,2,"uin",0,2)
// for each line, sorting the columns :
ms = gsort(m,"c","i")
// Then applying unique() row-wise:
[mu, k] = unique(ms,"r")
// Finally picking the related rows in the original matrix:
m(k,:)
-->m = grand(10,2,"uin",0,2)
m =
0. 1.
2. 2.
2. 0.
2. 1.
1. 1.
0. 0.
1. 1.
1. 2.
1. 0.
0. 2.
-->ms = gsort(m,"c","i")
ms =
0. 1.
2. 2.
0. 2.
1. 2.
1. 1.
0. 0.
1. 1.
1. 2.
0. 1.
0. 2.
-->[mu, k] = unique(ms,"r")
k =
6.
9.
3.
5.
8.
2.
mu =
0. 0.
0. 1.
0. 2.
1. 1.
1. 2.
2. 2.
-->m(k,:)
ans =
0. 0.
1. 0.
2. 0.
1. 1.
1. 2.
2. 2.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20131026/d6967d45/attachment.htm>
More information about the users
mailing list