[eigen] Sign function
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: [eigen] Sign function
• From: Carlos Becker <carlosbecker@xxxxxxxxx>
• Date: Sat, 8 Dec 2012 12:26:41 +0100
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=/mTjgHe6IhyILfz5hkEeLVzcj/UrN/CnIPqO9Tor4YU=; b=obLlOC1mQGmsH+SMKJQoYlmIA9mcTT4HojOiovJjqwcPo7KB15BQjCZIllWBsNiUu9 i3AIAQSv9dTii/3Q32Im4Pt2PTKExC5WSL3xmBwftsljRX3+KIwdNjAIJO8Zy1xrciTN HPzMuKi0pneWz0r0U7oqMNfAb6gNNAdiKPvyAbscgUwBzjzesUq2Bd7KzaPafnKyIZIq rM5jXjaweTge5an/fMR3TnrYECjPr1+8sAVL2ldIBsgIHMLEUmra38diuf46ulBuyoTj KasfK1IScP7hACfQerJlmjAnrS3iw9+VSjiwkJdR0I9EqQeRw6WKZO2VwfF8d8kody0a JFmQ==

Hello everyone,

I am wondering which would be the fast way to compute the sign of every element in a vector or matrix, since I have to do the following element-wise:

A = A + k * sign(B)

where A and B are double matrices and k is a scalar.

I was trying to find some information in the docs but so far I didn't succeed.
I know I can do a boolean operation and then cast to double, multiply by 2 and subtract 1, but that doesn't seem very efficient.

Maybe some kind of custom element-wise processing, since it would be enough to compute the sign and then add k or -k to each element of A ?

Thanks!

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/