Hi,
I want to create 4 dimensional array, in that first three dimenstional are fixed size and the final index will be on 0 to N-numbers.
For eg, double array[500][25][10][<NOT FIXED>].. So I cant create statically, because the index size are more. Also I have tried 4 dimenstional vector, but its giving 2 problem.
(i) I am storing 4th dimenstion size is more than vector[0][0][0].max_size()
(ii) Storing and Retrieving its more time in vector
So Please let me know, if any other solution to store large array which is 3 index is FIXED and final one is not FIXED?
Looking for answer from anyone..
Thanks.
19 9495
Hi,
Thanks for your reply.
Can you some example or link to create the own array on the heap?
The example is in the article linked to in my post #2.
Banfa 9,065
Recognized Expert Moderator Expert
On the whole if you have optimisation switched on storing and retrieving from a vector is the same as for an array.
Hi,
Thanks for your answer.
double array[500][25][10][<NOT FIXED>].
I am achieving this using vector(vector(vector(vector(double)))) dBuffer(....);
As of now I am using vector[500][25][10][UnknownSize].
UnknownSize will be decided on run time. It is working fine.
But I am facing 2 problems.
(i) I am storing 4th dimenstion size is more than
vector[0][0][0].max_size()
(ii) Storing and Retrieving its taking more time in vector for large index.
Pls suggest any other method.
On my system, a vector<double> can hold 62 million doubles. You have more than that?
Hi, I could able to store in my double vector is = 536870911..
But I need more than this index.
How many doubles do you need?
Banfa 9,065
Recognized Expert Moderator Expert
Given that a double is 8 bytes (which it normally is) 536870911 of them take about 4GiB which if you are using a 32 bit operating system is likely to be the limit of the virtual memory space for your program.
If that is the case using an array wont help because the limit is the process memory space not what an individual array or vector can hold.
If you are using that much data use a file or a memory mapped file.
Hi,
I need to create the double vector of
500*32*16*<un_knownsize>..The final element i will push in runtime...
Hi Banfa,
1) If i increase the virtual memory whether I can push much element.
2) More over I am not aware of memory mapped file. Please could you give some example to achieve.
Are you able to use database engine like Oracle? I'm starting to think that you will need to desing a database engine that more in it than one array.
I can use database engine but it will take more time to insert data and retrieve back again.But my requirement is around I will take around 300MB of data in buffer then I will process and convert into double values, this size will be around 3.5GB, then I have to write into file. But if i use database everytime i have to insert then at the end i have to read back from database then I have to write into the file.
Except Oracle doesn't work that way - and it can handle terabyte tables.
As can, I believe Microsoft SQL Server.
I am starting to worry that you will send a ton of time writing a database handler rather than processing your doubles.
I have personally written a semented database from scratch to handle table than spanned six hard discs. It worked but I spent a lot of time getting it to work.
BTW: During this talk of a 4D array I need you to be clear that there are only 1D arrays in both C and C++. The "dimensions" are just a way of getting the compiler to do your pointer arithmetic.
Banfa 9,065
Recognized Expert Moderator Expert
BTW: During this talk of a 4D array I need you to be clear that there are only 1D arrays in both C and C++. The "dimensions" are just a way of getting the compiler to do your pointer arithmetic.
I have to admit to be slightly surprised that you didn't say this in your first post.
Are you sure a database is required? It sounds like the process is - Read Data
- Process Data
- Write File
If (BIG IF) the data can be processed linearly and written straight to file then you don't actually need to do any more than store the original 300MByte of data which isn't so bad.
Are you sure a database is required:
You may be right, but hard to say since the number of doubles required is unknown. That raises the possibility the data will exceed the maximum file size and that would result in a segmented data structure. The result is spending time on things other than processing the data.
Try This Code -
-
#include <stdio.h>
-
int main()
-
{
-
-
int i, j, k, l, size;
-
-
int a[2][2][2][2];
-
-
size = 2;
-
-
a[0][0][0][0] = 5;
-
a[0][0][0][1] = 3;
-
a[0][0][1][0] = 5;
-
a[0][0][1][1] = 3;
-
a[0][1][0][0] = 6;
-
a[0][1][0][1] = 7;
-
a[0][1][1][0] = 6;
-
a[0][1][1][1] = 7;
-
a[1][0][0][0] = 8;
-
a[1][0][0][1] = 9;
-
a[1][0][1][0] = 8;
-
a[1][0][1][1] = 9;
-
a[1][1][0][0] = 9;
-
a[1][1][0][1] = 7;
-
a[1][1][1][0] = 9;
-
a[1][1][1][1] = 7;
-
-
for (i = 0; i < size; i++) {
-
for (j = 0; j < size; j++) {
-
for (k = 0; k < size; k++) {
-
for (l = 0; l < size; l++) {
-
printf("Value of a[%d][%d][%d][%d] :- %d ",
-
i, j, k, l, a[i][j][k][l]);
-
printf("\n");
-
}
-
}
-
}
-
}
-
return 0;
-
}
Banfa 9,065
Recognized Expert Moderator Expert
@Sherin, I don't think you have appreciated the problem that this thread is about which is not having a 4 dimensional array but rather processing and extremely large volume of data. Because of that the rather trivial example code posted is of little to no use in solving the actual problem.
@weaknessforcats
"there are only 1D arrays in both C and C++. The "dimensions" are just a way of getting the compiler to do your pointer arithmetic."
That is interesting. Instead of looking at it as multi-dimensional, maybe I should look at it as single dimensional with a potential for dimensions inside of that first dimension like a tree. Start with one dimension and get that to work, then work on one more dimension at a time getting each of those to work before going on to more of the tree.
Thanks: This is an easier way to look at it (for me).
I am working on (still at it) a shortest path algorithm (with variably changing constraints) that can handle a 1,000+ by 1,000+ grid. I was considering multi-dimensional vectors and trying to get that to work. I think that I shall go back to designing based upon a single dimension vector now; and potentially use other dimensions for variable conditions within that first dimension's elements.
Maybe as a single dimension like this?
vector <std::wstring> Grid_X_Y (1000000);
to start. Then I can concatenate the elements as data is added or changed.
Or maybe with multiple dimensions like this?
vector <std::wstring> Grid_X_Y (1000000,10);
to start. Then I can add up to 10 values per each of the first dimension's elements. This might make it easier to choose a value later rather than having to parse each wstring as in the single dimension example.
Maybe this process might help the OP.
Thank you weaknessforcats .
Thank you bytes.com .
Glory to God .
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nick |
last post by:
Loop to create an array from a dynamic form.
I'm having trouble with an application, and I'll try to explain it as
clearly as possible:
1. I have a form with two fields, say Apples and...
|
by: nobody |
last post by:
hello everybody,
is there a way of creating an array with help of a function that would
accept the name of this array as a parameter and then create global
Array type variable of that name?
so...
|
by: Piotre Ugrumov |
last post by:
I have tried to write the class Student(Studente), Teacher(Docente). This
classes derive from the class Person.
In a class university(facoltà). I have tried to create an array of Student
and an...
|
by: billy |
last post by:
I've got a set of subclasses that each derive from a common base class. What
I'd
like to do is create a global array of the class types (or, class names)
that a manager
class can walk through in...
|
by: SAN CAZIANO |
last post by:
is there a function that get the name of the first input field of the
current form ?
in my example below I want create an array of form field name and in the
onsubmit assign all element's name to...
| |
by: jhs |
last post by:
Hello,
I developping a .NET windows form application an need some help to create an
array of System.Windows.Forms.Label in order to be able to manage all of
them using index.
I'm trying to do...
|
by: Wendell Wilkie |
last post by:
I am working with a 3rd party unmanaged dll, and I need to pass an array of
char* as an argument.
I can used fixed to get a single char* as follows:
char buf = new char;
fixed (char* p = buf)...
|
by: Big Charles |
last post by:
Hello,
I would like to create an array-class to be able to call like:
Dim oMyCar as New MyCar
' After initializing oMyCar, the object has to be like:
oMyCar(0).Brand...
|
by: memeticvirus |
last post by:
I have an array cli::array<float, 2and I would like to access a
subset of it's values by compiling an array of pointers. But, it's not
possible to create an array of type...
|
by: David K in San Jose |
last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that
form I'm trying to invoke some static functions by using an array of function...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |