Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Feb 14, 2025

Since these functions act on arbitrary AbstractArrays, we should ideally not assume mutability of the intermediate array retmat. Instead, we may rely on the fact that the Hermitian wrapper implicitly sets the imaginary components of the diagonal elements to zero. This change will mean that the parents do have non-zero imaginary components, but this may be seen as an implementation detail.

Alternately, if this is not desired, we may explicitly set the diagonal elements for StridedArrays, which are usually mutable.

This PR will get the following to work, e.g.:

julia> A = complex.(SMatrix{4,4}(diagm(0=>[2,4,8,16])))
4×4 SMatrix{4, 4, Complex{Int64}, 16} with indices SOneTo(4)×SOneTo(4):
 2+0im  0+0im  0+0im   0+0im
 0+0im  4+0im  0+0im   0+0im
 0+0im  0+0im  8+0im   0+0im
 0+0im  0+0im  0+0im  16+0im

julia> exp(Hermitian(A))
4×4 Hermitian{ComplexF64, Matrix{ComplexF64}}:
 7.38906+0.0im      0.0+0.0im      0.0+0.0im        0.0+0.0im
     0.0-0.0im  54.5982+0.0im      0.0+0.0im        0.0+0.0im
     0.0-0.0im      0.0-0.0im  2980.96+0.0im        0.0+0.0im
     0.0-0.0im      0.0-0.0im      0.0-0.0im  8.88611e6+0.0im

Prior to this, the method call errors, as an SMatrix doesn't support setindex!.

Adding tests for this change is a little tricky, now that this repo is separated from julia, and the test helpers lie in the main julia repo. Any suggestions?

@jishnub jishnub added the arrays [a, r, r, a, y, s] label Feb 14, 2025
@codecov
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.89%. Comparing base (2a1696a) to head (83f2059).
Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1206      +/-   ##
==========================================
+ Coverage   91.86%   91.89%   +0.02%     
==========================================
  Files          34       34              
  Lines       15365    15353      -12     
==========================================
- Hits        14115    14108       -7     
+ Misses       1250     1245       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dkarrasch
Copy link
Member

Since we don't seem to have "standard" tests that would depend on this, I think this is fine. Or do we need to sharpen some tests, like test whether the diagonal isreal?

@jishnub
Copy link
Member Author

jishnub commented Feb 19, 2025

Perhaps we should just go ahead

@dkarrasch dkarrasch merged commit e096a03 into master Feb 19, 2025
4 checks passed
@dkarrasch dkarrasch deleted the jishnub/symfn_setindex branch February 19, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrays [a, r, r, a, y, s]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants