Registered Member
|
hi,
i found something strange. i'll let the code speak for itself:
output is: bad: 1 8 7 6 5 1 3 2 1 0 good: 1 0.8889 0.7778 0.6667 0.5556 1 0.75 0.5 0.25 0 Seems like cwise() doesn't take into account the replicated data. Cheers, Marton
Last edited by ggael on Fri May 29, 2009 6:34 am, edited 1 time in total.
|
Registered Member
|
Never mind, I wrote a description of the bug in bitbucket's issue tracker. Maybe an admin can even delete this thread?
|
Moderator
|
I answer here because this is not a bug and might be interesting for others.
Actually, this is an aliasing issue due to expression templates. Here x.col(0) return a reference to the first column element of x. When you write:
the values of x.col(0) are modified during the evaluation... This is equivalent to:
The best solution is to copy x.col(0) to a temporary using .eval():
|
Registered Member
|
Doh! Maybe I should have thought first.
Thanks, Gael, for the prompt answer! |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]