blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
404 stars 83 forks source link

The index type and limits of the Blitz++ Array #111

Open guanghaoli opened 5 years ago

guanghaoli commented 5 years ago

Hello! I want to use a very very large Array for programming, which is bigger than 2147483646, the maximum value of int type. So I choose unsigned int as the Array type. However, I can not get the data stored in the Array through unsigned int type of index. Is the index type of Array int? What's the limited size of Array? How can I deal with a very very large array using blitz++ library?

lutorm commented 5 years ago

The index type is size_t. As long as you compile as 64-bit, the max size of the array should not be a limitation.

On Tue, Apr 9, 2019, 18:13 Guanghao Li notifications@github.com wrote:

Hello! I want to use a very very large Array for programming, which is bigger than 2147483646, the maximum value of int type. So I choose unsigned int as the Array type. However, I can not get the data stored in the Array through unsigned int type of index. Is the index type of Array int? What's the limited size of Array? How can I deal with a very very large array using blitz++ library?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/blitzpp/blitz/issues/111, or mute the thread https://github.com/notifications/unsubscribe-auth/AFK8GMqfZWPSpzRN26zPyKXtDNC4ZXj1ks5vfWTOgaJpZM4cmFDF .

guanghaoli commented 5 years ago

The index type is size_t. As long as you compile as 64-bit, the max size of the array should not be a limitation. On Tue, Apr 9, 2019, 18:13 Guanghao Li @.***> wrote: Hello! I want to use a very very large Array for programming, which is bigger than 2147483646, the maximum value of int type. So I choose unsigned int as the Array type. However, I can not get the data stored in the Array through unsigned int type of index. Is the index type of Array int? What's the limited size of Array? How can I deal with a very very large array using blitz++ library? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#111>, or mute the thread https://github.com/notifications/unsubscribe-auth/AFK8GMqfZWPSpzRN26zPyKXtDNC4ZXj1ks5vfWTOgaJpZM4cmFDF .

Thank you very much for your reply. However, how can I solve this problem? image

In this statement "curr_id = Mut_trace(curr_cell_id,1);", curr_id is a size_t value and Mut_trace is a size_t Array, curr_cell_id is a size_t value. When I change the type of curr_cell_id to an int value, the problem is solved. This method is useful for values that are smaller than 2147483646. How can I solve this when the value is bigger?

AnderOne commented 5 years ago

Here one can see that int is used for indices of Array: https://github.com/blitzpp/blitz/blob/master/blitz/array-impl.h#L1707

In other cases, this method will been instantiated: https://github.com/blitzpp/blitz/blob/master/blitz/array-impl.h#L1984

For example:

#include <blitz/array.h>

using namespace blitz;

int main() {
    Array<float, 2> A(5, 10);
    A = -9.57;
    float a;
    unsigned iu = 0;
    short is = 0;
    int ii = 0;
    //a = A(iu, 1); //Compilation error!
    //a = A(is, 1); //Compilation error!
    a = A(ii, 1);
    return 0;
}
guanghaoli commented 5 years ago

OK, thank you very much! I'll try other methods to deal with large value.