Single Array Vs 2D Array to represent a Matrix...
-
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.
-
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.
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
-
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.
-
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
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.
-
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?
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. 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.
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
-
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