glenco / SLsimLib

Library for Gravitational Lensing Simulations
MIT License
2 stars 1 forks source link

Structure Point : adding a boolean to say if the image point has been defined ? #81

Closed FabienNugier closed 9 years ago

FabienNugier commented 9 years ago

I was having an EXC_BAD_ACCESS problem with a vector X for which I was calling X.image->x[0,1], but it was not defined. I think we should add a boolean in the structure Point that would say true if the function LinkToSourcePoints has been called. Also, when the configuration of the lenses has been changed, for example by calling clearMainHalos (but also probably other functions), one could reset this boolean to false in order to force the user to link image and source points again. What do you think ?

rbmetcalf commented 9 years ago

I don't agree. The Grid and Points are separate from the lens so they cannot be updated when the lens changes. The image pointer is set to null by default so if LinkToSourcePoints has not been called it will still be set to that.

In addition, if X is a vector of Points, X.image->x should give you an error because you haven't specified which element of the vector you are referring to.

FabienNugier commented 9 years ago

Hi, thanks for your reply. I comment below.

On 29 Sep 2015, at 19:59, Ben Metcalf notifications@github.com wrote:

I don't agree. The Grid and Points are separate from the lens so they cannot be updated when the lens changes. The image pointer is set to null by default so if LinkToSourcePoints has not been called it will still be set to that.

Okay. Then maybe we could at least put a boolean that says that it was called already once ?

In addition, if X is a vector of Points, X.image->x should give you an error because you haven't specified which element of the vector you are referring to.

I was too quick here, I meant for sure X[0].image->x[0,1].

Reply to this email directly or view it on GitHub https://github.com/glenco/SLsimLib/issues/81#issuecomment-144037497.

rbmetcalf commented 9 years ago

You can just write if(point.image != NULL) .....

I have always wanted to make source points and image point integrated into one class so that LinkSourcePoints would not be necessary and a lot of memory could be saved, but every time I have attempted it I have run into complications and aborted. Some day perhaps, but it would be a major disruption.

FabienNugier commented 9 years ago

Okay. Thanks !

On 30 Sep 2015, at 16:13, Ben Metcalf notifications@github.com wrote:

You can just write if(point.image != NULL) .....

I have always wanted to make source points and image point integrated into one class so that LinkSourcePoints would not be necessary and a lot of memory could be saved, but every time I have attempted it I have run into complications and aborted. Some day perhaps, but it would be a major disruption.

— Reply to this email directly or view it on GitHub https://github.com/glenco/SLsimLib/issues/81#issuecomment-144322483.