MatSetValues(A,i,m,j,n,value,INSERT_VALUES,ierr)函数的作用是在大矩阵的(m,n)处插入一个i*j大小的矩阵。
A- the matrix
value- a logically two-dimensional array of values
i,m- the number of rows and their global indices
j, n- the number of columns and their global indices
其中,行和列矩阵索引是从0开始。
A
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
value
0.9501 0.8913 0.8214 0.9218
0.2311 0.7621 0.4447 0.7382
0.6068 0.4565 0.6154 0.1763
0.4860 0.0185 0.7919 0.4057
在A的(2,3)处插入value,于是A变成了:
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0.9501 0.8913 0.8214 0.9218 0
0 0 0 0.2311 0.7621 0.4447 0.7382 0
0 0 0 0.6068 0.4565 0.6154 0.1763 0
0 0 0 0.4860 0.0185 0.7919 0.4057 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0