Skip to content

Commit 2d2ff5f

Browse files
Store type names as String instead of Type for full type stability
Changed all Type fields to String to achieve complete type stability: - matrix_type: Type → String - element_type: Type → String - rhs_type: Type → String (sentinel "" instead of Nothing) Now all fields are concrete types (String, Int, Float64, Tuple{Int,Int}), eliminating any remaining type instability from storing Type values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9308ce9 commit 2d2ff5f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/blas_logging.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ Uses sentinel values for optional fields to maintain type stability:
55
66
- condition_number: -Inf means not computed
77
- rhs_length: 0 means not applicable
8-
- rhs_type: Nothing means not applicable
8+
- rhs_type: "" means not applicable
99
"""
1010
struct BlasOperationInfo
1111
matrix_size::Tuple{Int, Int}
12-
matrix_type::Type
13-
element_type::Type
12+
matrix_type::String
13+
element_type::String
1414
condition_number::Float64 # -Inf means not computed
1515
rhs_length::Int # 0 means not applicable
16-
rhs_type::Type # Nothing means not applicable
16+
rhs_type::String # "" means not applicable
1717
memory_usage_MB::Float64
1818
end
1919

@@ -125,7 +125,7 @@ function _format_blas_context(op_info::BlasOperationInfo)
125125
push!(parts, "RHS length: $(op_info.rhs_length)")
126126
end
127127

128-
if op_info.rhs_type !== Nothing
128+
if !isempty(op_info.rhs_type)
129129
push!(parts, "RHS type: $(op_info.rhs_type)")
130130
end
131131

@@ -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, 0, Nothing, 0.0))
138+
(0, 0), "", "", -Inf, 0, "", 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, 0, Nothing, 0.0))
144+
(0, 0), "", "", -Inf, 0, "", 0.0))
145145
category, message, details = interpret_blas_code(func, info)
146146

147147
verbosity_field = if category in [
@@ -183,11 +183,11 @@ end
183183
function get_blas_operation_info(func::Symbol, A, b; condition = false)
184184
# Matrix properties (always present)
185185
matrix_size = size(A)
186-
matrix_type = typeof(A)
187-
element_type = eltype(A)
186+
matrix_type = string(typeof(A))
187+
element_type = string(eltype(A))
188188

189189
# Memory usage estimate (always present)
190-
mem_bytes = prod(matrix_size) * sizeof(element_type)
190+
mem_bytes = prod(matrix_size) * sizeof(eltype(A))
191191
memory_usage_MB = round(mem_bytes / 1024^2, digits = 2)
192192

193193
# Condition number (optional - use -Inf as sentinel)
@@ -201,9 +201,9 @@ function get_blas_operation_info(func::Symbol, A, b; condition = false)
201201
-Inf
202202
end
203203

204-
# RHS properties (optional - use 0 and Nothing as sentinels)
204+
# RHS properties (optional - use 0 and "" as sentinels)
205205
rhs_length = b !== nothing ? length(b) : 0
206-
rhs_type = b !== nothing ? typeof(b) : Nothing
206+
rhs_type = b !== nothing ? string(typeof(b)) : ""
207207

208208
return BlasOperationInfo(
209209
matrix_size,

0 commit comments

Comments
 (0)