Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sparse matrices - vfp8
Message
From
02/10/2011 06:10:20
 
 
To
01/10/2011 16:09:30
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01525329
Message ID:
01525378
Views:
63
>>>Hello - Unfortunately vfp software doesn't let me create a square sparse matrix (as is doing - for example Matlab software); because I need to overcome the limit of 65,000 memory variables (even double ...) , I'm looking for a solution - anyone has a idea - it is welcome. Thanks in advance for your help, bye, Sorin
>>
>>
>>(1) Use Collections - the key would be the string of the index
>>For mulitdimension you'll need to add other collecttions
>>
>>This becomes a bit messy
>>
>>(2) If all elements are the same type, use SafeArray
>>SafeArrays are allocated by windows
>>
>>http://msdn.microsoft.com/en-us/library/ms221145(v=VS.85).aspx
>>
>>- SaveArrayCreate() or SafeArrayCreateEx() for structures
>>You can specify the number of dimensions and the lower/upperbounds for each dimension
>>
>>- SafeArrayCreateVector() for one dimensional arrays
>>
>>- SafeArrayDestroy() when you no longer need it
>>
>>
>>- SafeArrayPutElement () to assign a value to an element
>>- SafeArrayGetElement() to get the contents fo an element
>>
>>
>>
>>(3) a Cursor may be the simplest way
>
>I like the cursor idea:
>
>PrimaryKey   XSubscript   YSubscript   (ZSubscript...)   Value
>
>   1             1             1            ...            42
>  ...
>
>Completely sparse "array" with up to about 250 "dimensions", if you want. Easy to insert/remove elements as needed.


I think you don't need a primary key field like you wrote

You need direct access given - say - x[1, 2, 3, 4, 5], ie you need to transform (1,2,3,4,5) into a (unique) key
max key length = 240
Max dimensions. If you bintoc(XSubscript , 2) = 120
Max dimensions. If you bintoc(XSubscript , 4) = 60

Same philosophy as the cursor - you could use one collection with keys eg bintoc(i) + bintoc(j) + bintoc(k) + bintoc(l) + ......
I do not think there's a limit on the key size of a collection

Downside - to modify an existing element, either
- remove and re add it
- work with objects - their properties can be modified directly - but you have one extra object per element
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform