diff general/arrutils/vecop.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/general/arrutils/vecop.m	Sat Jan 12 19:21:22 2013 +0000
@@ -0,0 +1,16 @@
+function Z=vecop(F,X,Y)
+% vecop - apply binary function to different sized arrays
+%
+% vecop ::
+%    ([[D]],[[D]]->[[D]])  ~'some function requiring equal size args',
+%    [[DX]]                ~'first arg of size DX',
+%    [[DY]]                ~'second arg of size DY'
+% -> [[DZ]]                ~'result of size DZ' :- DZ=max(DX,DY).
+%
+
+
+DX=size(X); DY=size(Y); 
+E=max(length(DX),length(DY));
+DZ=max(pad1s(E,DX),pad1s(E,DY));
+Z=feval(F,repmat_to(X,DZ),repmat_to(Y,DZ));
+