Precalculated array

```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
Anders
9/10/2010 5:32:09 AM
vb.general.discussion 1016 articles. 0 followers.

8 Replies
1273 Views

Similar Articles

[PageSpeed] 58

```"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

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
bNotFound = True
End If
End Sub

```
 0
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
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
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
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.
```
 0
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
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.
```
 0
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.

If you need several million points to be present,
then look at managing the data in disk files....

LFS

```
 0
Larry
9/10/2010 12:11:14 PM

Similar Artilces:

Date Range as Criteria in an Array
I need to use a date range from a date column as on of two criterium for a Sum function, using an array. example: A - dates (one criteria) B - quantity (second criteria) C - price (column to sum, if both criterium are met) my array formula so far: =SUM((A12:A55>=1/1/2002)*(A12:A55<=1/31/2002)*(B12:B55)* (C12:C55)) Enclose your dates in double quotes and multiply by 1: =SUM(..."1/1/2002"*1..."1/31/2002"*1...) Wrapping the date in DATEVALUE also works. You can also simply place the dates in cells and then reference those cells. HTH Jason Atlanta, GA >-----...

Array Limit
I Am using the following that I found somewhere to get the members in an Active Directory group and populate a spreadsheet with the names. Problem is it always returns 1500 names. even if I know there are 1600 people in this group. Is the array limited in size, or is the LDAP query limited in it's return? Thanks Sub ADGroupMembers() Dim arrNames() intSize = 0 'Let's clear the range first Range("SCREEN").ClearContents 'Get the AD Group Info for BATY-SESCREEN Set objGroup = GetObject("LDAP://CN= BATY-SESCREEN,OU=Security Groups,DC=baty...

Doing a VLOOKUP from the MIN value in an Array
This is a multi-part message in MIME format. ------=_NextPart_000_0082_01C37D23.15E40BE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Wow, this project has really opened my eyes to the fact that I need to = brush up on my excel (or learn Access!). Okay, I now have a value that shows me the lowest buying price of a = particular product. {=3DMIN(IF(C1:C3=3D1,B1:B3))} --- Thanks Dave Smith, you rock! --- Now I need a cell where I can put the location that sells that product = at the lowest price. =20 I have a spreadsheet showing the na...

a synonym for an array of 20 integers
Hi, The following declares M as a synonym for CArray<int,int. typedef CArray<int,int> M; Is there a way to declare M as a synonym for an array of 20 integers? That is, CArray<int, int> x; x.SetSize(20); Please advise. Thanks. Tony CArray is meant to go changing as it pleases, typically if fixed you would want a static array. consider writing a derrived template class that calls setsize in its constructor based on an argument. "Tony Young" <jdt_young@yahoo.com> wrote in message news:e3eE2N%236FHA.1864@TK2MSFTNGP12.phx.gbl... > Hi, > > The fo...

Array #2
Hello from steved I would like to insert a row but I get a message you cannot change part of an array How do I acheive inserting a row Thankyou. ...

2 dimensional array within function
Hello, I have a 2d array defined as follows: typedef CArray<int,int> arLineInt_t; typedef CArray<arLineInt_t,arLineInt_t> ar2DInt_t; ar2DInt_t Matrix2D; How can I pass that array to functions. I tried some things, but I can not realy access the elements of the array within the functions. Thanks Frank "Frank" <frankdeicke@gmx.de> ha scritto nel messaggio news:eXAQfbJaIHA.5208@TK2MSFTNGP04.phx.gbl... > I have a 2d array defined as follows: > > typedef CArray<int,int> arLineInt_t; > typedef CArray<arLineInt_t,arLineInt_t> ar2DInt_t;...

Array functions and cell formatting problem
Dear all! I kindly request your help with the following problem i've run into: I'll try to be as explanatory as possible, so please bear with me :-). I'm working on Excel XP. I'm using a Main Excel file (MAIN) that uses several array functions t perform some computations. These array functions refer to Ranges in a Database (DB) Excel file. There is also an Input Excel file (INPUT), that feeds MAIN with data. After MAIN is fed with data from INPUT, it tries to calculate its arra functions, which refer to ranges in DB. So we have the following 3 Excel files: INPUT (Data)...

Using a two-dimensional array in Excel 2002 or 2003
I am trying to improve my coding skills in Excel VBA and I just can't seem to find a good, very basic, example of how to use a 2-dimensional array. I've looked in several reference books & browsed VBA Forums but can't find an example I can understand. What I was trying to do was define a 3 x 4 Array that has a data type of Single. My sample data is located in Cells E1:H3. E F G H 1 3.4 8.1 11.6 100.3 2 5.2 7.3 45.2 632.4 3 1.7 9.6 39.7 161.5 I've been trying to use the LBound and UBound functions too, thinkin...

