jonhhy Posted March 26, 2024 at 11:39 AM Report #632930 Posted March 26, 2024 at 11:39 AM Bom dia, será que a documentação está mesmo mal: https://numpy.org/doc/stable/reference/generated/numpy.trace.html ? Andei à procura de explicação: https://g.co/gemini/share/3560c6a6dff5 Grato pelas vossas opiniões
jonhhy Posted March 26, 2024 at 02:54 PM Author Report #632937 Posted March 26, 2024 at 02:54 PM Na documentação está: >>> np.trace(np.eye(3)) 3.0 >>> a = np.arange(8).reshape((2,2,2)) >>> np.trace(a) array([6, 8]) Contudo na perspectiva que procurei e pesquisei obtive: array([ [ [0, 1], [2, 3] ], [ [4, 5], [6, 7] ] ]) Ele divide em matriz a[0]: [0, 1], [2, 3] e matriz em matriz a[1]: [4, 5], [6, 7] presumo eu, o resultado pensando assim será: np.trace(a[0]) = 3 np.trace(a[1]) = 11 -- Qual a vossa perspectiva?
Rui Carlos Posted March 26, 2024 at 09:41 PM Report #632938 Posted March 26, 2024 at 09:41 PM Suspeito do slicing que é feito ao "cubo" é diferente do que indicaste, e que resulta em [[0,4],[2,6]] e [[1,5],[3,7]]. Rui Carlos Gonçalves
jonhhy Posted April 3, 2024 at 09:20 PM Author Report #632962 Posted April 3, 2024 at 09:20 PM Em 26/03/2024 às 21:41, Rui Carlos disse: Suspeito do slicing que é feito ao "cubo" é diferente do que indicaste, e que resulta em [[0,4],[2,6]] e [[1,5],[3,7]]. Sim assim bate certo Rui Carlos, mto obriagdo pela resposta
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now