非常大的数组 [英] Very big arrays

查看:86
本文介绍了非常大的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在尝试用一些存储的值创建一个dll,希望在一个静态数组中存储数百万美元的b
这个:


双delta [x_size] [y_size] [z_size];

void delta_init(){

delta [0 ] [0] [0] = 8.65;

delta [0] [0] [1] = 1.35;

delta [0] [0] [2] = 2.11;

delta [0] [0] [3] = 3.29;

delta [0] [0] [4] = 5.147;


等...


我正在尝试编译Visual C ++ Pro 2005下的代码,代码

就是这么做不编译 - 它运行超过10个小时,只需要手。我虽然
能够编译更小的数组。


如何编译​​代码?有什么更好的方法呢?

感谢您的建议。

Hello,

I''m trying to make a dll with some stored values, looking to store
several million doubles in a static array like this:

double delta[x_size][y_size][z_size];
void delta_init() {
delta[0][0][0] = 8.65;
delta[0][0][1] = 1.35;
delta[0][0][2] = 2.11;
delta[0][0][3] = 3.29;
delta[0][0][4] = 5.147;

etc ...

I''m trying to compile the code under Visual C++ Pro 2005, and the code
just does not compile - it runs over 10 hours and just hands there. I
was able to compile smaller arrays though.

How can I make the code compile? What is a better way to do this?
Thank you for your advice.

推荐答案



victorg ... @ gmail.com skrev:

victorg...@gmail.com skrev:

您好,


我是试图用一些存储的值创建一个dll,希望在这样的静态数组中存储几百万的双倍数:


double delta [x_size] [y_size ] [z_size];

void delta_init(){

delta [0] [0] [0] = 8.65;

delta [0 ] [0] [1] = 1.35;

delta [0] [0] [2] = 2.11;

delta [0] [0] [3] = 3.29;

delta [0] [0] [4] = 5.147;


等...


我正在尝试编译Visual C ++ Pro 2005下的代码,而代码

只是不编译 - 它运行超过10个小时,只需动手。我虽然
能够编译较小的数组。
Hello,

I''m trying to make a dll with some stored values, looking to store
several million doubles in a static array like this:

double delta[x_size][y_size][z_size];
void delta_init() {
delta[0][0][0] = 8.65;
delta[0][0][1] = 1.35;
delta[0][0][2] = 2.11;
delta[0][0][3] = 3.29;
delta[0][0][4] = 5.147;

etc ...

I''m trying to compile the code under Visual C++ Pro 2005, and the code
just does not compile - it runs over 10 hours and just hands there. I
was able to compile smaller arrays though.



它必须是一个有数百万行的程序,然后呢?

It must be a program with millions of lines, then?


>

如何编译​​代码?有什么更好的方法呢?

感谢您的建议。
>
How can I make the code compile? What is a better way to do this?
Thank you for your advice.



技术上它还没有失败,但我不想打赌

编译最终会成功。但是你的问题是平台

具体,所以这里是偏离主题的。去参观一些你会想要讨论主题的小组 - 也许是microsoft.public.vc.language?


/ Peter

Technically it haven''t failed yet, but I don''t want to bet that the
compile will eventually succeed. But your question is platform
specific, so it is off-topic here. Go visit some group where you would
be on topic - perhaps microsoft.public.vc.language?

/Peter



vi********@gmail.com 写道:

您好,


我正在尝试用一些存储的值创建一个dll,想要存储

这样的静态数组中的数百万双:


双delta [x_size] [y_size] [z_size];

void delta_init(){

delta [0] [0] [0] = 8.65;

delta [0] [0] [1] = 1.35;

delta [0] [0] [2] = 2.11;

delta [0] [0] [3] = 3.29;

delta [0] [0] [4] = 5.147;


等...


我正在尝试编译代码在Visual C ++ Pro 2005下,代码

只是不编译 - 它运行超过10个小时,只需要在那里。我虽然
能够编译更小的数组。


如何编译​​代码?有什么更好的方法呢?

感谢您的建议。
Hello,

I''m trying to make a dll with some stored values, looking to store
several million doubles in a static array like this:

double delta[x_size][y_size][z_size];
void delta_init() {
delta[0][0][0] = 8.65;
delta[0][0][1] = 1.35;
delta[0][0][2] = 2.11;
delta[0][0][3] = 3.29;
delta[0][0][4] = 5.147;

etc ...

I''m trying to compile the code under Visual C++ Pro 2005, and the code
just does not compile - it runs over 10 hours and just hands there. I
was able to compile smaller arrays though.

How can I make the code compile? What is a better way to do this?
Thank you for your advice.



大笑,10小时?为什么要在dll中存储值?你的程序可以使用的内存不会那么多吗?你需要在内存中加载吗?

您是否考虑过将这些存储在一个文件或多个文件中?或者

可能会开发一个算法来初始化值?你是否意识到数组需要连续内存?
?为什么不在struct / class中存储相关的

值,而是存储

struct / class的实例?


如果我必须存储积分,例如,使用x,y和az:


#include< iostream>

#include< ; ostream>

#include< vector>

#include< deque>


template< typename T>

struct Point

{

// universal ctor

Point(const T& x_ = T(),

const T& y_ = T(),

const T& z_ = T())

:x(x_ ),y(y_),z(z_){}

//复制ctor

Point(const Point& copy)

{

x = copy.x;

y = copy.y;

z = copy.z;

}

私人:

T x,y,z;

};


int main(){

//一百万分为双打,全部设为0.0

std :: deque<点<双倍容器(1000000); //完成


std :: cout<< double container的大小=" ;;

std :: cout<< dcontainer.size()* sizeof(Point< double>);

std :: cout<< std :: endl;


//作为花车的百万分,全部设为0.0

std :: deque<点< float fcontainer(1000000);


std :: cout<< float container的大小=" ;;

std :: cout<< fcontainer.size()* sizeof(Point< float>);

std :: cout<< std :: endl;


返回0;

}

此平台上的
/ *输出:


双容器'的大小= 24000000 // 24 MB

浮动容器'的大小= 12000000 // 12 MB


* /

lol, 10 hours? Why would you store values in a dll? Wouldn''t that eat
away at memory available to your program - dll must be loaded in mem?
Have you considered storing these in a file or several files? Or
perhaps develop an algorithm to initialize the values? Do you realize
that an array requires contiguous memory? Why don''t you store related
values together in a struct/class and store instances of the
struct/class instead?

If i had to store points, for example, with an x, y and a z:

#include <iostream>
#include <ostream>
#include <vector>
#include <deque>

template< typename T >
struct Point
{
// universal ctor
Point(const T& x_ = T(),
const T& y_ = T(),
const T& z_ = T())
: x(x_), y(y_), z(z_) { }
// copy ctor
Point(const Point& copy)
{
x = copy.x;
y = copy.y;
z = copy.z;
}
private:
T x, y, z;
};

int main() {
// one million Points as doubles, all set to 0.0
std::deque< Point< double dcontainer(1000000); // done

std::cout << "double container''s size = ";
std::cout << dcontainer.size() * sizeof(Point< double >);
std::cout << std::endl;

// one million Points as floats, all set to 0.0
std::deque< Point< float fcontainer(1000000);

std::cout << "float container''s size = ";
std::cout << fcontainer.size() * sizeof(Point< float >);
std::cout << std::endl;

return 0;
}

/* output on this platform:

double container''s size = 24000000 // 24 MB
float container''s size = 12000000 // 12 MB

*/


vi ** ******@gmail.com 写道:

你好,


我是试图用一些存储的值创建一个dll,希望在这样的静态数组中存储几百万的双倍数:
Hello,

I''m trying to make a dll with some stored values, looking to store
several million doubles in a static array like this:



假设sizeof(双倍)== 8,几百万双打

可能占据几十MB。你真的想要一个

大的dll?

Assuming sizeof(double)==8, several million doubles will
likely occupy several tens of MB. You really want a dll that
big?


double delta [x_size] [y_size] [z_size];

void delta_init(){

delta [0] [0] [0] = 8.65;

delta [0] [0] [1] = 1.35;

delta [0] [0] [2] = 2.11;

delta [0] [0] [3] = 3.29;

delta [0] [0] [4] = 5.147;


等...


我正在尝试编译下的代码Visual C ++ Pro 2005,以及代码

只是不编译 - 它运行超过10个小时,只需动手。我虽然
能够编译较小的数组。
double delta[x_size][y_size][z_size];
void delta_init() {
delta[0][0][0] = 8.65;
delta[0][0][1] = 1.35;
delta[0][0][2] = 2.11;
delta[0][0][3] = 3.29;
delta[0][0][4] = 5.147;

etc ...

I''m trying to compile the code under Visual C++ Pro 2005, and the code
just does not compile - it runs over 10 hours and just hands there. I
was able to compile smaller arrays though.



看看硬盘灯,也许编译器耗尽了内存并开始颠簸?

Take a look at the HDD light, perhaps the compiler ran out of
memory and started thrashing?


如何编译​​代码?有什么更好的方法呢?

感谢您的建议。
How can I make the code compile? What is a better way to do this?
Thank you for your advice.



究竟什么不允许你从文件中读取这些数据?


HTH,

- J.

What exactly disallows you to read this data from a file?

HTH,
- J.


这篇关于非常大的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