I'm looking for a 2D dynamic array or container class to get to know, love, and use forever more. Want something ready made.
Does QuantLib provide such a thing? |
On Thu, 2008-05-08 at 19:26 -0700, caffeine wrote:
> I'm looking for a 2D dynamic array or container class to get to know, love, > and use forever more. Want something ready made. > > Does QuantLib provide such a thing? No. But if it's just a container you need, what's wrong with std::vector<std::vector<T> >? Luigi -- A little inaccuracy sometimes saves tons of explanation. -- H.H. Munro, "Saki" ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by caffeine
huh? what's wrong it? it's dam slow, that's what's wrong with it.
you may better off using a raw C array. this messags was sent from a mobile device On May 12, 2008, at 4:15 AM, Luigi Ballabio <[hidden email]> wrote: On Thu, 2008-05-08 at 19:26 -0700, caffeine wrote: I'm looking for a 2D dynamic array or container class to get to know, love, and use forever more. Want something ready made. Does QuantLib provide such a thing? No. But if it's just a container you need, what's wrong with std::vector<std::vector<T> >? Luigi -- A little inaccuracy sometimes saves tons of explanation. -- H.H. Munro, "Saki" ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, 2008-05-12 at 06:14 -0700, op wrote:
> huh? what's wrong it? it's dam slow, that's what's wrong with it. > > you may better off using a raw C array. "Somewhat slow" I can see. But "damn slow" I have some difficulties to believe. With the correct optimization flags, any compiler released in the past few years should be able to inline most std::vector calls into accesses to a raw C array. Anyway, you can try Boost.MultiArray instead: <http://www.boost.org/doc/libs/1_35_0/libs/multi_array/doc/index.html> Luigi -- A programming language is low-level when its programs require attention to the irrelevant. -- Alan Perlis ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I see that I was too slow on the "it's too slow" response. :-) Do you have any proof that a compiler will inline std::vector calls into raw C array accesses? If it were true, I would be ecstatic, but I don't believe it for a second. I just stumbled onto boost. I'll take a look at it. Thanks! Pete |
On Mon, 2008-05-12 at 08:49 -0700, caffeine wrote:
> I see that I was too slow on the "it's too slow" response. :-) > > Do you have any proof that a compiler will inline std::vector calls into raw > C array accesses? If it were true, I would be ecstatic, but I don't believe > it for a second. Not "proof" as such---results will probably depend on context. But on my machine, compiling with g++ 4.2.3 and with full optimization turned on (i.e., -O3), the two following programs run in about the same time. It seems pretty good evidence that, at least in this case, operator[] is inlined. However, if allocation is moved inside the outer loop, the vector program runs slower. Either vector creation is slower, or adding the allocation inside the loop changes the inlining policy---your guess is as good as mine. Luigi ------------------------- test1.cpp ------------------------- #include <vector> int main() { std::vector<double> v(10000); for (int j=0; j<10000; ++j) { for (int i=0; i<10000; ++i) v[i] = 42.0; double x; for (int i=0; i<10000; ++i) x = v[i]; } return 0; } ------------------------- test2.cpp ------------------------- int main() { double* v = new double[10000]; for (int j=0; j<10000; ++j) { for (int i=0; i<10000; ++i) v[i] = 42.0; double x; for (int i=0; i<10000; ++i) x = v[i]; } delete[] v; return 0; } -- There are no rules of architecture for a castle in the clouds. -- Gilbert K. Chesterton ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by caffeine
I am no expert, so barely qualify to make the kind of sarcastic comments I make anyway... But, I know quite a few people who refuse to use to use either STD/STL or boost for basic containers or performance sensitive program bits in general. Instead it is "not too difficult" to write your own basic types, allowing you to control such things as what your container is ultimately mapped to, or how you want to implement copy, assignment etc... At the same time you can twist your containers such that they are still supported with most regular STL algorithms."not too difficult" is a euphemism, I know. the best thing is to pick up some classes from someone and then take it from there. there are apparently some really shitty features in boost that you just don't want to have in your software at all.... what about blitz? that any good? ----- Original Message ---- From: Luigi Ballabio <[hidden email]> To: caffeine <[hidden email]> Cc: [hidden email] Sent: Monday, May 12, 2008 12:35:45 PM Subject: Re: [Quantlib-users] 2D Arrays? On Mon, 2008-05-12 at 08:49 -0700, caffeine wrote: > I see that I was too slow on the "it's too slow" response. :-) > > Do you have any proof that a compiler will inline std::vector calls into raw > C array accesses? If it were true, I would be ecstatic, but I don't believe > it for a second. Not "proof" as such---results will probably depend on context. But on my machine, compiling with g++ 4.2.3 and with full optimization turned on (i.e., -O3), the two following programs run in about the same time. It seems pretty good evidence that, at least in this case, operator[] is inlined. However, if allocation is moved inside the outer loop, the vector program runs slower. Either vector creation is slower, or adding the allocation inside the loop changes the inlining policy---your guess is as good as mine. Luigi ------------------------- test1.cpp ------------------------- #include <vector> int main() { std::vector<double> v(10000); for (int j=0; j<10000; ++j) { for (int i=0; i<10000; ++i) v[i] = 42.0; double x; for (int i=0; i<10000; ++i) x = v[i]; } return 0; } ------------------------- test2.cpp ------------------------- int main() { double* v = new double[10000]; for (int j=0; j<10000; ++j) { for (int i=0; i<10000; ++i) v[i] = 42.0; double x; for (int i=0; i<10000; ++i) x = v[i]; } delete[] v; return 0; } -- There are no rules of architecture for a castle in the clouds. -- Gilbert K. Chesterton ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |