|
From: Luigi B. <lui...@gm...> - 2007-04-19 14:35:59
|
On Thu, 2007-04-19 at 15:47 +0200, DU VIGNAUD DE VILLEFORT FRANCOIS GASAPRD PHI wrote: > I have tried to removing the dependency on Array class from the > optimization framework. One change leading to another it turns out > that Arrray dependencies could be removed in the whole QL ! > The only change I had to do was to provide missing operators an > independent header file and all worked fine. As a result I’m wondering > if using plain std::vector instead of Arrray wouldn’t be more > efficient in terms of compilation efficiency and flexibility of use. > (if one want to use linear algebra he has just to include a file > defining new operators…). François, it doesn't sound right to me, for a couple of reasons: - you're changing the std::vector interface by adding operators. I'm not sure that it is legal C++. Moreover, this might be done without the user knowing it if he happens to include a file which in turn includes your new operators. Thus, code which according to the C++ standard is not valid (such as w = u+v if u,v,and w are std::vectors) would silently become legal. I'm not comfortable with this. - there's a conceptual difference between the two classes, and using std::vector for both would confuse the issue. std::vector is a container; Array is the linear-algebra concept of an array. I, too, had been thinking of replacing Array with an STL class, but the right one would be std::valarray---which models the right concept and already defines the required operators. Later, Luigi ---------------------------------------- If you can't convince them, confuse them. -- Harry S. Truman |