samer@4: function B=mouter(varargin) samer@4: % mouter - Multidimensional outer product of multiple arrays samer@4: % Index domain of result is the concatenation of the index domains samer@4: % of the arguments, (with trailing 1s removed). samer@4: % samer@4: % mouter :: [Size1->A], [Size2->A] -> [[Size1,Size2]->A]. samer@4: % mouter :: [Size1->A], [Size2->A], [Size3->A] -> [[Size1,Size2,Size3]->A]. samer@4: % etc. samer@4: B=1; samer@4: for i=1:length(varargin) samer@4: B=kron(varargin{i},B); samer@4: end samer@4: B=reshape(B,cell2mat(cellmap(@size1,varargin))); samer@4: