- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个 32x32 的 float 矩阵。我想得到其中所有元素的总和。但是当我使用循环时:
s = 0
for i in range(len(Temp)):
for j in range(len(Temp)):
s += Temp[i][j]
我得到 2.795541576006144e-13
当我使用 NumPy .sum(..)
方法时:
np.sum(Temp)
我得到 3.197442310920451e-13
结果截然不同,到底哪个是对的?
附言无法显示我在上面的示例中使用的数组,因为它说我的帖子主要是代码
[ 1.46992605 -4.38174259 7.11556386 -9.63811941 11.89561903
-13.57161385 14.72605916 -15.41213544 15.31459028 -14.72605916
13.65805725 -12.19869213 10.13557074 -7.67002338 4.8085357
-1.64285853 -1.66207325 4.89389432 -7.94725314 10.81956631
-13.33521624 15.38692526 -16.97717649 18.43603543 -17.16794834
16.69578682 -16.16491586 14.16866725 -11.81446896 8.6865325
-5.51985755 1.90225724]
[ -4.35328971 12.97683985 -21.07324444 28.54397071 -35.22971513
40.19329204 -43.61226329 45.6441266 -45.35523972 43.61226329
-40.44930027 36.12728748 -30.01720791 22.71531543 -14.24081776
4.86544144 4.92234719 -14.49361334 23.53635093 -32.04290906
39.49318383 -45.56946487 50.27910609 -54.59961979 50.84409039
-49.44575074 47.87353893 -41.96150782 34.98938345 -25.72577893
16.34744761 -5.63366904]
[ 7.0693589 -21.07324444 34.22109206 -46.35289322 57.20995302
-65.27036457 70.8224726 -74.12203957 73.65291273 -70.8224726
65.68609937 -58.66753144 48.74530062 -36.88767066 23.12583318
-7.90104818 -7.9934581 23.53635093 -38.22095996 52.03486078
-64.13345052 74.00079549 -81.64883784 88.66497138 -82.56632255
80.29554219 -77.74240875 68.14179118 -56.81967556 41.7763981
-26.54681442 9.1485821 ]
[ -9.51375658 28.35981606 -46.0538423 62.38050004 -76.99164451
87.83913358 -95.31101401 99.75148412 -99.12014562 95.31101401
-88.39861851 78.95321507 -65.60013876 49.64245339 -31.12213581
10.63302206 10.75738489 -31.67459976 51.43675893 -70.02714198
86.30910468 -99.58831705 109.88085054 -119.32297784 111.11557725
-108.05962098 104.6236814 -91.70342372 76.46641941 -56.22157372
35.72600205 -12.31192028]
[ 11.59254593 -34.55653586 56.11676921 -76.01085923 93.81459028
-107.03229395 116.13680659 -121.54753509 120.77824689 -116.13680659
107.71402831 -96.20477092 79.93400035 -60.48950447 37.9224322
-12.95637487 -13.10791142 38.59561147 -62.6758721 85.3283194
-105.16794834 121.34871544 -133.89020378 145.39546918 -135.39472263
131.67102913 -127.48432464 111.74094511 -93.17460164 68.50618579
-43.53225945 15.00211827]
[ -13.22584025 39.42526736 -64.02316015 86.72016373 -107.03229395
122.11226329 -132.49952683 138.67258244 -137.79490787 132.49952683
-122.89004841 109.75923138 -91.19604314 69.01197782 -43.2653908
14.78182146 14.95470826 -44.03341549 71.50638666 -97.35037734
119.98524672 -138.44575074 152.75423157 -165.88049418 154.47072474
-150.22239348 145.44581679 -127.48432464 106.30213618 -78.15814356
49.66559654 -17.11579326]
[ 14.35087294 -42.77890794 69.46917695 -94.09686096 116.13680659
-132.49952683 143.77036457 -150.46852022 149.51618781 -143.77036457
133.34347287 -119.09570613 98.95347314 -74.88235957 46.94568469
-16.03921093 -16.22680405 47.77904004 -77.58895088 105.63131489
-130.19157937 150.22239348 -165.74799991 179.99082482 -167.61050354
163.00079549 -157.81790776 138.32855308 -115.34453924 84.8065277
-53.8903126 18.57171792]
[ -14.92440963 44.48857909 -72.24553223 97.8574686 -120.77824689
137.79490787 -149.51618781 156.48203715 -155.49164451 149.51618781
-138.67258244 123.85539968 -102.90817666 77.87505423 -48.82188225
16.68022253 16.87531285 -49.68854288 80.68981522 -109.85290024
135.39472263 -156.22607389 172.37216557 -187.184209 174.30910468
-169.51516835 164.12514504 -143.85689279 119.95431635 -88.19584455
56.04405417 -19.31394188]
[ 14.92440963 -44.48857909 72.24553223 -97.8574686 120.77824689
-137.79490787 149.51618781 -156.48203715 155.49164451 -149.51618781
138.67258244 -123.85539968 102.90817666 -77.87505423 48.82188225
-16.68022253 -16.87531285 49.68854288 -80.68981522 109.85290024
-135.39472263 156.22607389 -172.37216557 187.184209 -174.30910468
169.51516835 -164.12514504 143.85689279 -119.95431635 88.19584455
-56.04405417 19.31394188]
[ -14.35087294 42.77890794 -69.46917695 94.09686096 -116.13680659
132.49952683 -143.77036457 150.46852022 -149.51618781 143.77036457
-133.34347287 119.09570613 -98.95347314 74.88235957 -46.94568469
16.03921093 16.22680405 -47.77904004 77.58895088 -105.63131489
130.19157937 -150.22239348 165.74799991 -179.99082482 167.61050354
-163.00079549 157.81790776 -138.32855308 115.34453924 -84.8065277
53.8903126 -18.57171792]
[ 13.22584025 -39.42526736 64.02316015 -86.72016373 107.03229395
-122.11226329 132.49952683 -138.67258244 137.79490787 -132.49952683
122.89004841 -109.75923138 91.19604314 -69.01197782 43.2653908
-14.78182146 -14.95470826 44.03341549 -71.50638666 97.35037734
-119.98524672 138.44575074 -152.75423157 165.88049418 -154.47072474
150.22239348 -145.44581679 127.48432464 -106.30213618 78.15814356
-49.66559654 17.11579326]
[ -11.59254593 34.55653586 -56.11676921 76.01085923 -93.81459028
107.03229395 -116.13680659 121.54753509 -120.77824689 116.13680659
-107.71402831 96.20477092 -79.93400035 60.48950447 -37.9224322
12.95637487 13.10791142 -38.59561147 62.6758721 -85.3283194
105.16794834 -121.34871544 133.89020378 -145.39546918 135.39472263
-131.67102913 127.48432464 -111.74094511 93.17460164 -68.50618579
43.53225945 -15.00211827]
[ 9.51375658 -28.35981606 46.0538423 -62.38050004 76.99164451
-87.83913358 95.31101401 -99.75148412 99.12014562 -95.31101401
88.39861851 -78.95321507 65.60013876 -49.64245339 31.12213581
-10.63302206 -10.75738489 31.67459976 -51.43675893 70.02714198
-86.30910468 99.58831705 -109.88085054 119.32297784 -111.11557725
108.05962098 -104.6236814 91.70342372 -76.46641941 56.22157372
-35.72600205 12.31192028]
[ -7.0693589 21.07324444 -34.22109206 46.35289322 -57.20995302
65.27036457 -70.8224726 74.12203957 -73.65291273 70.8224726
-65.68609937 58.66753144 -48.74530062 36.88767066 -23.12583318
7.90104818 7.9934581 -23.53635093 38.22095996 -52.03486078
64.13345052 -74.00079549 81.64883784 -88.66497138 82.56632255
-80.29554219 77.74240875 -68.14179118 56.81967556 -41.7763981
26.54681442 -9.1485821 ]
[ 4.35328971 -12.97683985 21.07324444 -28.54397071 35.22971513
-40.19329204 43.61226329 -45.6441266 45.35523972 -43.61226329
40.44930027 -36.12728748 30.01720791 -22.71531543 14.24081776
-4.86544144 -4.92234719 14.49361334 -23.53635093 32.04290906
-39.49318383 45.56946487 -50.27910609 54.59961979 -50.84409039
49.44575074 -47.87353893 41.96150782 -34.98938345 25.72577893
-16.34744761 5.63366904]
[ -1.46992605 4.38174259 -7.11556386 9.63811941 -11.89561903
13.57161385 -14.72605916 15.41213544 -15.31459028 14.72605916
-13.65805725 12.19869213 -10.13557074 7.67002338 -4.8085357
1.64285853 1.66207325 -4.89389432 7.94725314 -10.81956631
13.33521624 -15.38692526 16.97717649 -18.43603543 17.16794834
-16.69578682 16.16491586 -14.16866725 11.81446896 -8.6865325
5.51985755 -1.90225724]
[ -1.46992605 4.38174259 -7.11556386 9.63811941 -11.89561903
13.57161385 -14.72605916 15.41213544 -15.31459028 14.72605916
-13.65805725 12.19869213 -10.13557074 7.67002338 -4.8085357
1.64285853 1.66207325 -4.89389432 7.94725314 -10.81956631
13.33521624 -15.38692526 16.97717649 -18.43603543 17.16794834
-16.69578682 16.16491586 -14.16866725 11.81446896 -8.6865325
5.51985755 -1.90225724]
[ 4.35328971 -12.97683985 21.07324444 -28.54397071 35.22971513
-40.19329204 43.61226329 -45.6441266 45.35523972 -43.61226329
40.44930027 -36.12728748 30.01720791 -22.71531543 14.24081776
-4.86544144 -4.92234719 14.49361334 -23.53635093 32.04290906
-39.49318383 45.56946487 -50.27910609 54.59961979 -50.84409039
49.44575074 -47.87353893 41.96150782 -34.98938345 25.72577893
-16.34744761 5.63366904]
[ -7.0693589 21.07324444 -34.22109206 46.35289322 -57.20995302
65.27036457 -70.8224726 74.12203957 -73.65291273 70.8224726
-65.68609937 58.66753144 -48.74530062 36.88767066 -23.12583318
7.90104818 7.9934581 -23.53635093 38.22095996 -52.03486078
64.13345052 -74.00079549 81.64883784 -88.66497138 82.56632255
-80.29554219 77.74240875 -68.14179118 56.81967556 -41.7763981
26.54681442 -9.1485821 ]
[ 9.51375658 -28.35981606 46.0538423 -62.38050004 76.99164451
-87.83913358 95.31101401 -99.75148412 99.12014562 -95.31101401
88.39861851 -78.95321507 65.60013876 -49.64245339 31.12213581
-10.63302206 -10.75738489 31.67459976 -51.43675893 70.02714198
-86.30910468 99.58831705 -109.88085054 119.32297784 -111.11557725
108.05962098 -104.6236814 91.70342372 -76.46641941 56.22157372
-35.72600205 12.31192028]
[ -11.59254593 34.55653586 -56.11676921 76.01085923 -93.81459028
107.03229395 -116.13680659 121.54753509 -120.77824689 116.13680659
-107.71402831 96.20477092 -79.93400035 60.48950447 -37.9224322
12.95637487 13.10791142 -38.59561147 62.6758721 -85.3283194
105.16794834 -121.34871544 133.89020378 -145.39546918 135.39472263
-131.67102913 127.48432464 -111.74094511 93.17460164 -68.50618579
43.53225945 -15.00211827]
[ 13.22584025 -39.42526736 64.02316015 -86.72016373 107.03229395
-122.11226329 132.49952683 -138.67258244 137.79490787 -132.49952683
122.89004841 -109.75923138 91.19604314 -69.01197782 43.2653908
-14.78182146 -14.95470826 44.03341549 -71.50638666 97.35037734
-119.98524672 138.44575074 -152.75423157 165.88049418 -154.47072474
150.22239348 -145.44581679 127.48432464 -106.30213618 78.15814356
-49.66559654 17.11579326]
[ -14.35087294 42.77890794 -69.46917695 94.09686096 -116.13680659
132.49952683 -143.77036457 150.46852022 -149.51618781 143.77036457
-133.34347287 119.09570613 -98.95347314 74.88235957 -46.94568469
16.03921093 16.22680405 -47.77904004 77.58895088 -105.63131489
130.19157937 -150.22239348 165.74799991 -179.99082482 167.61050354
-163.00079549 157.81790776 -138.32855308 115.34453924 -84.8065277
53.8903126 -18.57171792]
[ 14.92440963 -44.48857909 72.24553223 -97.8574686 120.77824689
-137.79490787 149.51618781 -156.48203715 155.49164451 -149.51618781
138.67258244 -123.85539968 102.90817666 -77.87505423 48.82188225
-16.68022253 -16.87531285 49.68854288 -80.68981522 109.85290024
-135.39472263 156.22607389 -172.37216557 187.184209 -174.30910468
169.51516835 -164.12514504 143.85689279 -119.95431635 88.19584455
-56.04405417 19.31394188]
[ -14.92440963 44.48857909 -72.24553223 97.8574686 -120.77824689
137.79490787 -149.51618781 156.48203715 -155.49164451 149.51618781
-138.67258244 123.85539968 -102.90817666 77.87505423 -48.82188225
16.68022253 16.87531285 -49.68854288 80.68981522 -109.85290024
135.39472263 -156.22607389 172.37216557 -187.184209 174.30910468
-169.51516835 164.12514504 -143.85689279 119.95431635 -88.19584455
56.04405417 -19.31394188]
[ 14.35087294 -42.77890794 69.46917695 -94.09686096 116.13680659
-132.49952683 143.77036457 -150.46852022 149.51618781 -143.77036457
133.34347287 -119.09570613 98.95347314 -74.88235957 46.94568469
-16.03921093 -16.22680405 47.77904004 -77.58895088 105.63131489
-130.19157937 150.22239348 -165.74799991 179.99082482 -167.61050354
163.00079549 -157.81790776 138.32855308 -115.34453924 84.8065277
-53.8903126 18.57171792]
[ -13.22584025 39.42526736 -64.02316015 86.72016373 -107.03229395
122.11226329 -132.49952683 138.67258244 -137.79490787 132.49952683
-122.89004841 109.75923138 -91.19604314 69.01197782 -43.2653908
14.78182146 14.95470826 -44.03341549 71.50638666 -97.35037734
119.98524672 -138.44575074 152.75423157 -165.88049418 154.47072474
-150.22239348 145.44581679 -127.48432464 106.30213618 -78.15814356
49.66559654 -17.11579326]
[ 11.59254593 -34.55653586 56.11676921 -76.01085923 93.81459028
-107.03229395 116.13680659 -121.54753509 120.77824689 -116.13680659
107.71402831 -96.20477092 79.93400035 -60.48950447 37.9224322
-12.95637487 -13.10791142 38.59561147 -62.6758721 85.3283194
-105.16794834 121.34871544 -133.89020378 145.39546918 -135.39472263
131.67102913 -127.48432464 111.74094511 -93.17460164 68.50618579
-43.53225945 15.00211827]
[ -9.51375658 28.35981606 -46.0538423 62.38050004 -76.99164451
87.83913358 -95.31101401 99.75148412 -99.12014562 95.31101401
-88.39861851 78.95321507 -65.60013876 49.64245339 -31.12213581
10.63302206 10.75738489 -31.67459976 51.43675893 -70.02714198
86.30910468 -99.58831705 109.88085054 -119.32297784 111.11557725
-108.05962098 104.6236814 -91.70342372 76.46641941 -56.22157372
35.72600205 -12.31192028]
[ 7.0693589 -21.07324444 34.22109206 -46.35289322 57.20995302
-65.27036457 70.8224726 -74.12203957 73.65291273 -70.8224726
65.68609937 -58.66753144 48.74530062 -36.88767066 23.12583318
-7.90104818 -7.9934581 23.53635093 -38.22095996 52.03486078
-64.13345052 74.00079549 -81.64883784 88.66497138 -82.56632255
80.29554219 -77.74240875 68.14179118 -56.81967556 41.7763981
-26.54681442 9.1485821 ]
[ -4.35328971 12.97683985 -21.07324444 28.54397071 -35.22971513
40.19329204 -43.61226329 45.6441266 -45.35523972 43.61226329
-40.44930027 36.12728748 -30.01720791 22.71531543 -14.24081776
4.86544144 4.92234719 -14.49361334 23.53635093 -32.04290906
39.49318383 -45.56946487 50.27910609 -54.59961979 50.84409039
-49.44575074 47.87353893 -41.96150782 34.98938345 -25.72577893
16.34744761 -5.63366904]
[ 1.46992605 -4.38174259 7.11556386 -9.63811941 11.89561903
-13.57161385 14.72605916 -15.41213544 15.31459028 -14.72605916
13.65805725 -12.19869213 10.13557074 -7.67002338 4.8085357
-1.64285853 -1.66207325 4.89389432 -7.94725314 10.81956631
-13.33521624 15.38692526 -16.97717649 18.43603543 -17.16794834
16.69578682 -16.16491586 14.16866725 -11.81446896 8.6865325
-5.51985755 1.90225724]
最佳答案
他们都是对的。请注意,它是如此之小,以至于在这两种情况下它几乎为零(因为 e-13 部分)。
请参阅这篇关于浮点运算问题和限制的帖子:https://docs.python.org/3/tutorial/floatingpoint.html
关于python - 二维数组中所有元素的总和,不同的方法 - 不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51820019/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!