1
에 베셀 함수의 결과를 넣을 수 없습니다 :이 게시물에 다음 NumPy와의 배열
How to put complex into a numpy's array?
나를 위해 잘 작동 보인다.
하지만이 경우 왜이 오류가 발생 했습니까? 추가
1 #!/usr/bin/env python
2 import scipy.special
3 import numpy as np
4
5 deg = 10
6 nodes = np.polynomial.legendre.leggauss(deg)[0]
7 A = np.zeros((deg, deg), dtype=complex)
8 for i in range(0, deg):
9 for j in range(0, deg):
10 A[i, j] = scipy.special.sph_yn(0, nodes[i]*nodes[j])[0]
machine:Desktop users$ ./aa.py
Traceback (most recent call last):
File "./aa.py", line 10, in <module>
A[i, j] = scipy.special.sph_yn(0, nodes[i]*nodes[j])[0]
TypeError: can't convert complex to float
는 : 나는 루프 둥지에서 라인 (10) 및 인쇄 scipy.special.sph_yn(0, nodes[i]*nodes[j])[0]
을 언급하면 내가
[-0.61456112]
[-0.79004531]
[-1.19235662]
[-2.16125343]
[-6.82467416]
[ 6.82467416+0.j]
[ 2.16125343+0.j]
[ 1.19235662+0.j]
[ 0.79004531+0.j]
[ 0.61456112+0.j]
... and so on
'scipy.special.sph_yn (0, nodes [i] * nodes [j]) [0]'을 A에 할당하지 않고 실행하여 먼저 작동하는지 확인하십시오. 그런 다음'scipy.special.sph_yn (0, nodes [i] * nodes [j]) [0]'의 결과를 확인하십시오. – brechmos