fill_diagonal not yet implemented
See original GitHub issueJust a feature request to implement jnp.fill_diagonal
, mainly for consistency with NumPy. Though is the reason this hasn’t been implemented yet that it isn’t pure in NumPy? I don’t see an issue with having a non-pure version that returns a new array.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Numpy fill_diagonal return None - python - Stack Overflow
I want to generate symmetric zero diagonal matrices.
Read more >numpy.fill_diagonal — NumPy v1.24 Manual
This function modifies the input array in-place, it does not return a value. ... implementation that never constructs the indices and uses simple...
Read more >diag: Matrix Diagonals - Rdrr.io
(when x is a matrix) logical indicating if the resulting vector, the diagonal of x , should inherit names from dimnames(x) if available....
Read more >Efficiently compute sums of diagonals of a matrix
Condition for Principal Diagonal: The row-column condition is row = column. ... Auxiliary Space: O(1), as we are not using any extra space....
Read more >Compute Weights for 'rma' Objects - metafor
The method is not yet implemented for objects of class "rma.glmm" . type. character string to specify whether to return only the diagonal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I see; here’s a quick implementation similar to
np.fill_diagonal
that should work for any batch size without reshapes or vmaps:My main hesitation here is that
np.fill_diagonal
is specified to update its input in-place. We can’t do that in JAX. We could provide an alternate API that returns an updated array, although that wouldn’t satisfy the “consistent with NumPy” constraint. What do you think?