Naming arrays
I need to retrieve values from a monthly database and I cannot use Excel database functions because they are too primitive. What I have come across is using arrays like fields and criteria in 1-2-3 database functions like this: {=SUM((DBVAR="CRMUSCR--VA")*(DBYEAR=2007)*(DB_JAN))} If I want to retrieve data from each month in separate cells, it seems to me that I have to create at least 14 arrays, one for the variable, one for the year, and one for each month's values. (In 1-2-3, you just set up a database with field headings and put a field and criteria into a database ...

How to convert char array into wchar array?
hi: is there a function to conver array of chars into array of WCHARs? Thanks Polaris wbstowcs "Polaris" <etpolaris@hotmail.com> wrote in message news:egIdFTsPEHA.3216@TK2MSFTNGP12.phx.gbl... > hi: > > is there a function to conver array of chars into array of WCHARs? > > Thanks > Polaris > > >>is there a function to conver array of chars into array of WCHARs? I use MultiByteToWideChar() Keith ...

Declaring an array as an element in another array
Hi I want to store an array as an element in another array. I'm using a CArray to store elements of CStringArra CEntityArray <CEntity, CEntity&> CArray class CEntit public CStringArray inPortNameArray however when i wanted to add instances of CEntity to CArray in this fashion CEntity R1 R1.inPortNameArray.Add("v1") CEntityArray.Add(R1) I get the following error error C2582: 'CEntity' : 'operator =' function is unavailabl c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while compiling class-template member fun...

Listbox Control Array?
How can I make a control array or group or something where I can have two groups of ten list boxes on a form that have the same names but different index numbers for referencing? You build the collections yourself: '********************* Option Explicit Dim SomeLists As New Collection Dim OtherLists As New Collection Private Sub UserForm_Initialize() SomeLists.Add Me.ListBox1 SomeLists.Add Me.ListBox2 SomeLists.Add Me.ListBox3 OtherLists.Add Me.ListBox4 OtherLists.Add Me.ListBox5 OtherLists.Add Me.ListBox6 End Sub Private Sub CommandButton1_Click() Dim i As Long For i = 1 To 3 ...

Problem with array and CComboBox control
I have a header file in which is contained the following array. const char *directionVal[][24] = { { "Left-to-right", "ltr" }, { "Right-to-left", "rtl" }, { "Left-to-right Override", "ltr-override" }, { "Right-to-left Override", "rtl-override" } }; In OnInitDialog() I load my combo box control with the strings from the array like so. for(int d = 0; d < sizeof(directionVal)/sizeof(directionVal[0]); d++) m_cDirectionCombo.AddString(directionVal[0][d] ); I want to show the first s...

IF/AND Array in MS Excel 2003
What I am trying to do: I have a list of 35 clients (column B), a row of 7 available catalogs (row 1: catalogs 1-7 in columns C-I). We have approximately 50 mailings per calendar year so I have columns O-U (O(orange)=catalog 1, P(purple)=catalog 2, Q(green)=catalog 3, etc) set up with color coded columns to the catalog columns, here is were I enter the date a specific catalog is to be mailed out. I am looking for a quick way for anyone of my co-workers to get into my catalog address file and send off the necessary catalogs only to the clients who are supposed to receive ...

creating an array
I want to create a time array. For example, cell A1 is the starting time of 6:00 AM, and cell B1 which contains the ending time of 2 PM. From 6 am to 2 pm is exactly 8 hours. I want to create an array of 8 elements with the starting value of 6:00 AM, and the last value in the array with the value of 2 pm. Of course, the array will start from cell C1 to J1 or 8 elements cell. Is there a formula to do? or is it possible to do this in excel at all? It would be similar to the one below. A B C D E F G --->&g...

arrays
I have an array with about 1500 names in it. How can I add those names to column A1 on sheet1 and go down one cell 1500 times and add the next value to the spreadsheet? in Excel07 VBA apologize for duplicate post, seem to have connectivity issues "Striker3070" <striker3070@qwest.net> wrote in message news:F0806BFF-7975-4C06-A448-37FFDBEB9DE4@microsoft.com... > I have an array with about 1500 names in it. How can I add those names to > column A1 on sheet1 and go down one cell 1500 times and add the next value > to the spreadsheet? in Excel07 VBA ...

