I have an array which stores values of precalculate results at certain
positions (x,y):
Theoretical, it would look like this:
Dim sngArr(200000,200000) as single
For example sng(1,1) would be 0.003923
Of course this is not possible due to the memory capacity.
Any wild ideas how you would do that?
Any input is welcome!
|
|
0
|
|
|
|
Reply
|
Anders
|
9/10/2010 5:32:09 AM |
|
"Anders Jorgenson" <a.jorg@lycos.com> wrote in message
news:%23$Uc5mKULHA.5432@TK2MSFTNGP05.phx.gbl...
>I have an array which stores values of precalculate results at certain
>positions (x,y):
>
> Theoretical, it would look like this:
>
> Dim sngArr(200000,200000) as single
> For example sng(1,1) would be 0.003923
>
> Of course this is not possible due to the memory capacity.
> Any wild ideas how you would do that?
> Any input is welcome!
Put the points in an array, then loop through it. Example air code:
Private Type TMyPoints
x As Long
y As Long
Value As Single
End Type
Private MyPoints() As TMyPoints
Private MyPointsCount As Long
Private Sub Form_Load()
ReDim MyPoints(1 To 10000) ' Initial size
End Sub
Private Sub AddPoint(x As Long, y As Long, Value As Single)
If MyPointsCount >= UBound(MyPoints) Then
' Time to enlarge the array
ReDim Preserve MyPoints(1 To UBound(MyPoints) + 10000)
End If
MyPointsCount = MyPointsCount + 1
MyPoints(MyPointsCount).x = x
MyPoints(MyPointsCount).y = y
MyPoints(MyPointsCount).Value = Value
End Sub
Private Function GetPoint(x As Long, y As Long, ByRef bNotFound As Boolean)
As Single
Dim i As Long
For i = 1 To MyPointsCount
If x = MyPoints(i).x And y = MyPoints(i).y Then
GetPoint = MyPoints(i).Value
Exit Function
End If
Next
If i = MyPointsCount + 1 Then
' Point not found
bNotFound = True
End If
End Sub
|
|
0
|
|
|
|
Reply
|
Nobody
|
9/10/2010 6:41:45 AM
|
|
Another approach is to use a collection, and use x*y as a key. This is
probably faster if you have large number of items, but uses more memory.
|
|
0
|
|
|
|
Reply
|
Nobody
|
9/10/2010 6:48:32 AM
|
|
On Sep 10, 5:32=A0pm, Anders Jorgenson <a.j...@lycos.com> wrote:
> I have an array which stores values of precalculate results at certain
> positions (x,y):
>
> Theoretical, it would look like this:
>
> Dim sngArr(200000,200000) as single
> For example sng(1,1) would be 0.003923
>
> Of course this is not possible due to the memory capacity.
> Any wild ideas how you would do that?
> Any input is welcome!
http://www.vb-helper.com/tut2.htm
"This article describes triangular arrays, sparse arrays, and other
powerful data structures that can save you memory in your Visual Basic
and VBA applications. "
|
|
0
|
|
|
|
Reply
|
Jimekus
|
9/10/2010 7:07:32 AM
|
|
"Nobody" <nobody@nobody.com> wrote in message
news:i6cjvb$nhr$1@speranza.aioe.org...
> Put the points in an array, then loop through it. Example air code:
> Private Type TMyPoints
> x As Long
> y As Long
> Value As Single
> End Type
> Private MyPoints() As TMyPoints
> Private MyPointsCount As Long
> Private Sub Form_Load()
> ReDim MyPoints(1 To 10000) ' Initial size
> End Sub
I think you migth have missed this line in the OP's post ;-)
Dim sngArr(200000,200000) as single
He's going to need to have data of that size on disk.
Mike
|
|
0
|
|
|
|
Reply
|
Mike
|
9/10/2010 7:17:43 AM
|
|
On 10/09/2010 08:17, Mike Williams wrote:
> "Nobody" <nobody@nobody.com> wrote in message
> news:i6cjvb$nhr$1@speranza.aioe.org...
>
>> Put the points in an array, then loop through it. Example air code:
>> Private Type TMyPoints
>> x As Long
>> y As Long
>> Value As Single
>> End Type
>> Private MyPoints() As TMyPoints
>> Private MyPointsCount As Long
>> Private Sub Form_Load()
>> ReDim MyPoints(1 To 10000) ' Initial size
>> End Sub
>
> I think you migth have missed this line in the OP's post ;-)
>
> Dim sngArr(200000,200000) as single
>
> He's going to need to have data of that size on disk.
I think people are more likely to have 149GB of disk space than memory :p
--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
iCode Systems
(Replies direct to my email address will be ignored.
Please reply to the group.)
|
|
0
|
|
|
|
Reply
|
Dee
|
9/10/2010 8:17:49 AM
|
|
"Dee Earley" <dee.earley@icode.co.uk> wrote in message
news:%235AkYFMULHA.4980@TK2MSFTNGP04.phx.gbl...
>> [The OP said]
>> Dim sngArr(200000,200000) as single
>> [Mike Williams said] He's going to need to have data of that size on
>> disk.
>
> I think people are more likely to have 149GB of disk space than memory :p
Exactly, which is why I said he needs to have it on disk. Mind you, having
said that, I can remember the time when I would have said you're not gonna'
fit data of that huge size (8KB) in memory! Who knows what the future will
bring ;-)
Mike
|
|
0
|
|
|
|
Reply
|
Mike
|
9/10/2010 8:47:11 AM
|
|
On 10/09/2010 09:47, Mike Williams wrote:
> "Dee Earley" <dee.earley@icode.co.uk> wrote in message
> news:%235AkYFMULHA.4980@TK2MSFTNGP04.phx.gbl...
>>> [The OP said]
>>> Dim sngArr(200000,200000) as single
>>> [Mike Williams said] He's going to need to have data of that size on
>>> disk.
>>
>> I think people are more likely to have 149GB of disk space than memory :p
>
> Exactly, which is why I said he needs to have it on disk. Mind you,
> having said that, I can remember the time when I would have said you're
> not gonna' fit data of that huge size (8KB) in memory! Who knows what
> the future will bring ;-)
You want one of these then :)
http://www.oracle.com/us/products/servers-storage/servers/x86/sun-fire-x4800-server-077287.html
--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
iCode Systems
(Replies direct to my email address will be ignored.
Please reply to the group.)
|
|
0
|
|
|
|
Reply
|
Dee
|
9/10/2010 8:52:53 AM
|
|
"Anders Jorgenson" <a.jorg@lycos.com> wrote
> I have an array which stores values of precalculate results at certain
> positions (x,y):
>
> Theoretical, it would look like this:
>
> Dim sngArr(200000,200000) as single
> For example sng(1,1) would be 0.003923
>
> Of course this is not possible due to the memory capacity.
> Any wild ideas how you would do that?
> Any input is welcome!
"At certain positions" would tend to indicate not all positions
need to be represented. If you only need a few thousand
points to be represented, then use the sparse array.
(linked lists)
If you need several million points to be present,
then look at managing the data in disk files....
LFS
|
|
0
|
|
|
|
Reply
|
Larry
|
9/10/2010 12:11:14 PM
|
|
|
8 Replies
457 Views
(page loaded in 0.083 seconds)
|