ha, this actually happens in my one of my graduate program, where we must handle the product of a bunch of probability tables, such as
P(A, B, C) P(D, C) P(D, A) P(B, E), each table is large, and when you want to multiply them together, you must specify an order, such as A, B, C, D, E to ensure the result is right. Sometimes the variable order in different tables contradicts, such as P(A, B)P(C, B, A), so the variable ordering must...
User Profile
Collapse
-
When I started using C++, I remember some code regarding multi-dimensional arrays can not compile in some compiler, but was OK in other compilers. This might not be a problem anymore: )
the vector<int> is used for storing sizes of each dimension. For example, for a 2*2 table, the vector<int> is [2,2], for a 3 * 5 * 9 table, the vector<int> is [3, 5, 9]
In this way, we can create different abstract table...Leave a comment:
-
In my opinion, using multidimensiona l arrays is always a BAD choice. It is not flexible, it is not easy to read, it suffers from distinction between compilers.
Probably the most convenient solution is use one dimensional array and adding your own dimension management. In this case, I suggest a one dimensional array for storing pointer to string, like this:
vector<string*> my_array;
then you add...Leave a comment:
-
The problem is: the allocator you passed to STL container is an allocator for ALL types, not only for the specific type you need. For example
when use
std::list<T, alloc>, the alloc has to be able to allocate T, rebind<T>, ...
One possible solution is to override the default allocator with a two layer allocator, on the first layer, we check the size of memory required, and map specific memory requirement...Leave a comment:
-
a problem on fixed length allocator and data structures
Recently I am trying to develop a C++ program dealing with large scale DAGs (about 6,000,000 nodes and 50,000,000 edges), and I find a very serious problem here.
In the program, the node and edges are frequently added and deleted, so the key point is to avoid memory fragmentation, in other word, all the nodes and edges must be allocated from a chunk-based fix length allocator, so the deleted entries can be managed and re-used without...
No activity results to display
Show More
Leave a comment: