From a74b6d0e82f6d30ad58468e912d880ff13cbcfa2 Mon Sep 17 00:00:00 2001 From: Christian Woltering Date: Mon, 24 Aug 2026 10:54:59 +0200 Subject: [PATCH 1/3] Update test project dependencies. --- CSparse.Tests/CSparse.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSparse.Tests/CSparse.Tests.csproj b/CSparse.Tests/CSparse.Tests.csproj index e4cb7b0..7b30383 100644 --- a/CSparse.Tests/CSparse.Tests.csproj +++ b/CSparse.Tests/CSparse.Tests.csproj @@ -43,7 +43,7 @@ - + From b177d8f03fdc03be6a2846e76aa503979a404ef2 Mon Sep 17 00:00:00 2001 From: Christian Woltering Date: Mon, 24 Aug 2026 11:31:32 +0200 Subject: [PATCH 2/3] Minor code modernization - Use null-conditional access operator - Use "is null" expression instead of "== null" - Use variable deconstruction for value tuples --- CSparse/Check.cs | 2 +- CSparse/Complex/DenseMatrix.cs | 2 +- .../Complex/Factorization/SparseCholesky.cs | 7 ++----- CSparse/Complex/Factorization/SparseLDL.cs | 5 +---- CSparse/Complex/Factorization/SparseLU.cs | 9 +++------ CSparse/Complex/Factorization/SparseQR.cs | 4 ++-- CSparse/Complex/SparseMatrix.cs | 14 ++++++------- CSparse/Converter.cs | 4 ++-- CSparse/Double/DenseMatrix.cs | 4 ++-- .../Double/Factorization/SparseCholesky.cs | 7 ++----- CSparse/Double/Factorization/SparseLDL.cs | 5 +---- CSparse/Double/Factorization/SparseLU.cs | 7 ++----- CSparse/Double/Factorization/SparseQR.cs | 4 ++-- CSparse/Double/SparseMatrix.cs | 18 ++++++++--------- CSparse/Factorization/SparseQR.cs | 5 +---- CSparse/GraphHelper.cs | 14 ++++++------- CSparse/Matrix.cs | 2 +- CSparse/Ordering/DulmageMendelsohn.cs | 4 ++-- CSparse/Ordering/MaximumMatching.cs | 2 +- CSparse/Permutation.cs | 4 ++-- CSparse/Storage/CompressedColumnStorage.cs | 4 ++-- CSparse/Storage/CoordinateStorage.cs | 6 +++--- CSparse/Storage/DenseColumnMajorStorage.cs | 20 +++++++++---------- CSparse/Storage/SymbolicColumnStorage.cs | 11 +++++----- 24 files changed, 72 insertions(+), 92 deletions(-) diff --git a/CSparse/Check.cs b/CSparse/Check.cs index 7bb5851..6d5d39b 100644 --- a/CSparse/Check.cs +++ b/CSparse/Check.cs @@ -8,7 +8,7 @@ static class Check { public static void NotNull(object obj, string name) { - if (obj == null) + if (obj is null) { throw new ArgumentNullException(name); } diff --git a/CSparse/Complex/DenseMatrix.cs b/CSparse/Complex/DenseMatrix.cs index 4dc99b6..385b2d4 100644 --- a/CSparse/Complex/DenseMatrix.cs +++ b/CSparse/Complex/DenseMatrix.cs @@ -282,7 +282,7 @@ public override bool Equals(Matrix other, double tolerance) var dense = other as DenseColumnMajorStorage; - if (dense == null) + if (dense is null) { return false; } diff --git a/CSparse/Complex/Factorization/SparseCholesky.cs b/CSparse/Complex/Factorization/SparseCholesky.cs index 23b9efd..d413116 100644 --- a/CSparse/Complex/Factorization/SparseCholesky.cs +++ b/CSparse/Complex/Factorization/SparseCholesky.cs @@ -195,7 +195,7 @@ private bool UpDown(int sigma, CompressedColumnStorage w) var parent = S.parent; - if (parent == null) + if (parent is null) { return false; } @@ -315,10 +315,7 @@ private void Factorize(CompressedColumnStorage A, IProgress pro { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } // Find nonzero pattern of L(k,:) diff --git a/CSparse/Complex/Factorization/SparseLDL.cs b/CSparse/Complex/Factorization/SparseLDL.cs index 3d3778f..b2b28e5 100644 --- a/CSparse/Complex/Factorization/SparseLDL.cs +++ b/CSparse/Complex/Factorization/SparseLDL.cs @@ -312,10 +312,7 @@ void Factorize(CompressedColumnStorage A, IProgress progress) { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } // compute nonzero Pattern of kth row of L, in topological order diff --git a/CSparse/Complex/Factorization/SparseLU.cs b/CSparse/Complex/Factorization/SparseLU.cs index 132cdd4..ecd9cd2 100644 --- a/CSparse/Complex/Factorization/SparseLU.cs +++ b/CSparse/Complex/Factorization/SparseLU.cs @@ -134,7 +134,7 @@ public void Refactorize(CompressedColumnStorage A, double tol = 1.0) if (A.ColumnCount != n) { - throw new ArgumentException("Matrix dimensions don't match the factorization.", "A"); + throw new ArgumentException("Matrix dimensions don't match the factorization.", nameof(A)); } // Ensure tol is in range. @@ -262,10 +262,7 @@ private void Factorize(CompressedColumnStorage A, double tol, IProgress { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } // Triangular solve @@ -381,7 +378,7 @@ private void SymbolicAnalysis(CompressedColumnStorage A, int[] p) private int SolveSp(CompressedColumnStorage G, CompressedColumnStorage B, int k, int[] xi, Complex[] x, int[] pinv, bool lo) { - if (xi == null || x == null) return -1; + if (xi is null || x is null) return -1; var gp = G.ColumnPointers; var gi = G.RowIndices; diff --git a/CSparse/Complex/Factorization/SparseQR.cs b/CSparse/Complex/Factorization/SparseQR.cs index 0e88785..e9226d2 100644 --- a/CSparse/Complex/Factorization/SparseQR.cs +++ b/CSparse/Complex/Factorization/SparseQR.cs @@ -208,7 +208,7 @@ protected override Complex CreateHouseholder(Complex[] x, int offset, ref double { Complex s = Complex.Zero; int i; - if (x == null) return -1; // check inputs + if (x is null) return -1; // check inputs // s = norm(x) for (i = 0; i < n; i++) @@ -243,7 +243,7 @@ protected override bool ApplyHouseholder(CompressedColumnStorage V, int int p = 0; Complex tau = Complex.Zero; - if (x == null) return false; // check inputs + if (x is null) return false; // check inputs var vp = V.ColumnPointers; var vi = V.RowIndices; diff --git a/CSparse/Complex/SparseMatrix.cs b/CSparse/Complex/SparseMatrix.cs index d591fed..71a29df 100644 --- a/CSparse/Complex/SparseMatrix.cs +++ b/CSparse/Complex/SparseMatrix.cs @@ -321,12 +321,12 @@ public override void Transpose(CompressedColumnStorage result, bool sto public override void Add(Complex alpha, Complex beta, CompressedColumnStorage other, CompressedColumnStorage result) { - if (other == null) + if (other is null) { throw new ArgumentNullException(nameof(other)); } - if (result == null) + if (result is null) { throw new ArgumentNullException(nameof(result)); } @@ -379,12 +379,12 @@ public override void Add(Complex alpha, Complex beta, CompressedColumnStorage public override void Multiply(CompressedColumnStorage other, CompressedColumnStorage result) { - if (other == null) + if (other is null) { throw new ArgumentNullException(nameof(other)); } - if (result == null) + if (result is null) { throw new ArgumentNullException(nameof(result)); } @@ -494,7 +494,7 @@ public override bool Equals(Matrix other, double tolerance) { var o = other as SparseMatrix; - if (o == null) + if (o is null) { return false; } @@ -590,9 +590,9 @@ internal override int Scatter(int j, Complex beta, int[] w, Complex[] x, int mar { int i, p; - if (w == null || mat == null) return -1; // check inputs + if (w is null || mat is null) return -1; // check inputs - if (x == null) + if (x is null) { throw new ArgumentNullException(nameof(x)); } diff --git a/CSparse/Converter.cs b/CSparse/Converter.cs index dec3661..eb68b0a 100644 --- a/CSparse/Converter.cs +++ b/CSparse/Converter.cs @@ -302,9 +302,9 @@ public static CoordinateStorage FromEnumerable(IEnumerable<(int row, int c { var storage = new CoordinateStorage(rowCount, columnCount, Math.Max(rowCount, columnCount)); - foreach (var item in enumerable) + foreach (var (row, column, value) in enumerable) { - storage.At(item.row, item.column, item.value); + storage.At(row, column, value); } return storage; diff --git a/CSparse/Double/DenseMatrix.cs b/CSparse/Double/DenseMatrix.cs index 73da96c..f4f83eb 100644 --- a/CSparse/Double/DenseMatrix.cs +++ b/CSparse/Double/DenseMatrix.cs @@ -271,7 +271,7 @@ public override void ParallelMultiply(DenseColumnMajorStorage other, Den return; } - if (options == null) + if (options is null) { options = new ParallelOptions() { MaxDegreeOfParallelism = processorCount }; } @@ -342,7 +342,7 @@ public override bool Equals(Matrix other, double tolerance) var dense = other as DenseColumnMajorStorage; - if (dense == null) + if (dense is null) { return false; } diff --git a/CSparse/Double/Factorization/SparseCholesky.cs b/CSparse/Double/Factorization/SparseCholesky.cs index a135928..5b6b1f3 100644 --- a/CSparse/Double/Factorization/SparseCholesky.cs +++ b/CSparse/Double/Factorization/SparseCholesky.cs @@ -194,7 +194,7 @@ private bool UpDown(int sigma, CompressedColumnStorage w) var parent = S.parent; - if (parent == null) + if (parent is null) { return false; } @@ -310,10 +310,7 @@ private void Factorize(CompressedColumnStorage A, IProgress prog { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } // Find nonzero pattern of L(k,:) diff --git a/CSparse/Double/Factorization/SparseLDL.cs b/CSparse/Double/Factorization/SparseLDL.cs index 88a041e..2cd8be6 100644 --- a/CSparse/Double/Factorization/SparseLDL.cs +++ b/CSparse/Double/Factorization/SparseLDL.cs @@ -311,10 +311,7 @@ void Factorize(CompressedColumnStorage A, IProgress progress) { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } // compute nonzero Pattern of kth row of L, in topological order diff --git a/CSparse/Double/Factorization/SparseLU.cs b/CSparse/Double/Factorization/SparseLU.cs index d568d65..4786a19 100644 --- a/CSparse/Double/Factorization/SparseLU.cs +++ b/CSparse/Double/Factorization/SparseLU.cs @@ -261,10 +261,7 @@ private void Factorize(CompressedColumnStorage A, double tol, IProgress< { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } // Triangular solve @@ -380,7 +377,7 @@ private void SymbolicAnalysis(CompressedColumnStorage A, int[] p) private int SolveSp(CompressedColumnStorage G, CompressedColumnStorage B, int k, int[] xi, double[] x, int[] pinv, bool lo) { - if (xi == null || x == null) return -1; + if (xi is null || x is null) return -1; var gp = G.ColumnPointers; var gi = G.RowIndices; diff --git a/CSparse/Double/Factorization/SparseQR.cs b/CSparse/Double/Factorization/SparseQR.cs index 9f88ee8..5de82ab 100644 --- a/CSparse/Double/Factorization/SparseQR.cs +++ b/CSparse/Double/Factorization/SparseQR.cs @@ -206,7 +206,7 @@ protected override double CreateHouseholder(double[] x, int offset, ref double b { double s = 0; int i; - if (x == null) return -1; // check inputs + if (x is null) return -1; // check inputs // s = norm(x) for (i = 0; i < n; i++) @@ -241,7 +241,7 @@ protected override bool ApplyHouseholder(CompressedColumnStorage V, int int p = 0; double tau = 0; - if (x == null) return false; // check inputs + if (x is null) return false; // check inputs var vp = V.ColumnPointers; var vi = V.RowIndices; diff --git a/CSparse/Double/SparseMatrix.cs b/CSparse/Double/SparseMatrix.cs index b18aabc..b9941bf 100644 --- a/CSparse/Double/SparseMatrix.cs +++ b/CSparse/Double/SparseMatrix.cs @@ -274,12 +274,12 @@ public override void TransposeMultiply(double alpha, ReadOnlySpan x, dou public override void Add(double alpha, double beta, CompressedColumnStorage other, CompressedColumnStorage result) { - if (other == null) + if (other is null) { throw new ArgumentNullException(nameof(other)); } - if (result == null) + if (result is null) { throw new ArgumentNullException(nameof(result)); } @@ -332,12 +332,12 @@ public override void Add(double alpha, double beta, CompressedColumnStorage public override void Multiply(CompressedColumnStorage other, CompressedColumnStorage result) { - if (other == null) + if (other is null) { throw new ArgumentNullException(nameof(other)); } - if (result == null) + if (result is null) { throw new ArgumentNullException(nameof(result)); } @@ -411,7 +411,7 @@ public override void Multiply(CompressedColumnStorage other, CompressedC public override CompressedColumnStorage ParallelMultiply(CompressedColumnStorage other, ParallelOptions options = null) { // Check inputs - if (other == null) + if (other is null) { throw new ArgumentNullException(nameof(other)); } @@ -451,7 +451,7 @@ public override CompressedColumnStorage ParallelMultiply(CompressedColum return Multiply(other); } - if (options == null) + if (options is null) { options = new ParallelOptions() { MaxDegreeOfParallelism = processorCount }; } @@ -563,7 +563,7 @@ public override bool Equals(Matrix other, double tolerance) { var o = other as SparseMatrix; - if (o == null) + if (o is null) { return false; } @@ -659,9 +659,9 @@ internal override int Scatter(int j, double beta, int[] w, double[] x, int mark, { int i, p; - if (w == null || mat == null) return -1; // check inputs + if (w is null || mat is null) return -1; // check inputs - if (x == null) + if (x is null) { throw new ArgumentNullException(nameof(x)); } diff --git a/CSparse/Factorization/SparseQR.cs b/CSparse/Factorization/SparseQR.cs index e4b883b..404e92b 100644 --- a/CSparse/Factorization/SparseQR.cs +++ b/CSparse/Factorization/SparseQR.cs @@ -130,10 +130,7 @@ protected void Factorize(CompressedColumnStorage A, IProgress progres { current += step; - if (progress != null) - { - progress.Report(k / (double)n); - } + progress?.Report(k / (double)n); } rp[k] = rnz; // R(:,k) starts here diff --git a/CSparse/GraphHelper.cs b/CSparse/GraphHelper.cs index d22505a..bf1f95e 100644 --- a/CSparse/GraphHelper.cs +++ b/CSparse/GraphHelper.cs @@ -26,7 +26,7 @@ public static int DepthFirstSearch(int j, int[] Gp, int[] Gi, int top, int[] xi, int i, p, p2, jnew, head = 0; bool done; - if (xi == null || pstack == null) return -1; + if (xi is null || pstack is null) return -1; xi[0] = j; // initialize the recursion stack while (head >= 0) @@ -115,7 +115,7 @@ public static int[] TreePostorder(int[] parent, int n) { int j, k = 0; - if (parent == null) return null; // check inputs + if (parent is null) return null; // check inputs int[] post = new int[n]; // allocate result int[] w = new int[n]; // get workspace @@ -145,7 +145,7 @@ public static int[] ColumnCounts(SymbolicColumnStorage A, int[] parent, int[] po int i, j, k, J, p, q, jleaf = 0; int[] ATp, ATi, colcount, delta, head = null, next = null; - if (parent == null || post == null) return (null); // check inputs + if (parent is null || post is null) return (null); // check inputs int m = A.RowCount; int n = A.ColumnCount; @@ -240,7 +240,7 @@ static int IsLeaf(int i, int j, int[] first, int[] maxfirst, int[] prevleaf, int[] ancestor, ref int jleaf) { int q, s, sparent, jprev; - if (first == null || maxfirst == null || prevleaf == null || ancestor == null) + if (first is null || maxfirst is null || prevleaf is null || ancestor is null) { return (-1); } @@ -277,7 +277,7 @@ public static int TreeDepthFirstSearch(int j, int k, int[] head, int[] next, int { int i, p, top = 0; - if (head == null || next == null || post == null || stack == null) + if (head is null || next is null || post is null || stack is null) return (-1); // check inputs stack[0] = j; // place j on the stack @@ -304,7 +304,7 @@ public static int TreeDepthFirstSearch(int j, int k, int[] head, int[] next, int // xi [n...2n-1] used as workspace public static int Reach(int[] Gp, int[] Gi, int[] Bp, int[] Bi, int n, int k, int[] xi, int[] pinv) { - if (xi == null) return (-1); // check inputs + if (xi is null) return (-1); // check inputs int p, top = n; @@ -333,7 +333,7 @@ public static int EtreeReach(SymbolicColumnStorage A, int k, int[] parent, int[] { int i, p, n, len; - if (parent == null || s == null || w == null) return -1; // check inputs + if (parent is null || s is null || w is null) return -1; // check inputs int top = n = A.ColumnCount; int[] Ap = A.ColumnPointers; diff --git a/CSparse/Matrix.cs b/CSparse/Matrix.cs index aafcda9..d9c7a31 100644 --- a/CSparse/Matrix.cs +++ b/CSparse/Matrix.cs @@ -186,7 +186,7 @@ protected Matrix(int rowCount, int columnCount) public virtual bool Equals(Matrix other) { // Reject equality when the argument is null or has a different shape. - if (other == null) + if (other is null) { return false; } diff --git a/CSparse/Ordering/DulmageMendelsohn.cs b/CSparse/Ordering/DulmageMendelsohn.cs index 10636cd..da1f17c 100644 --- a/CSparse/Ordering/DulmageMendelsohn.cs +++ b/CSparse/Ordering/DulmageMendelsohn.cs @@ -134,7 +134,7 @@ public static DulmageMendelsohn Generate(SymbolicColumnStorage A, int seed = 0) int[] jimatch = MaximumMatching.Generate(A, seed); // max transversal - if (jimatch == null) return null; + if (jimatch is null) return null; // Coarse decomposition for (j = 0; j < n; j++) s[j] = -1; // unmark all cols for bfs @@ -238,7 +238,7 @@ private bool BreadthFirstSearch(SymbolicColumnStorage A, int n, int[] wi, int[] // Transpose if requested SymbolicColumnStorage C = (mark == 1) ? A.Clone() : A.Transpose(); - if (C == null) return false; // bfs of C=A' to find R3,C3 from R0 + if (C is null) return false; // bfs of C=A' to find R3,C3 from R0 Ap = C.ColumnPointers; Ai = C.RowIndices; while (head < tail) // while queue is not empty diff --git a/CSparse/Ordering/MaximumMatching.cs b/CSparse/Ordering/MaximumMatching.cs index fe907e7..08af6c5 100644 --- a/CSparse/Ordering/MaximumMatching.cs +++ b/CSparse/Ordering/MaximumMatching.cs @@ -58,7 +58,7 @@ public static int[] Generate(SymbolicColumnStorage A, int seed) // Transpose if needed SymbolicColumnStorage C = (m2 < n2) ? A.Transpose() : A.Clone(); - if (C == null) return jimatch; + if (C is null) return jimatch; n = C.ColumnCount; m = C.RowCount; diff --git a/CSparse/Permutation.cs b/CSparse/Permutation.cs index f30bb06..3e0e5a7 100644 --- a/CSparse/Permutation.cs +++ b/CSparse/Permutation.cs @@ -34,7 +34,7 @@ public static void Apply(int[] p, T[] b, T[] x, int n) /// public static void Apply(int[] p, ReadOnlySpan b, Span x, int n) { - if (p == null) + if (p is null) { b.Slice(0, n).CopyTo(x); } @@ -74,7 +74,7 @@ public static void ApplyInverse(int[] p, T[] b, T[] x, int n) /// public static void ApplyInverse(int[] p, ReadOnlySpan b, Span x, int n) { - if (p == null) + if (p is null) { b.Slice(0, n).CopyTo(x); } diff --git a/CSparse/Storage/CompressedColumnStorage.cs b/CSparse/Storage/CompressedColumnStorage.cs index d25a970..f4c2bef 100644 --- a/CSparse/Storage/CompressedColumnStorage.cs +++ b/CSparse/Storage/CompressedColumnStorage.cs @@ -588,9 +588,9 @@ public CompressedColumnStorage Clone(bool values = true) /// public override IEnumerable> EnumerateIndexed() { - foreach (var valueTuple in EnumerateIndexedAsValueTuples()) + foreach (var (row, column, value) in EnumerateIndexedAsValueTuples()) { - yield return Tuple.Create(valueTuple.row, valueTuple.column, valueTuple.value); + yield return Tuple.Create(row, column, value); } } diff --git a/CSparse/Storage/CoordinateStorage.cs b/CSparse/Storage/CoordinateStorage.cs index 448e21e..ab99d4a 100644 --- a/CSparse/Storage/CoordinateStorage.cs +++ b/CSparse/Storage/CoordinateStorage.cs @@ -92,17 +92,17 @@ public CoordinateStorage(int rowCount, int columnCount, int[] rowind, int[] coli public CoordinateStorage(int rowCount, int columnCount, int nonZerosCount, int[] rowind, int[] colind, T[] values) : this(rowCount, columnCount, 0, false) { - if (rowind == null) + if (rowind is null) { throw new ArgumentNullException(nameof(rowind)); } - if (colind == null) + if (colind is null) { throw new ArgumentNullException(nameof(colind)); } - if (values == null) + if (values is null) { throw new ArgumentNullException(nameof(values)); } diff --git a/CSparse/Storage/DenseColumnMajorStorage.cs b/CSparse/Storage/DenseColumnMajorStorage.cs index ae7c653..fd59d2c 100644 --- a/CSparse/Storage/DenseColumnMajorStorage.cs +++ b/CSparse/Storage/DenseColumnMajorStorage.cs @@ -165,8 +165,8 @@ public static DenseColumnMajorStorage OfDiagonalArray(T[] diagonal) { int order = diagonal.Length; - var A = Create(order, order); - + var A = Create(order, order); + for (int i = 0; i < order; i++) { A.At(i, i, diagonal[i]); @@ -453,7 +453,7 @@ public virtual DenseColumnMajorStorage LowerTriangle() /// If the result matrix's dimensions are not the same as this matrix. public virtual void LowerTriangle(DenseColumnMajorStorage result) { - if (result == null) + if (result is null) { throw new ArgumentNullException(nameof(result)); } @@ -480,7 +480,7 @@ public virtual void LowerTriangle(DenseColumnMajorStorage result) /// If the result matrix's dimensions are not the same as this matrix. public virtual void UpperTriangle(DenseColumnMajorStorage result) { - if (result == null) + if (result is null) { throw new ArgumentNullException(nameof(result)); } @@ -548,12 +548,12 @@ public override void Clear() /// public override IEnumerable> EnumerateIndexed() { - foreach (var valueTuple in EnumerateIndexedAsValueTuples()) - { - yield return Tuple.Create(valueTuple.row, valueTuple.column, valueTuple.value); + foreach (var (row, column, value) in EnumerateIndexedAsValueTuples()) + { + yield return Tuple.Create(row, column, value); } - } - + } + /// public override IEnumerable<(int row, int column, T value)> EnumerateIndexedAsValueTuples() { @@ -582,7 +582,7 @@ private void CopySubMatrixTo(DenseColumnMajorStorage target, int sourceRowIndex, int targetRowIndex, int rowCount, int sourceColumnIndex, int targetColumnIndex, int columnCount) { - if (target == null) + if (target is null) { throw new ArgumentNullException(nameof(target)); } diff --git a/CSparse/Storage/SymbolicColumnStorage.cs b/CSparse/Storage/SymbolicColumnStorage.cs index c3c88dc..16a82b6 100644 --- a/CSparse/Storage/SymbolicColumnStorage.cs +++ b/CSparse/Storage/SymbolicColumnStorage.cs @@ -294,10 +294,11 @@ public SymbolicColumnStorage Add(SymbolicColumnStorage other) // Remove extra space Array.Resize(ref ci, nz); - var result = new SymbolicColumnStorage(m, n, 0, false); - - result.ColumnPointers = cp; - result.RowIndices = ci; + var result = new SymbolicColumnStorage(m, n, 0, false) + { + ColumnPointers = cp, + RowIndices = ci + }; return result; } @@ -377,7 +378,7 @@ public virtual void Permute(int[] pinv, int[] q, SymbolicColumnStorage result) int[] ai = RowIndices; // Allocate memory if needed. - if (result.ColumnPointers == null) + if (result.ColumnPointers is null) { result.ColumnPointers = new int[ap.Length]; result.RowIndices = new int[ai.Length]; From 494bd68d2368996563ebb6f385aad04a428ec9e2 Mon Sep 17 00:00:00 2001 From: Christian Woltering Date: Mon, 24 Aug 2026 11:34:25 +0200 Subject: [PATCH 3/3] Update package version and release notes. --- CHANGELOG.md | 4 ++++ CSparse/CSparse.csproj | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3bab2..f13ccd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Version 4.4.1 - 2026-08-24 + +* Fix issue with SparseLU refactorization + ### Version 4.4.0 - 2026-06-10 * Add Refactorize methods to SparseCholesky, SparseLDL and SparseLU diff --git a/CSparse/CSparse.csproj b/CSparse/CSparse.csproj index 52a920a..e83a3a3 100644 --- a/CSparse/CSparse.csproj +++ b/CSparse/CSparse.csproj @@ -11,17 +11,21 @@ Copyright Christian Woltering © 2012-2026 Christian Woltering - 4.4.0.0 - 4.4.0.0 + 4.4.1.0 + 4.4.1.0 math sparse matrix lu cholesky qr decomposition factorization - 4.4.0 + 4.4.1 CSparse CSparse LGPL-2.1-only https://github.com/wo80/CSparse.NET https://github.com/wo80/CSparse.NET.git git - Version 4.4.0 + Version 4.4.1 + +* Fix issue with SparseLU refactorization + +Version 4.4.0 * Add Refactorize methods to SparseCholesky, SparseLDL and SparseLU