我无法绕开scipy文档中的<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="10dp"
android:layout_width=“match_parent”
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="@dimen/card_view_item_main_width"
android:layout_height="@dimen/card_view_item_main_height"
android:layout_gravity="center">
个示例:https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
有人可以解释此示例如何工作吗?
csr_matrix
我相信这是遵循这种格式的。
>>> row = np.array([0, 0, 1, 2, 2, 2])
>>> col = np.array([0, 2, 2, 0, 1, 2])
>>> data = np.array([1, 2, 3, 4, 5, 6])
>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()
array([[1, 0, 2],
[0, 0, 3],
[4, 5, 6]])
csr_matrix((data, (row_ind, col_ind)), [shape=(M, N)])
这里的where data, row_ind and col_ind satisfy the relationship a[row_ind[k], col_ind[k]] = data[k].
是什么?
答案 0 :(得分:2)
这是一个稀疏矩阵。因此,它存储显式索引和这些索引处的值。因此,例如,由于row = 0和col = 0对应于1(示例中所有三个数组的第一个条目)。因此,矩阵的[0,0]项为1。依此类推。
答案 1 :(得分:0)
据我了解,在行和列数组中,我们有对应于矩阵中非零值的索引。 a [0,0] = 1,a [0,2] = 2,a [1,2] = 3,依此类推。由于我们没有a [0,1],a [1,0],a [1,1]的索引,因此矩阵中的适当值等于0。
此外,也许这个小介绍对您有帮助: https://www.youtube.com/watch?v=Lhef_jxzqCg
答案 2 :(得分:0)
row = np.array([0,0,1,2,2,2])
col = np.array([0,2,2,0,1,2])
数据= np.array([1、2、3、4、5、6])
来自上述数组;
for in in 0〜5
a [row_ind [k],col_ind [k]] =数据[k]
a
row[0],col[0] = [0,0] = 1 (from data[0])
row[1],col[1] = [0,2] = 2 (from data[1])
row[2],col[2] = [1,2] = 3 (from data[2])
row[3],col[3] = [2,0] = 4 (from data[3])
row[4],col[4] = [2,1] = 5 (from data[4])
row[5],col[5] = [2,2] = 6 (from data[5])
所以让我们以形状(3X3)布置矩阵'a'
a
0 1 2
0 [1, 0, 2]
1 [0, 0, 3]
2 [4, 5, 6]
答案 3 :(得分:0)
以4 X 4矩阵表示“数据”:
input.nextFloat()
Radius of the second circle => 2.5
c(0) radius = 1.0 area = 3.141592653589793
c(1) radius = 2.5 area = 19.634954084936208
c(2) radius = 2.5 area = 19.634954084936208
Total radius of the circles = 6.0
Total area of the circles = 42.4115