Hi,
I would like to instantiate several thousand times the same contractor C, for example:
class C:ibex::Ctc { public: C(){}; void contract(ibex::IntervalVector &box) { ibex::Variable v1(2); ibex::Variable v2(2); ibex::Function f(v1,v2,v1+v2); f.backward(box); } }
In order to save memory and time, I would like to have the Function defined only once as a static member of the class:
class C:ibex::Ctc { public: C(){}; static ibex::Function f; void contract(ibex::IntervalVector &box) { f.backward(box); } } ibex::Variable v1(2); ibex::Variable v2(2); ibex::Function C::f(v1,v2,v1+v2);
However, instantiation of global ibex::Variable throws a segmentation fault at execution.
For example, this minimalistic main file compiles and runs:
#include <ibex/ibex.h>
int main() { ibex::Variable v0(1); return 0; }
While this one compile but throws a segmentation fault at runtime:
#include <ibex/ibex.h>
ibex::Variable v0(1);
int main(){ return 0; }
Could you tell me where am I wrong?
Regards
zenno
Mon, 07/07/2014 - 12:02
Permalink
Hi Jeremy,
Hi Jeremy,
Your last piece of code:
does not throw a segmentation fault in my computer. Which version of the code are you using exactly?
It's a very good idea however to create the function once, statically. Note that you can avoid creating Variable object using string directly. The following program works:
Output:
Regards,
Gilles
Jeremy Nicola
Tue, 07/08/2014 - 18:27
Permalink
Hello Gilles,
Hello Gilles,
thank you for your prompt reply.
For some reason, I don't get the segmentation fault anymore.
It may be that it was due to the order I was using when linking the libraries (soplex, prim, ibex), but I can't reproduce this message anymore...
Anyway, thank you!
zenno
Wed, 07/09/2014 - 15:04
Permalink
Libraries linking order
You are welcome.
I think pkg-config is automatically ordering librairies correctly.
See comment here: http://www.ibex-lib.org/comment/6#comment-6
Regards,
Gilles