[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #65704] hmst
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #65704] hmst |
Date: |
Tue, 7 May 2024 17:37:09 -0400 (EDT) |
Follow-up Comment #2, bug #65704 (group octave):
f=sym([10 30 50 70 90])
pw=[1 1 1 1 0;1 1 1 0 1;1 1 0 1 1;1 0 1 1 1;0 1 1 1 1;1 1 1 0 0;1 1 0 1 0;1 1
0 0 1;1 0 1 1 0;1 0 1 0 1;1 0 0 1 1;0 1 1 1 0;0 1 1 0 1;0 1 0 1 1;0 0 1 1 1;1
1 0 0 0;1 0 1 0 0;1 0 0 1 0;1 0 0 0 1;0 1 1 0 0;0 1 0 1 0;0 1 0 0 1;0 0 1 1
0;0 0 1 0 1;0 0 0 1 1;1 0 0 0 0;0 1 0 0 0;0 0 1 0 0;0 0 0 1 0;0 0 0 0 1;0 0 0
0 0];
%% SHORT but SLOW
tic
for d=1:10
U=sum(prod(repmat(f,size(pw,1),1).^pw,2))
end
toc
%% LONG but FAST
tic
for d=1:10
t=ones(sym([size(pw,1),1]));
p=pw;
for i=1:5
while(any(p(:,i)))
c=p(:,i) > 0;
t(c)*=f(i);
p(c,i)-=1;
end
end
V=sum(t)
end
toc
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65704>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/