Home > GLMdenoise > utilities > mtimescell.m

mtimescell

PURPOSE ^

function f = mtimescell(m1,m2)

SYNOPSIS ^

function f = mtimescell(m1,m2)

DESCRIPTION ^

 function f = mtimescell(m1,m2)

 <m1> is A x B
 <m2> is a cell vector of matrices such that cat(1,m2{:}) is B x C

 simply return <m1>*cat(1,m2{:}) but do so in a way that doesn't cause 
 too much memory usage.

 example:
 x = randn(10,20);
 y = randn(20,200);
 result = x*y;
 result2 = mtimescell(x,splitmatrix(y,1,repmat(2,[1 10])));
 allzero(result-result2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f = mtimescell(m1,m2)
0002 
0003 % function f = mtimescell(m1,m2)
0004 %
0005 % <m1> is A x B
0006 % <m2> is a cell vector of matrices such that cat(1,m2{:}) is B x C
0007 %
0008 % simply return <m1>*cat(1,m2{:}) but do so in a way that doesn't cause
0009 % too much memory usage.
0010 %
0011 % example:
0012 % x = randn(10,20);
0013 % y = randn(20,200);
0014 % result = x*y;
0015 % result2 = mtimescell(x,splitmatrix(y,1,repmat(2,[1 10])));
0016 % allzero(result-result2)
0017 
0018 f = 0;
0019 cnt = 0;
0020 for q=1:length(m2)
0021   f = f + m1(:,cnt + (1:size(m2{q},1))) * m2{q};
0022   cnt = cnt + size(m2{q},1);
0023 end

Generated on Fri 01-Aug-2014 12:03:17 by m2html © 2005