Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Single Array Vs 2D Array to represent a Matrix...

Single Array Vs 2D Array to represent a Matrix...

Scheduled Pinned Locked Moved C#
performancevisual-studiodata-structures
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Are Jay
    wrote on last edited by
    #1

    Single dimension array Vs Multiple dimension array. - speed/performance - memory footprint I will be storing Object relationships and permission information so I will need to quickly return a list of Object Ids/Reference Objects inside the matrix. I am looking for anyones experience with both types of array usages, pitfalls, performance/memory issues, and overall preferences. Robert Fidler

    I'm listening but I only speak GEEK.

    D L 2 Replies Last reply
    0
    • A Are Jay

      Single dimension array Vs Multiple dimension array. - speed/performance - memory footprint I will be storing Object relationships and permission information so I will need to quickly return a list of Object Ids/Reference Objects inside the matrix. I am looking for anyones experience with both types of array usages, pitfalls, performance/memory issues, and overall preferences. Robert Fidler

      I'm listening but I only speak GEEK.

      D Offline
      D Offline
      Dr Walt Fair PE
      wrote on last edited by
      #2

      Are you dealing with a sparse or compact matrix? Is there a natural ordering? Do you expect to reference matrix elements by integer indices? Are you going to do any matrix manipulations or is this basically just a 2D data store?

      CQ de W5ALT

      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

      A 1 Reply Last reply
      0
      • A Are Jay

        Single dimension array Vs Multiple dimension array. - speed/performance - memory footprint I will be storing Object relationships and permission information so I will need to quickly return a list of Object Ids/Reference Objects inside the matrix. I am looking for anyones experience with both types of array usages, pitfalls, performance/memory issues, and overall preferences. Robert Fidler

        I'm listening but I only speak GEEK.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        MDarray's are quite slow to index, a normal array with some funny math for the indexing is faster. But I don't really understand your requirement to return "a list inside the matrix" - what do you mean? Do you want access to rows or columns as lists?

        A 1 Reply Last reply
        0
        • D Dr Walt Fair PE

          Are you dealing with a sparse or compact matrix? Is there a natural ordering? Do you expect to reference matrix elements by integer indices? Are you going to do any matrix manipulations or is this basically just a 2D data store?

          CQ de W5ALT

          Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

          A Offline
          A Offline
          Are Jay
          wrote on last edited by
          #4

          1. It will be a sparse matrix. 2. Natual ordering, I am not familiar with this term but after a quick google search I don't beleive I will be. Will look more like "Nested". 3. Yes I will be using an integer indices to access the matrix. 4. No matrix manipulation, I have not found a reason yet to do this. If I find that I can in the future it would be nice. An example of useages for the matrix: - Find all the children and childrens-children for Object.Id 456. - Find all the parents for the Object.Id 456. At this time it will be a simple 2D datastore of relationships. Robert Fidler

          I'm listening but I only speak GEEK.

          D 1 Reply Last reply
          0
          • L Lost User

            MDarray's are quite slow to index, a normal array with some funny math for the indexing is faster. But I don't really understand your requirement to return "a list inside the matrix" - what do you mean? Do you want access to rows or columns as lists?

            A Offline
            A Offline
            Are Jay
            wrote on last edited by
            #5

            harold aptroot thank you for your insight on MD Arrays. "A list inside the matrix" is miss leading. I will have an initial datasource of Objects that I will reference by Id so once/while I iterate through the relationship matrix I can return a List. Robert Fidler

            I'm listening but I only speak GEEK.

            1 Reply Last reply
            0
            • A Are Jay

              1. It will be a sparse matrix. 2. Natual ordering, I am not familiar with this term but after a quick google search I don't beleive I will be. Will look more like "Nested". 3. Yes I will be using an integer indices to access the matrix. 4. No matrix manipulation, I have not found a reason yet to do this. If I find that I can in the future it would be nice. An example of useages for the matrix: - Find all the children and childrens-children for Object.Id 456. - Find all the parents for the Object.Id 456. At this time it will be a simple 2D datastore of relationships. Robert Fidler

              I'm listening but I only speak GEEK.

              D Offline
              D Offline
              Dr Walt Fair PE
              wrote on last edited by
              #6

              By "natural ordering" I mean something that obviously has an inherent sort order, like integers, an alphabetical list, etc. Some things just "happen" almost at random and have no inherent "natural" way to order them. In your case, perhaps a user ID is (an imposed) natural ordering? It sounds to me that you might be better off using one of the generic list-type objects to save your data, rather than an array or matrix. Your structure and application sounds like a natural for a linked list or a tree, but I'm not sure I understand enough to say for sure. For large, sparse matrices, a list or tree would require less memory. Tree or list traversal can also be very fast compared to computing offsets in an array. As always there are trade-offs both ways.

              CQ de W5ALT

              Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

              A 1 Reply Last reply
              0
              • D Dr Walt Fair PE

                By "natural ordering" I mean something that obviously has an inherent sort order, like integers, an alphabetical list, etc. Some things just "happen" almost at random and have no inherent "natural" way to order them. In your case, perhaps a user ID is (an imposed) natural ordering? It sounds to me that you might be better off using one of the generic list-type objects to save your data, rather than an array or matrix. Your structure and application sounds like a natural for a linked list or a tree, but I'm not sure I understand enough to say for sure. For large, sparse matrices, a list or tree would require less memory. Tree or list traversal can also be very fast compared to computing offsets in an array. As always there are trade-offs both ways.

                CQ de W5ALT

                Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                A Offline
                A Offline
                Are Jay
                wrote on last edited by
                #7

                Thanks you for you help and insight was extremely helpful, thanks again. Robert Fidler

                I'm listening but I only speak GEEK.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups