Skip to content

Conversation

@langou
Copy link

@langou langou commented Nov 24, 2025

There is a typo at
https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#Elementary-operations
for the row with UpperHessenberg, the supported operations should be MV and not MM.

This PR fixes the typo.

Co-authored-by: Steven G. Johnson <stevenj@mit.edu>
@langou
Copy link
Author

langou commented Nov 24, 2025

Hi @stevengj,

(*) OKey doc, I had no idea whether there was an optimized implementation for mat-vec or mat-mat with Hessenberg matrices but the 'MM' was not making sense and was confusing to me. Thanks!

(*) I think it is a good idea to have a 'UpperHessenberg' type even though there is no optimized operation for it. It is still convenient and can be handy. Great.

(*) I think it is a good idea to keep the line 'UpperHessenberg' in "Elementary operations", even though the line is empty, maybe one day, there will be some optimized versions there.

(*) Quoting "In principle, an optimized MV probably should be added — it could call BLAS.trmv! to multiply by the upper-triangular part, plus a linear-time loop to add in the contribution of the lower diagonal. Similarly, we could implement an optimized MM by calling BLAS.trmm! for the $\mathcal{O}( m^3 )$ triangular MM and then implement an $\mathcal{O} ( m^2 )$ loop for the remaining contributions. (Though I'm not sure how much demand there is for upper-Hessenberg MM.)" I agree with all of this. I also note that for the matrix-vector product one could use BLAS.gbmv( ) to handle this. But the approach proposed by @stevengj sounds great.

(*) Related, I am not sure what is being done for the "norms" of these special matrices. For example, LAPACK has LAPACK.lantr() for triangular matrices and then LAPACK.lansy() for symmetric matrices, etc. If I call 'opnorm( Symmetric(A), 1)', does it call LAPACK.lansy()? If I call 'opnorm( UnitUpperTriangular(A), 1)', does it call LAPACK.lantr()? This could be considered as "optimized" elementary operation. It could be good to have a column "norm". I can open an issue and a PR with this but the column will most likely be empty! I am not sure I'll be able to implement the wrapper for LAPACK norm functions.

Cheers,
Julien.

@stevengj
Copy link
Member

I think it is a good idea to have a 'UpperHessenberg' type even though there is no optimized operation for it. It is still convenient and can be handy. Great.

The optimized operation for it is ldiv.

@stevengj
Copy link
Member

Whoops, I was looking at the wrong column. This was the column for \, and there is an optimized MV routine for this (it's not LAPACK, but rather a specialized function in Julia). Sorry, I thought this was the column for *.

So "MV" is indeed appropriate.

(It also supports MM H \ B, but that is not at BLAS3-style optimization that exploits the matrix–matrix structure.)

| [`LowerTriangular`](@ref) | | | MV | MV | [`inv`](@ref), [`det`](@ref), [`logdet`](@ref) |
| [`UnitLowerTriangular`](@ref) | | | MV | MV | [`inv`](@ref), [`det`](@ref), [`logdet`](@ref) |
| [`UpperHessenberg`](@ref) | | | | MM | [`inv`](@ref), [`det`](@ref) |
| [`UpperHessenberg`](@ref) | | | | | [`inv`](@ref), [`det`](@ref) |
Copy link
Member

@stevengj stevengj Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, maybe this should be MV after all, since this is in the \ column as noted above. Also there is an optimized logdet method.

@stevengj
Copy link
Member

On the other hand, the table says that it is about "optimized methods for them in LAPACK", whereas the optimized method here is in Julia. By that criterion, UpperHessenberg should currently list no LAPACK methods.

(We might want to re-think the description of the table and what this is for.)

(*) no optimized '*'
(*) optimized '\' for M and V
(*) add logdet as an optimized method too
@langou
Copy link
Author

langou commented Nov 26, 2025

On the other hand, the table says that it is about "optimized methods for them in LAPACK", whereas the optimized method here is in Julia. By that criterion, UpperHessenberg should currently list no LAPACK methods.

(*) Maybe use "optimized" for LAPACK and then "specialized" for julia implementations. Or maybe call LAPACK something like "LAPACK optimized backend" and "specialized" sounds good. In that sense, 'logdet' would be "specialized" and not "optimized" indeed. It might be worth differentiating indeed.

Maybe the table is about "optimized" and "specialized" functionality. Or maybe two tables.

"So "MV" is indeed appropriate. (It also supports MM H \ B, but that is not at BLAS3-style optimization that exploits the matrix–matrix structure.)"

Comment: My understanding is that 'MM' does not makes sense in this table. Maybe the notation should be changed. If we want to say 'MM' (matrix-matrix), we need to say 'M'. If we want to say 'MV' (matrix-vector), we need to say 'V'. If we want to say 'MM' (matrix-vector) and 'MV' (matrix-vector), we need to say 'MV'. This is written in the "legend" just below the table "Elementary operations". I find this confusing-ish, and maybe using something like MM-MV-MS (instead of MVS) while more verbose would be clearer.

@langou
Copy link
Author

langou commented Nov 26, 2025

We are back with 'MV' in the '' column. 🔁. Let me know. Happy to remove it too if that's the decision. In any case, 'MM' needs to be changed. (To 'MV' or to a blank.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants