Mercurial > hg > ishara
annotate general/funutils/maprows.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children |
rev | line source |
---|---|
samer@4 | 1 function Y=maprows(f,X) |
samer@4 | 2 % maprows - Map a function of a vector over the rows of an array |
samer@4 | 3 % |
samer@4 | 4 % maprows :: |
samer@4 | 5 % ([[1,N]->A] -> [[1,M]->B]) ~'function maps a row of A to a row of B', |
samer@4 | 6 % [[L,N]->A] |
samer@4 | 7 % -> [[L,M]->B]. |
samer@4 | 8 |
samer@4 | 9 n=size(X,1); |
samer@4 | 10 if n==0, Y=[]; |
samer@4 | 11 else |
samer@4 | 12 for i=n:-1:1 |
samer@4 | 13 Y(i,:)=f(X(i,:)); |
samer@4 | 14 end |
samer@4 | 15 end |
samer@4 | 16 |