Best way to store a sparse matrix in .NET

后端 未结 6 1174
眼角桃花
眼角桃花 2021-02-05 22:07

We have an application that stores a sparse matrix. This matrix has entries that mostly exist around the main diagonal of the matrix. I was wondering if there were any efficie

6条回答
  •  没有蜡笔的小新
    2021-02-05 22:25

    I think this could be done by using a class holding plain array, saving the horizontal offset applied between matrix rows and defining stripe of a row, e.g. the number of valid entries. So for a large matrix where only the diagonal and two neighbor elements are defined you'd create an array of 3 * number of rows and store 3 as the stripe width. The offset depends on the size of the matrix.

    I'm not aware of anything free which already does this.

提交回复
热议问题