Creating Grid from dynamically allocated data - has to be persistent?

17 views
Skip to first unread message

Ben Buckner

unread,
Feb 22, 2022, 2:23:54 PM2/22/22
to Ceres Solver
Hi - I'm having some trouble managing a large set of interpolations, and I'm starting to suspect that ceres' Grid* objects created from a pointer to data only hold a shallow copy, so that if the original data gets deallocated, it crashes. Is this the case, so that the original pointer has to be kept valid as long as the Grid* and derived interpolators are alive?

Thanks,
Ben

1262871536

unread,
Feb 22, 2022, 2:24:12 PM2/22/22
to Ben Buckner
这是来自QQ邮箱的假期自动回复邮件。

您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

Sameer Agarwal

unread,
Feb 22, 2022, 6:24:19 PM2/22/22
to ceres-...@googlegroups.com
Ben,
The grid objects does not make copies of the data, you can see that here


from the grid2d constructor.  So yes, the arrays containing the data need to be live for the lifetime of the Grid object.

Sameer



--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/dd33f14c-d4d9-4b8c-be36-de4f3e2d640an%40googlegroups.com.

Sameer Agarwal

unread,
Feb 22, 2022, 6:25:15 PM2/22/22
to ceres-...@googlegroups.com
This should of course be better documented, but I assumed that the header is small enough that it will be evident to the reader. I will update the header to make this more explicit.

Ben Buckner

unread,
Feb 22, 2022, 8:23:44 PM2/22/22
to Ceres Solver
Thanks Sameer - I was thinking that the interpolator would precalculate some of the interpolation, but from the code, it looks like it's a very thin wrapper, so that there's no reason to store interpolator objects, which is what I was trying to do. I'll just pass data pointers to the cost functions and instantiate the interpolator when it initializes the cost function structure.

1262871536

unread,
Feb 22, 2022, 8:23:57 PM2/22/22
to Ben Buckner

Sameer Agarwal

unread,
Feb 22, 2022, 10:56:30 PM2/22/22
to ceres-...@googlegroups.com
Yes, the interpolator has no precomputed state, just some sanity checks. 

1262871536

unread,
Feb 22, 2022, 10:56:36 PM2/22/22
to Sameer Agarwal' via Ceres Solver <>
Reply all
Reply to author
Forward
0 new messages