Re: [eigen] Sign function |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Sign function
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sat, 8 Dec 2012 14:08:25 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=/kAMAMx/rs4P8HXOrKw51NLmS9OWhaJu9afeTltVczo=; b=oXhkri4Z7n+2UCEs2d+5nDtsqyw1ijsGP/3hyRc++W5XkZVwEDu9tEPu1XpmpSMpvl FLuYliiHWsZ8z8xSpFdWzhk1S2mhjN23pvjNKQxMHTMdqvIoAMbRgOW2YyOLtby1Ne4x SVZGbvZ4s5iDWU6sW79ZjHUK5IHSnZ5Xw7fQNvhDAuT6C1wdhmjsRvFIoGECLq2niWcn EcPebCVTJ52LEnR8TjBGpWSV+0/vl0ZyUIAQybzjWqu4G3N02l8sLPKFPufOq8vEExxF 6m4/GGy0513iDoKcSG+Xo9zmYCOdiYNOVz7eBrlEp2rE8QQHF6PGyc6oKVX+Xy4wlOKF RYpw==
You can do something like:
A += (B.array()>0)..select(MatType::Constant(k),-k);
Unfortunately the following cannot work because we have to know the matrix type returned by select from at least one of its arguments:
A += (B.array()>0).select(k,-k);
You can also use B.unaryExpr(std::ptr_fun(sign)) to reproduce "sign(B)".
gael