|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
2D Arrays?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? |
|
|
Re: 2D Arrays?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 QuantLib-users@... https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
|
|
|
|
Re: 2D Arrays?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 QuantLib-users@... https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
|
Re: 2D Arrays?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 |
|
|
Re: 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 QuantLib-users@... https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
|
|
| Free Forum Powered by Nabble | Forum Help |