accessing elements of Eigen types

0 views
Skip to first unread message

Ben Goodrich

unread,
Jan 17, 2012, 1:55:16 AM1/17/12
to stan development mailing list
As explained here

http://eigen.tuxfamily.org/dox/QuickRefPage.html

in the section on Basic Matrix Manipulation of Eigen types,

y[i] // checks to make sure i is not outside range
y(i) // checks range unless NDEBUG is defined
y(i,j) // checks range unless NDEBUG is defined

Our makefile passes -DNDEBUG, but you can take that out temporarily to
check whether a new function has range errors. And we should probably
have Jenkins not pass -DNDEBUG ever.

But the big problem is that there are a ton of instances in stan's C++
files that use the bracket notation, meaning that we waste wall time
range checking every little thing. I grepped 547 instances, but some
of those are false positives. We probably should fix all of them.

Ben

Bob Carpenter

unread,
Jan 17, 2012, 1:27:01 PM1/17/12
to stan...@googlegroups.com
Thanks -- I'd somehow missed that important
bit of range checking detail:

On 1/17/12 1:55 AM, Ben Goodrich wrote:
>
> y[i] // checks to make sure i is not outside range
> y(i) // checks range unless NDEBUG is defined
> y(i,j) // checks range unless NDEBUG is defined

> Our makefile passes -DNDEBUG, but you can take that out temporarily to
> check whether a new function has range errors. And we should probably
> have Jenkins not pass -DNDEBUG ever.

I agree.

Maybe we could even do a strict check
that both work.

> But the big problem is that there are a ton of instances in stan's C++
> files that use the bracket notation, meaning that we waste wall time
> range checking every little thing. I grepped 547 instances, but some
> of those are false positives. We probably should fix all of them.

I agree here, too.

Probably most of those are false positives. I don't
do much manipulation of Eigen matrices outside of
I/O and the promotion to auto-dif, but then again,
I'll probably be surprised.

We'll still need to check std::vector ranges for arrays.

- Bob

Reply all
Reply to author
Forward
0 new messages