So if you recall the value array, it is simply the non-zero elements of this input array,
which we'll just fill in here.
The index array here is which column each of these array elements are in.
So the 1 is in column 0, the 2 is in column 2,
the 2 here is in column 0, the 1 here is in column 1,
this 1 is also in column 1, and this final 3 is in column 2.
Finally, what are the indices of each one of these elements that actually begins a row?
So we should look for the index of this 1, the index of this 2, and the index of this 1
because they are what begin each one of these rows.
That's this element, this element, and this element.
This element is the zeroth element, this element is the second element,
and this element here is the fourth element.
So this is the CSR representation of this sparse matrix here.
所以如果你回忆值数组,它只是此输入数组的非零元素。
就是我们将在这里填写的元素。
这里的索引数组是指每个数组元素位于哪一列。
所以1是在第0列,2 是在第2列,
这里的 2 是在第0列,这里的 1 是在第1列,
这个1 也在第1列,这最后的3是在第2列。
最后,实际在每行起始处的的这每个元素的索引是什么?
所以我们应该寻找这个1的索引、 这个2的索引和这个1的索引
因为它们分别是这些行的起始元素。
就是这个元素,这个元素,这个元素。
这个元素是第零个元素,这个元素是第二个元素,
在这里的这个元素是第四个元素。
所以这就是这稀疏矩阵的CSR(压缩稀疏行)表示形式。