Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linked 2D Matrix in C#

Tags:

c#

matrix

I need to implement this scenario in C#:

http://i.stack.imgur.com/Dm6G3.jpg

The matrix will be very large, maybe 10000x10000 or larger. I will use this for distance matrix in hierarchical clustering algorithm. In every iteration of the algorithm the matrix should be updated (joining 2 rows into 1 and 2 columns into 1). If I use simple double[,] or double[][] matrix this operations will be very "expensive". Please, can anyone suggest C# implementation of this scenario?

like image 790
Vlado Avatar asked Oct 25 '22 01:10

Vlado


1 Answers

Do you have a algorithm at the moment? And what do you mean by expensive? Memory or time expensive? If memory expensive: There is not much you can do in c#. But you can consider executing the calculation inside a database using temporary objects. If time expensive: You can use parallelism to join columns and rows.

But beside that I think a simple double[,] array is the fastest and memory sparing way you can get in c#, because accessing the array values is an o(1) operation and arrays have a least amount of memory and management overhead (compared to lists and dictionaries).

like image 177
jb_ Avatar answered Nov 15 '22 05:11

jb_