Matlab BroadCast Özelliği (numpy olduğu gibi)
Matlab satır ve sütun matrisini toplarken hata verirdi. Yeni gelen özellikle artık numpy gibi işlem yapabiliyoruz.
a =[0 1 2 3 4 5 6 7 8 9 10];
b =[0 1 2 3 4 5 6 7 8 9 10];
a.'=
0
1
2
3
4
5
6
7
8
9
10
a.' * b=
0 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10 11
2 3 4 5 6 7 8 9 10 11 12
3 4 5 6 7 8 9 10 11 12 13
4 5 6 7 8 9 10 11 12 13 14
5 6 7 8 9 10 11 12 13 14 15
6 7 8 9 10 11 12 13 14 15 16
7 8 9 10 11 12 13 14 15 16 17
8 9 10 11 12 13 14 15 16 17 18
9 10 11 12 13 14 15 16 17 18 19
10 11 12 13 14 15 16 17 18 19 20
Matlab pisagor özel üçgenleri bulan programı broadcast ile hesapladım ve s=10000 için 1.7 küsür saniyede hesapladı.
s=10000;
b=3:2:s;
a=4:2:s;
tic;
c2=sqrt((b.').^2+a.^2);
mask=and(fix(c2)==c2 , triu(ones(size(c2)),0)); %
[rows,cols]=find(mask);
c2 = c2( mask );
b2= b( rows );
a2= a( cols ); %unique
disp([b2.' a2.' c2])
ellapse=toc;
disp(['elleapse time: ',num2str(ellapse)])
Matlab pisagor özel üçgenleri bulan programı broadcast ile hesapladım ve s=10000 için 1.7 küsür saniyede hesapladı.
s=10000;
b=3:2:s;
a=4:2:s;
tic;
c2=sqrt((b.').^2+a.^2);
mask=and(fix(c2)==c2 , triu(ones(size(c2)),0)); %
[rows,cols]=find(mask);
c2 = c2( mask );
b2= b( rows );
a2= a( cols ); %unique
disp([b2.' a2.' c2])
ellapse=toc;
disp(['elleapse time: ',num2str(ellapse)])
Yorumlar
Yorum Gönder