@@ -1919,28 +1919,29 @@ const AbstractSparseVecOrMatInclAdjAndTrans = Union{AbstractSparseVecOrMat, AdjO
19191919"""
19201920 CholmodWorkspace()
19211921
1922- Reusable workspace for allocation-free calls to `ldiv!(x, L, b, ws)` with a
1923- CHOLMOD [`Factor`](@ref).
1922+ Reusable workspace for allocation-free calls to `ldiv!(x, L, b, ws)`.
19241923
19251924`cholmod_solve2` allocates two temporary dense matrices (Y and E) on every solve.
19261925A `CholmodWorkspace` holds those buffers across calls so that CHOLMOD reuses them
19271926instead of reallocating. It also pre-allocates the `cholmod_dense_struct` wrappers
1928- for `x` and `b`, eliminating all Julia-side heap allocations per solve.
1927+ for `x` and `b`.
1928+ This eliminates all Julia-side heap allocations per solve.
19291929
1930- The workspace is finalizer-protected: the CHOLMOD-managed Y and E buffers are freed
1931- automatically when the workspace is garbage-collected. A single workspace can be
1932- reused across calls with different arrays or a different number of RHS columns;
1933- CHOLMOD will resize Y and E as needed .
1930+ A finalizer frees Y adn E automatically when the worspace is garbage-collected.
1931+
1932+ A single workspace can be reused across calls with different arrays or a different number of RHS columns since
1933+ CHOLMOD will resize Y and E.
19341934
19351935# Example
19361936```julia
1937- F = cholesky(A)
1937+ F = cholesky(A)
19381938ws = CholmodWorkspace()
19391939for b in rhs_list
19401940 ldiv!(x, F, b, ws)
19411941end
19421942```
19431943"""
1944+
19441945mutable struct CholmodWorkspace
19451946 dense_x:: cholmod_dense_struct
19461947 dense_b:: cholmod_dense_struct
@@ -1950,7 +1951,7 @@ mutable struct CholmodWorkspace
19501951
19511952 function CholmodWorkspace ()
19521953 ws = new (
1953- cholmod_dense_struct (), # all fields written in ldiv! before use
1954+ cholmod_dense_struct (), # all fields will be written in ldiv! before use
19541955 cholmod_dense_struct (),
19551956 Ref (Ptr {cholmod_dense_struct} (C_NULL )),
19561957 Ref (Ptr {cholmod_dense_struct} (C_NULL )),
@@ -2051,8 +2052,7 @@ for TI in IndexTypes
20512052 end
20522053 end
20532054
2054- # Update all fields of the reused cholmod_dense_structs on every call,
2055- # since T, dimensions, and data pointers may all change between calls.
2055+ # Update all cholmod_dense_structs fields on every call in case dimensions or T change
20562056 ws. dense_x. nrow = size (x, 1 )
20572057 ws. dense_x. ncol = size (x, 2 )
20582058 ws. dense_x. nzmax = length (x)
0 commit comments