Skip to content

feat(types): make TernaryHV parametric over integer type#54

Merged
cvigilv merged 1 commit intoKermit-UGent:mainfrom
cvigilv:feat-parametrized-ternary-hv
Mar 23, 2026
Merged

feat(types): make TernaryHV parametric over integer type#54
cvigilv merged 1 commit intoKermit-UGent:mainfrom
cvigilv:feat-parametrized-ternary-hv

Conversation

@cvigilv
Copy link
Collaborator

@cvigilv cvigilv commented Mar 23, 2026

  • Refactor TernaryHV to be parametric over integer type (T <: Integer)
  • Add inner and outer constructors for type inference and conversion
  • Provide type-specific constructors for TernaryHV{T}
  • Update helper methods (copy, similar, normalize) to preserve type parameter
  • Update tests to cover TernaryHV with various integer types

- Refactor TernaryHV to be parametric over integer type (T <: Integer)
- Add inner and outer constructors for type inference and conversion
- Provide type-specific constructors for TernaryHV{T}
- Update helper methods (copy, similar, normalize) to preserve type parameter
- Update tests to cover TernaryHV with various integer types
@cvigilv
Copy link
Collaborator Author

cvigilv commented Mar 23, 2026

Mini benchmark:

julia> for T in (Int8, Int16, Int32, Int64)
           println("Benchmarking with $T")
           H = [TernaryHV{T}() for _ in 1:10]
           @show @benchmark sum($H)
           @show @benchmark prod($H)
           println()
       end
Benchmarking with Int8
#= REPL[7]:4 =# @benchmark(sum($(Expr(:$, :H)))) = Trial(4.655 μs)
#= REPL[7]:5 =# @benchmark(prod($(Expr(:$, :H)))) = Trial(2.729 μs)

Benchmarking with Int16
#= REPL[7]:4 =# @benchmark(sum($(Expr(:$, :H)))) = Trial(8.541 μs)
#= REPL[7]:5 =# @benchmark(prod($(Expr(:$, :H)))) = Trial(5.479 μs)

Benchmarking with Int32
#= REPL[7]:4 =# @benchmark(sum($(Expr(:$, :H)))) = Trial(17.209 μs)
#= REPL[7]:5 =# @benchmark(prod($(Expr(:$, :H)))) = Trial(11.667 μs)

Benchmarking with Int64
#= REPL[7]:4 =# @benchmark(sum($(Expr(:$, :H)))) = Trial(36.667 μs)
#= REPL[7]:5 =# @benchmark(prod($(Expr(:$, :H)))) = Trial(27.541 μs)

This is useful for optimizing bigger experiments.

@cvigilv
Copy link
Collaborator Author

cvigilv commented Mar 23, 2026

Immediately merging this as I think it is a trivial addition.

@cvigilv cvigilv merged commit faa918e into Kermit-UGent:main Mar 23, 2026
3 checks passed
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.

1 participant