Nemocas / Nemo.jl

Julia bindings for various mathematical libraries (including flint2)
http://nemocas.github.io/Nemo.jl/
Other
176 stars 57 forks source link

Remove is_diagonal, is_(lower|upper)_triangular for ZZMatrix #1768

Closed fingolfin closed 1 month ago

fingolfin commented 1 month ago

The generic methods use is_zero_entry and thus have a performance profile similar to the functions being removed here.

Before:

julia> A = diagonal_matrix(ZZ(42), 10);

julia> @btime is_diagonal(A);
  208.696 ns (0 allocations: 0 bytes)

julia> @btime is_lower_triangular(A);
  125.095 ns (0 allocations: 0 bytes)

julia> @btime is_upper_triangular(A);
  127.596 ns (0 allocations: 0 bytes)

julia> A = diagonal_matrix(ZZ(42), 100);

julia> @btime is_diagonal(A);
  19.750 μs (0 allocations: 0 bytes)

julia> @btime is_lower_triangular(A);
  11.083 μs (0 allocations: 0 bytes)

julia> @btime is_upper_triangular(A);
  11.125 μs (0 allocations: 0 bytes)

After:

julia> A = diagonal_matrix(ZZ(42), 10);

julia> @btime is_diagonal(A);
  208.708 ns (0 allocations: 0 bytes)

julia> @btime is_lower_triangular(A);
  129.279 ns (0 allocations: 0 bytes)

julia> @btime is_upper_triangular(A);
  124.396 ns (0 allocations: 0 bytes)

julia> A = diagonal_matrix(ZZ(42), 100);

julia> @btime is_diagonal(A);
  19.375 μs (0 allocations: 0 bytes)

julia> @btime is_lower_triangular(A);
  11.166 μs (0 allocations: 0 bytes)

julia> @btime is_upper_triangular(A);
  11.125 μs (0 allocations: 0 bytes)
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.66%. Comparing base (8528795) to head (adb84fb).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1768 +/- ## ========================================== + Coverage 85.60% 85.66% +0.06% ========================================== Files 95 95 Lines 36921 36880 -41 ========================================== - Hits 31606 31594 -12 + Misses 5315 5286 -29 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.