Open psycharo-zz opened 11 years ago
I left a comment in the code relating to commit #cc429e0 but I'm not sure if you received that. Any the comment is this:
Just FYI (and please change code accordingly), look at the time elapsed (40X faster) for the following two pieces of code that implement the same:
>> clear results
>> tic
results = struct('id', {}, 'message', {});
for i = 1:1000
results = [results struct('id', y.id, 'message', ffg.gaussMessage(i+randn()*sd, 0, 'VARIANCE'))];
end
toc
Elapsed time is 0.387352 seconds.
>> clear results
>> tic
for i = 1000:-1:1
results(i) = struct('id', y.id, 'message', ffg.gaussMessage(i+randn()*sd, 0, 'VARIANCE'));
end
toc
Elapsed time is 0.099072 seconds.
In matlab, it helps to pre-allocate memory by first initializing the array entry with highest index.
Currently one has to manually propagate messages from step to step for a dynamic network. Maybe extending
Network
with something that allows to specify connections between different (time)steps could work.