本文介绍了numpy的均方根以及numpy矩阵和数组的复杂性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以将我引向numpy手册的部分,在那部分我可以获取函数来完成均方根计算...(我知道这可以使用np.mean和np.abs ..没有内置的..如果没有为什么?..只是好奇..无罪)

Can anyone direct me to the section of numpy manual where i can get functions to accomplish root mean square calculations ...(i know this can be accomplished using np.mean and np.abs .. isn't there a built in ..if no why?? .. just curious ..no offense)

谁能解释矩阵和数组的复杂性(仅在以下情况下):

can anyone explain the complications of matrix and arrays (just in the following case):

U是一个矩阵(T-by-N,或者说T交叉N),Ue是另一个矩阵(T-by-N)我将k定义为一个numpy数组

U is a matrix(T-by-N,or u say T cross N) , Ue is another matrix(T-by-N)I define k as a numpy array

U[ind,:]仍然是矩阵

以以下方式k = np.array(U[ind,:])

当我在ipython中打印k或键入k

when I print k or type k in ipython

它显示以下内容

K = array ([[2,.3 .....
              ......
                9]])

您会看到双方括号(我想这使它具有多个维度)它的形状为=(1,N)

You see the double square brackets (which makes it multi-dim i guess)which gives it the shape = (1,N)

但是我不能将其分配给以此方式定义的数组

but I can't assign it to array defined in this way

l = np.zeros(N)
shape = (,N) or perhaps (N,) something like that

l[:] = k[:]
error:
matrix dimensions incompatible

有没有一种方法可以完成我打算做的向量分配...请不要告诉我这样做l = k(这违背了目的...我在程序中遇到不同的错误..我知道原因..如果需要,我可以附上一段代码)

Is there a way to accomplish the vector assignment which I intend to do ... Please don't tell me do this l = k (that defeats the purpose ... I get different errors in program .. I know the reasons ..If you need I may attach the piece of code)

写一个循环是愚蠢的方式..我暂时正在使用...

writing a loop is the dumb way .. which I'm using for the time being ...

我希望我能够解释..我所面临的问题..

I hope I was able to explain .. the problems I'm facing ..

致谢...

推荐答案

尝试一下:

U = np.zeros((N,N))
ind = 1
k = np.zeros(N)
k[:] = U[ind,:]

这篇关于numpy的均方根以及numpy矩阵和数组的复杂性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 07:52