简体   繁体   English

如何缩放非常大的数字,以便它们可以表示为数组索引?

[英]How to scale very large numbers such that they could be represented as an array index?

I have a 2D array of size 30*70.我有一个大小为 30*70 的二维数组。

I have 70 columns.我有 70 列。 My values are very large ranging from 8066220960081 to (some number with same power of 10 as lowerlimit) and I need to plot a scatter plot in an array.我的值非常大,范围从 8066220960081 到(与下限相同的 10 次幂的某个数字),我需要 plot 在数组中分散 plot。 How do I index into the array given very large values?给定非常大的值,如何索引到数组中?

Also, I need to do this in kernel space另外,我需要在 kernel 空间中执行此操作

Let's take an array long long int A with large values.让我们取一个具有大值的数组 long long int A。

A[0] = 393782040
A[1] = 2*393782040
... and so on
A[N] = 8066220960081; where N = 30*70 - 1

We can scale A with a factor or we can shift A by a certain number and scale it again.我们可以用一个因子缩放 A,或者我们可以将 A 移动某个数字并再次缩放它。 That's where you can deal with numbers ranging between 0 and 1 or -1 and 1 or x and y.这就是您可以处理介于 0 和 1 或 -1 和 1 或 x 和 y 之间的数字的地方。 You choose as per your need.你根据自己的需要选择。 Theoretically, this should not make a difference to the scatter plot other than the placement of the axis.从理论上讲,除了轴的放置之外,这不会对散点图 plot 产生影响。 However, if your scatter plot is also a representative of the underlying values ie the dots are proportional to values;但是,如果您的散点图 plot 也是基础值的代表,即点与值成比例; then it is a good idea to be nice to your plotting tool and not flood it with terribly large values that might lead to overflow depending on how the code for plotting is written.那么最好对你的绘图工具友好,不要用非常大的值淹没它,这可能会导致溢出,具体取决于绘图代码的编写方式。

PS: I would assume you know how to flatten a 2d array. PS:我假设您知道如何展平二维数组。

I just ended up doing regular interval calculation between max and min and then start from min + interval*index to get the number.我刚刚结束了在 max 和 min 之间进行定期间隔计算,然后从 min + interval*index 开始获取数字。 index would be the index in array. index 将是数组中的索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM