Registered Member
|
Hi,
the use of a custom function for .unaryExpr() is a bit clumsy. Using the CwiseUnaryOp struct is probably the most versatile approach, but in most cases the user just wants to specify a specific function Scalar func(Scalar). Thus I wrote this piece of code:
Though, it would be great, if one could use .unaryExpr<func_name>() additionally to .unaryExpr(CwiseUnaryOp). So .unaryExpr<func_name>() would just call .unaryExpr( CwiseOp<Scalar, func_name> ). The only problem with my struct is, that you have to declare it for any return and argument type:
What do think about that? |
Moderator
|
Hi,
you can already do that using STL's ptr_fun construct, e.g.: B = A.unaryExpr(std::ptr_fun(fabs)); |
Registered Member
|
oh, ok. Thanks!
Would be great if it would be added to the documentation of unaryExpr(), because I guess this is a common problem. Cheers, Manuel |
Registered Member
|
Hi, it's me again!
Is there any possibility to execute the unaryExpr() only on non-zero elements of a sparse matrix? Cheers, Manuel |
Moderator
|
|
Registered Member
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft