|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Precalculated arrayI 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! "Anders Jorgenson" <a.j***@lycos.com> wrote in message Put the points in an array, then loop through it. Example air code: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! 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 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.
Show quote
Hide quote
"Nobody" <nob***@nobody.com> wrote in message I think you migth have missed this line in the OP's post ;-)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 Dim sngArr(200000,200000) as single He's going to need to have data of that size on disk. Mike On 10/09/2010 08:17, Mike Williams wrote:
Show quoteHide quote > "Nobody" <nob***@nobody.com> wrote in message I think people are more likely to have 149GB of disk space than memory :p> 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. -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) "Dee Earley" <dee.ear***@icode.co.uk> wrote in message Exactly, which is why I said he needs to have it on disk. Mind you, having 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 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 On 10/09/2010 09:47, Mike Williams wrote:
> "Dee Earley" <dee.ear***@icode.co.uk> wrote in message You want one of these then :)> 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 ;-) http://www.oracle.com/us/products/servers-storage/servers/x86/sun-fire-x4800-server-077287.html -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) On Sep 10, 5:32 pm, Anders Jorgenson <a.j***@lycos.com> wrote:
> I have an array which stores values of precalculate results at certain http://www.vb-helper.com/tut2.htm> 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! "This article describes triangular arrays, sparse arrays, and other powerful data structures that can save you memory in your Visual Basic and VBA applications. " "Anders Jorgenson" <a.j***@lycos.com> wrote "At certain positions" would tend to indicate not all positions> 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! 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
Is including Excel9.olb in the installation files necessary?
E_Fail Status with VB6 Old vb6 / mdb app with "Could not delete from specified tables" er Aero Glass Control Text Problem Funky Font Enumeration Cant solve this. create desktop shortcut when app installed w/P&D installer for XP,Vista,W7 Any "quirsk" with the timer control DLL fight Strange ActiveX-Exe behaviour |
|||||||||||||||||||||||