MtxVec VCL
|
Convert triplets to sparse format.
A sparse matrix can also be presented as pairs of the three elements called triplets. For each non zero value in the matrix we specify it's position: Row, Column, and it's Value. MatrixSize defines the size of the matrix and sets the Size and Cols properties. The maximum row and column index may not exceed rowCount and colCount. This is usually the most efficient way to convert a given dense matrix to sparse format. The values do not need to be ordered, the same coordinates can appear more than once. All values having the same coordinates will be summed together. This routine can therefore also be used as a way to sum multiple sparse matrices. Triplets can be represented by three arrays: Row, Column and Values or they can all be stored in one TMtx matrix.
By default any zeros on the main diagonal will be preserved. Set the last parameter to false to drop them on conversion.
Test sparseToTriplets, TripletsToSparse methods.
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|