Results 1 to 8 of 8

Thread: Complex Multidimensional Array Ops...

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2002
    Location
    Two places at once
    Posts
    33

    Complex Multidimensional Array Ops...

    I have a C# class that reads in a four-dimensional array from a series of flat text files. The clients of this class won't need access to all of the data at any one time, only certain parts of it. Is there a way I can write a method to return a multidimensional array with specific dimensions eliminated?

    For instance, take an array of sales figures:
    Code:
    double[,,,] dSales = new double[NUM_YEARS, NUM_MONTHS, NUM_SALESPEOPLE, NUM_PRODUCTS];
    This array provides sales figures organized by year, month, salesperson, and product. If a client needs access to sales figures of product #2 in August, it only needs a two dimensional array (year and salesperson). The other two dimensions (month and product) have been specified.

    Is this even possible? If so, any ideas on how to implement it?

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Check out the Array.Copy() method.

  3. #3
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Maybe you want to take closer look at the vector possibilitys of c#!

    Dont know much about it, but it sounds like a typical vector or ArrayList problem.

    Hope that helps,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2002
    Location
    Two places at once
    Posts
    33
    I checked MSDN regarding the Array.Copy method. It's meant to work on one-dimensional arrays. Multidimensional arrays are treated as flat arrays. I need something that recognizes that the arrays I'm copying from and to are multidimensional.

    I couldn't find anything on vectors, aside from how they apply to matrices and cryptography. Got anything more specific, Sgt-Peppa?

  5. #5
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Heres a link to an array list msdn example.
    Maybe thats what your looking for!

    http://msdn.microsoft.com/library/de...classtopic.asp

    Hope that helps.

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2002
    Location
    Two places at once
    Posts
    33
    I don't really think that ArrayLists will help me. The problem is not dynamically adding items, but rather trying to access subsets of elements. I guess I can just write a new method everytime I need to access a different type of array...but I was really hoping for some way to do this more dynamically.

  7. #7
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    the best way in my opinon is to create a method that takes as arguments the dimensions / length that you want to retrieve although it will require some maths at how to do it
    \m/\m/

  8. #8
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256

    Re: Complex Multidimensional Array Ops...

    Originally posted by smiley_dood
    I have a C# class that reads in a four-dimensional array from a series of flat text files. The clients of this class won't need access to all of the data at any one time, only certain parts of it. Is there a way I can write a method to return a multidimensional array with specific dimensions eliminated?

    For instance, take an array of sales figures:
    Code:
    double[,,,] dSales = new double[NUM_YEARS, NUM_MONTHS, NUM_SALESPEOPLE, NUM_PRODUCTS];
    This array provides sales figures organized by year, month, salesperson, and product. If a client needs access to sales figures of product #2 in August, it only needs a two dimensional array (year and salesperson). The other two dimensions (month and product) have been specified.

    Is this even possible? If so, any ideas on how to implement it?
    Why dont you just write a struct or a class to hold the sales information, then read in the info, then add the object to an arraylist. You can always retrieve the info you want from each object when you need to.

Posting Permissions

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



Click Here to Expand Forum to Full Width