मुझे numpy.dot उत्पाद पर कुछ संदेह हैं।बेवकूफ, बहुआयामी सरणी पर डॉट उत्पाद
मैं एक मैट्रिक्स 6x6 परिभाषित की तरह:
C=np.zeros((6,6))
C[0,0], C[1,1], C[2,2] = 129.5, 129.5, 129.5
C[3,3], C[4,4], C[5,5] = 25, 25, 25
C[0,1], C[0,2] = 82, 82
C[1,0], C[1,2] = 82, 82
C[2,0], C[2,1] = 82, 82
तो मैं एक बहुआयामी सरणी
def long2short(m, n):
"""
Given two indices m and n of the stiffness tensor the function
return i the index of the Voigt matrix
i = long2short(m,n)
"""
if m == n:
i = m
elif (m == 1 and n == 2) or (m == 2 and n == 1):
i = 3
elif (m == 0 and n == 2) or (m == 2 and n == 0):
i = 4
elif (m == 0 and n == 1) or (m == 1 and n == 0):
i = 5
return i
c=np.zeros((3,3,3,3))
for m in range(3):
for n in range(3):
for o in range(3):
for p in range(3):
i = long2short(m, n)
j = long2short(o, p)
c[m, n, o, p] = C[i, j]
का उपयोग करके एक 4 रैंक टेन्सर में यह फिर से पात्र चयन और फिर मैं संदर्भ समन्वय परिवर्तन करना चाहते हैं
Q=np.array([[sqrt(2.0/3), 0, 1.0/sqrt(3)], [-1.0/sqrt(6), 1.0/sqrt(2), 1.0/sqrt(3)], [-1.0/sqrt(6), -1.0/sqrt(2), 1.0/sqrt(3)]])
Qt = Q.transpose()
मातृ: रोटेशन मैट्रिक्स है कि मैं की तरह परिभाषित का उपयोग करके टेन्सर की प्रणाली एक्स ओर्थोगोनल है (हालांकि संख्यात्मक परिशुद्धता सही नहीं है):
In [157]: np.dot(Q, Qt)
Out[157]:
array([[ 1.00000000e+00, 4.28259858e-17, 4.28259858e-17],
[ 4.28259858e-17, 1.00000000e+00, 2.24240114e-16],
[ 4.28259858e-17, 2.24240114e-16, 1.00000000e+00]])
लेकिन फिर अगर मैं प्रदर्शन:
In [158]: a=np.dot(Q,Qt)
In [159]: c_mat=np.dot(a, c)
In [160]: a1 = np.dot(Qt, c)
In [161]: c_mat1=np.dot(Q, a1)
मैं c_mat के लिए उम्मीद मूल्य लेकिन c_mat1 नहीं करने के लिए (ग =) मिल सकता है? क्या बहुआयामी सरणी पर डॉट का उपयोग करने के लिए कुछ सूक्ष्मता है?
np.dot(a,b) == np.tensordot(a, b, axes=([-1],[2]))
जैसा कि आप देख, यह एक के रूप में काम नहीं करता है:
आप c_mat1 के लिए क्या परिणाम प्राप्त करते हैं? उन मामलों में से कुछ में आपको अनुमान लगाया जाना चाहिए? – usethedeathstar
'numpy.tensordot() ' –