Skip to content

Commit 9308ce9

Browse files
Use rhs_length instead of rhs_size tuple for better type stability
Changed from Tuple{Vararg{Int}} to Int for storing RHS length. Uses sentinel value 0 for "not applicable" instead of empty tuple. This is simpler and more type-stable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0b63628 commit 9308ce9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/blas_logging.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Type-stable container for BLAS operation information.
44
Uses sentinel values for optional fields to maintain type stability:
55
66
- condition_number: -Inf means not computed
7-
- rhs_size: () means not applicable
7+
- rhs_length: 0 means not applicable
88
- rhs_type: Nothing means not applicable
99
"""
1010
struct BlasOperationInfo
1111
matrix_size::Tuple{Int, Int}
1212
matrix_type::Type
1313
element_type::Type
1414
condition_number::Float64 # -Inf means not computed
15-
rhs_size::Tuple{Vararg{Int}} # () means not applicable
15+
rhs_length::Int # 0 means not applicable
1616
rhs_type::Type # Nothing means not applicable
1717
memory_usage_MB::Float64
1818
end
@@ -121,8 +121,8 @@ function _format_blas_context(op_info::BlasOperationInfo)
121121
push!(parts, "Condition number: $(round(op_info.condition_number, sigdigits=4))")
122122
end
123123

124-
if !isempty(op_info.rhs_size)
125-
push!(parts, "RHS size: $(op_info.rhs_size)")
124+
if op_info.rhs_length > 0
125+
push!(parts, "RHS length: $(op_info.rhs_length)")
126126
end
127127

128128
if op_info.rhs_type !== Nothing
@@ -135,13 +135,13 @@ end
135135
"""
136136
blas_info_msg(func::Symbol, info::Integer;
137137
extra_context::BlasOperationInfo = BlasOperationInfo(
138-
(0, 0), Nothing, Nothing, -Inf, (), Nothing, 0.0))
138+
(0, 0), Nothing, Nothing, -Inf, 0, Nothing, 0.0))
139139
140140
Log BLAS/LAPACK return code information with appropriate verbosity level.
141141
"""
142142
function blas_info_msg(func::Symbol, info::Integer;
143143
extra_context::BlasOperationInfo = BlasOperationInfo(
144-
(0, 0), Nothing, Nothing, -Inf, (), Nothing, 0.0))
144+
(0, 0), Nothing, Nothing, -Inf, 0, Nothing, 0.0))
145145
category, message, details = interpret_blas_code(func, info)
146146

147147
verbosity_field = if category in [
@@ -201,16 +201,16 @@ function get_blas_operation_info(func::Symbol, A, b; condition = false)
201201
-Inf
202202
end
203203

204-
# RHS properties (optional - use () and Nothing as sentinels)
205-
rhs_size = b !== nothing ? size(b) : ()
204+
# RHS properties (optional - use 0 and Nothing as sentinels)
205+
rhs_length = b !== nothing ? length(b) : 0
206206
rhs_type = b !== nothing ? typeof(b) : Nothing
207207

208208
return BlasOperationInfo(
209209
matrix_size,
210210
matrix_type,
211211
element_type,
212212
condition_number,
213-
rhs_size,
213+
rhs_length,
214214
rhs_type,
215215
memory_usage_MB
216216
)

0 commit comments

Comments
 (0)