Results 1 to 8 of 8

is an array of arrays awkward or desirable programming practice?

Threaded View

  1. #1
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,528

    is an array of arrays awkward or desirable programming practice?

    I have undertaken a project to write a UDF that will take a parametric array as an argument. The thing that is looking awkward to me is that each element of the parametric array will be an array/range itself. Recognizing that a series of polynomials is an imperfect example, here is how it looks for a series of polynomials.
    Function arraytest(x As Double, ParamArray polys()) As Variant
    Dim temp(1 To 4) As Double
    Dim i As Integer, j As Integer
    'loop through each polynomial
    For i = 1 To 4
        temp(i) = 0
    'loop through parameters to sum up polynomial(i)
        For j = 1 To 4
    'this is where it seems awkward to me: accessing polys() as
    'polys(0)(1) rather than polys(0,1) for a 2D array
    'polys(0)(2)
    'etc
            temp(i) = temp(i) + polys(i - 1)(j) * x ^ (j - 1)
        Next j
    Next i
    'output result to sheet
    arraytest = temp
    End Function
    I'm sure I could process polys() into a 2D array before moving on to the main processing loops, but is such a step necessary? Do I just need to bite the bullet and become more comfortable with this "array of arrays" notation? Or do "real" programmers prefer not to work with this array of arrays structure?
    Does anything change if I add that in my real project, each element of polys is a 2D range? Which is really worse:
    a 3D array polys(i,j,k)
    a paramarray of 2D arrays polys(i)(j,k)

    I realize that this kind of thing may not have a solid answer, but I would appreciate some feedback from more experienced programmers.
    Attached Files Attached Files
    Last edited by MrShorty; 09-24-2015 at 12:55 PM. Reason: add attachment
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What's the best practice for determining unique values in multiple arrays?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2015, 05:38 PM
  2. [SOLVED] How to apply header to desirable row
    By pabloponza in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-01-2014, 01:51 AM
  3. Replies: 6
    Last Post: 09-25-2013, 10:08 PM
  4. [SOLVED] New to arrays-how do I build new array while filtering first array?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-03-2013, 05:59 AM
  5. [SOLVED] Awkward last used row problem
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-05-2013, 03:03 PM
  6. Summarising awkward extract
    By Sibrulotte in forum Excel General
    Replies: 0
    Last Post: 06-22-2011, 09:59 AM
  7. Array Size & Dimensions Best Practice
    By pipsturbo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2011, 11:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1