Created
November 2, 2015 11:47
-
-
Save kyoro1/a7866c4efc09c92a4308 to your computer and use it in GitHub Desktop.
PythonでTraceを計算してみる ref: http://qiita.com/kyoro1/items/77b1b7c9634e16f09ee4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{\rm Tr}(PAP^{-1})={\rm Tr}(A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{\rm Tr}(A):=\sum_{i=1}^na_{ii} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=\left( | |
\begin{matrix} | |
1 & 2 \\ | |
3 & 4 | |
\end{matrix} | |
\right), | |
P=\left( | |
\begin{matrix} | |
2 & 3 \\ | |
4 & 5 | |
\end{matrix} | |
\right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> import numpy as np | |
> A = np.array([[1,2],[3,4]]) | |
> P = np.array([[2,3],[4,5]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> A | |
array([[1, 2], | |
[3, 4]]) | |
> P | |
array([[2, 3], | |
[4, 5]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> np.linalg.det(P) | |
-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> np.trace(np.dot(np.dot(P,A),inv_P)) | |
5.0 | |
> np.trace(A) | |
5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment