void EntrywiseMap ( const AbstractDistMatrix<S>& A, AbstractDistMatrix<T>& B, function<T(S)> func ) { if( A.DistData().colDist == B.DistData().colDist && A.DistData().rowDist == B.DistData().rowDist && A.Wrap() == B.Wrap() ) { B.AlignWith( A.DistData() ); B.Resize( A.Height(), A.Width() ); EntrywiseMap( A.LockedMatrix(), B.Matrix(), func ); } else { B.Resize( A.Height(), A.Width() ); #define GUARD(CDIST,RDIST,WRAP) \ B.DistData().colDist == CDIST && B.DistData().rowDist == RDIST && \ B.Wrap() == WRAP #define PAYLOAD(CDIST,RDIST,WRAP) \ DistMatrix<S,CDIST,RDIST,WRAP> AProx(B.Grid()); \ AProx.AlignWith( B.DistData() ); \ Copy( A, AProx ); \ EntrywiseMap( AProx.Matrix(), B.Matrix(), func ); #include <El/macros/GuardAndPayload.h> #undef GUARD #undef PAYLOAD } }