I think you're asking the wrong question. The right question would be (assuming 8 byte doubles), why are you trying to eat over 16 gigabytes for a single vector? The naive approach isn't likely to work in this case, you need to consider alternative algorithms that don't waste so much memory.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>I really need to store all that data.
Every time I hear somebody say that, they turn out to be wrong. :icon_rolleyes:
>I think I really want a vector.
No, you want multiple vectors. If you're hitting the memory limit of a single vector, it's only a minor inconvenience to extend that limit with a vector of vectors.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
you obviously are not using MS-Windows or *nix operating systems, because the max amount of ram supported by 64-bit MS-Windows is 128 gig.
one way to do what you want is to store the data in two or more arrays and use one of the arrays depending on the value of i.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>When I talk about the i-th element, what would i be?
I'd probably use two indices where a simple calculation represents your value's index. So if you divide your vectors into 100 element blocks and there are ten of them, the item at "index" 356 would be located at v[3][56] in the actual vector (conceptually 3 * 100 + 56).
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>>if you can have it in memory, then you can have it in a vector.
No it doesn't. If he is still using 32-bit compiler than the size of the long int is not changed from what it is on a 32-bit operating system, and the STL libraries will still be 32-bit libraries. He will need to use a 64-bit compiler to make any use of the 64-bit os.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
It's so simple (no need in DaniWeb;)), ask your compiler:
typedef std::vector<double> DblVector;
typedef std::vector<int> IntVector;
DblVector dv;
IntVector iv;
cout << sizeof(DblVector::size_type) << '\n';
cout << dv.max_size() << '\n';
cout << iv.max_size() << endl;
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
If you are using that much memory, you will be much better off using the boost array/multi_array classes. Then you will be better off using Blitz.
Word of warning: write the code using boost/stl untill it works with smaller data sets. THEN use Blitz. Otherwize the error messages and other problems are incomprehensible.
StuXYZ
Practically a Master Poster
680 posts since Nov 2008
Reputation Points: 760
Solved Threads: 138