Excel Linksources / no object array enumerator
I'm having trouble iterating through LinkSources in an Excel workbook using C#. I first wrote the below code in VBA to get a quick, correct result, Dim x As Variant For Each x In ThisWorkbook.LinkSources Debug.Print x Next but am so far unable to successfully convert the code to workable C# syntax. C#'s compiler complains "foreach statement cannot operate on variables of type 'object' because 'object' does not contain a definition for 'GetEnumerator', or it is inaccessible" when I try to use the below code : foreach(string Src i...

1:1 as the Array using the MATCH function
Hello, I am working on an Excel course from OzGrid. One of the problem/examples defines the MATCH function Array as 1:1. In my ignorance I expected something like A1:G50. I can't find in Help an explanation of what "1:1" defines. I will appreciate some guidance. Thanks Bob The 1:1 in the array indicates ALL of Row_1. Does that help? *********** Regards, Ron XL2002, WinXP "Knot2Brite" wrote: > Hello, > > I am working on an Excel course from OzGrid. > > One of the problem/examples defines the MATCH function Array as 1:1. In my > ign...

Counting values in arrays
How do I get from a vertical single-field array to an array of the sam size, each original value converted to a count of that value in th original array? E.g., 1 -> 3 0 -> 2 1 -> 3 0 -> 2 1 -> 3 2 -> 1 I start with a calculated array, not a cell range, so (I'm assuming {=COUNTIF(Array,Array)} won't work. Steve Przyborski Boston, Mass -- Message posted from http://www.ExcelForum.com Two methods using an array formula and countif Assuming that the data starts in A13. Type the following and drag down - the range w...

Assigning values from a sheet to an array
Can anyone explain why I get a runtime error with the code below.MANY THANKS! Option Explicit Option Base 1 Sub testing3() Dim Vt() As Double Dim j As Long Dim i As Long ReDim Preserve Vt(1 To 40) For i = 1 To 40 j = Int(Rnd() * 1100) Vt(i) = Worksheets("data").Cells(1, j) Next i End Sub ** Posted via: http://www.ozgrid.com Excel Templates, Training, Add-ins & Software! http://www.ozgrid.com/Services/excel-software-categories.htm ** Because j is greater than 256, the maximum number of columns in Excel. Alan Beban Ann...

xml schema and 2D arrays
Hi, I have got to transfer some data into a c# project from an old one that was written in delphi. I am new to XML, but it looks idea for transfering this data around. I have written a schema for this data using the tools in visual studio, my problem is that i dont know how to represent the arrays in the schema. These arrays a dynamic, so i dont know how big they are at design-time. Is it possible to represent this kind of data in XML? thanks in advance Neil yes it is possible. I suggest you use the xsd.exe tool as a design aid. Build a class in C#, then compile it into a DLL. Run xsd /...

Type Mismatch with UBound and arrays
I can't see what is wrong with this code In the Function MaxOfArray I get a type mismatch on the line "For i = 1 To UBound(TheArray). I think it has something to do with Set OrderDateArray = Sheets("Sheet2").Range("A2", Range("A65536").End(xlUp)) , which has only 36 rows. Even if I put k = UBound(OrderDateArray) in the main sub I get the error. I know this must be something simple that I can't see. Sub Forcast_Prod() Dim OrderDateArray As Variant Set OrderDateArray = Sheets("Sheet2").Range("A2", Range(...

create array of values returned by named formulas
Hi all, Is it possible to used named formulas to build an array of values that are not constants. I know you can use the myArray = {0,1,2,3} to build an array of constants but can you simulate this effect with named formulas, e.g. myArray = {myval1, myval2, mval3} where the values are derived by named formulas, eg myval1 = average(some range). I've tried using various syntax and the named range is 'accepted' when entered into the define box but when i come to try and use the name as a chart reference i get an error. Thanks Rob OK Tushar, here's the dilemma: I have a t...

trying to set up array
i have a field on my form called FTNumber. trying to get a message box on the after update to where: if mid(FTNumber,1,1)<> "A" Then MsgBox "You entered a Ticket Number that is not of a recognized format; ensure the Ticket Number is correct", vbInformation, "Notice" End If this works fine. the issue is i have other values that are also a good format. "C","D","E","F". when i try the: if mid(FTNumber,1,1)<> "A" or if mid(FTNumber,1,1)<> "C" it doesn't recognize the &qu...

array with split is reading incorrectly
My code below shows run-time error 6 overflow at lot_number = farray(0). some how the number is not captured. It should show 705302. Any thoughts? Sub test() FileName = "705302 build postfill 01-27-2010 sns " Dim farray() As String Dim lot_number As Integer Dim Material As String Dim Serialno As Integer farray = Split(FileName, " ") If (IsNumeric(farray(0))) Then lot_number = farray(0) Else lot_number = 0 End If ...