Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion CSparse.Tests/CSparse.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<ItemGroup>
<PackageReference Include="NUnit" Version="4.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 8 additions & 4 deletions CSparse/CSparse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@
<Company />
<Copyright>Copyright Christian Woltering © 2012-2026</Copyright>
<Authors>Christian Woltering</Authors>
<AssemblyVersion>4.4.0.0</AssemblyVersion>
<FileVersion>4.4.0.0</FileVersion>
<AssemblyVersion>4.4.1.0</AssemblyVersion>
<FileVersion>4.4.1.0</FileVersion>
<PackageTags>math sparse matrix lu cholesky qr decomposition factorization</PackageTags>
<Version>4.4.0</Version>
<Version>4.4.1</Version>
<AssemblyName>CSparse</AssemblyName>
<RootNamespace>CSparse</RootNamespace>
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/wo80/CSparse.NET</PackageProjectUrl>
<RepositoryUrl>https://github.com/wo80/CSparse.NET.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>Version 4.4.0
<PackageReleaseNotes>Version 4.4.1

* Fix issue with SparseLU refactorization

Version 4.4.0

* Add Refactorize methods to SparseCholesky, SparseLDL and SparseLU

Expand Down
2 changes: 1 addition & 1 deletion CSparse/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion CSparse/Complex/DenseMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public override bool Equals(Matrix<Complex> other, double tolerance)

var dense = other as DenseColumnMajorStorage<Complex>;

if (dense == null)
if (dense is null)
{
return false;
}
Expand Down
7 changes: 2 additions & 5 deletions CSparse/Complex/Factorization/SparseCholesky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private bool UpDown(int sigma, CompressedColumnStorage<Complex> w)

var parent = S.parent;

if (parent == null)
if (parent is null)
{
return false;
}
Expand Down Expand Up @@ -315,10 +315,7 @@ private void Factorize(CompressedColumnStorage<Complex> A, IProgress<double> pro
{
current += step;

if (progress != null)
{
progress.Report(k / (double)n);
}
progress?.Report(k / (double)n);
}

// Find nonzero pattern of L(k,:)
Expand Down
5 changes: 1 addition & 4 deletions CSparse/Complex/Factorization/SparseLDL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,7 @@ void Factorize(CompressedColumnStorage<Complex> A, IProgress<double> 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
Expand Down
9 changes: 3 additions & 6 deletions CSparse/Complex/Factorization/SparseLU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void Refactorize(CompressedColumnStorage<Complex> 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.
Expand Down Expand Up @@ -262,10 +262,7 @@ private void Factorize(CompressedColumnStorage<Complex> A, double tol, IProgress
{
current += step;

if (progress != null)
{
progress.Report(k / (double)n);
}
progress?.Report(k / (double)n);
}

// Triangular solve
Expand Down Expand Up @@ -381,7 +378,7 @@ private void SymbolicAnalysis(CompressedColumnStorage<Complex> A, int[] p)
private int SolveSp(CompressedColumnStorage<Complex> G, CompressedColumnStorage<Complex> 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;
Expand Down
4 changes: 2 additions & 2 deletions CSparse/Complex/Factorization/SparseQR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -243,7 +243,7 @@ protected override bool ApplyHouseholder(CompressedColumnStorage<Complex> 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;
Expand Down
14 changes: 7 additions & 7 deletions CSparse/Complex/SparseMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ public override void Transpose(CompressedColumnStorage<Complex> result, bool sto
public override void Add(Complex alpha, Complex beta, CompressedColumnStorage<Complex> other,
CompressedColumnStorage<Complex> 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));
}
Expand Down Expand Up @@ -379,12 +379,12 @@ public override void Add(Complex alpha, Complex beta, CompressedColumnStorage<Co
/// <inheritdoc />
public override void Multiply(CompressedColumnStorage<Complex> other, CompressedColumnStorage<Complex> 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));
}
Expand Down Expand Up @@ -494,7 +494,7 @@ public override bool Equals(Matrix<Complex> other, double tolerance)
{
var o = other as SparseMatrix;

if (o == null)
if (o is null)
{
return false;
}
Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions CSparse/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ public static CoordinateStorage<T> FromEnumerable<T>(IEnumerable<(int row, int c
{
var storage = new CoordinateStorage<T>(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;
Expand Down
4 changes: 2 additions & 2 deletions CSparse/Double/DenseMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public override void ParallelMultiply(DenseColumnMajorStorage<double> other, Den
return;
}

if (options == null)
if (options is null)
{
options = new ParallelOptions() { MaxDegreeOfParallelism = processorCount };
}
Expand Down Expand Up @@ -342,7 +342,7 @@ public override bool Equals(Matrix<double> other, double tolerance)

var dense = other as DenseColumnMajorStorage<double>;

if (dense == null)
if (dense is null)
{
return false;
}
Expand Down
7 changes: 2 additions & 5 deletions CSparse/Double/Factorization/SparseCholesky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private bool UpDown(int sigma, CompressedColumnStorage<double> w)

var parent = S.parent;

if (parent == null)
if (parent is null)
{
return false;
}
Expand Down Expand Up @@ -310,10 +310,7 @@ private void Factorize(CompressedColumnStorage<double> A, IProgress<double> prog
{
current += step;

if (progress != null)
{
progress.Report(k / (double)n);
}
progress?.Report(k / (double)n);
}

// Find nonzero pattern of L(k,:)
Expand Down
5 changes: 1 addition & 4 deletions CSparse/Double/Factorization/SparseLDL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,7 @@ void Factorize(CompressedColumnStorage<double> A, IProgress<double> 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
Expand Down
7 changes: 2 additions & 5 deletions CSparse/Double/Factorization/SparseLU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ private void Factorize(CompressedColumnStorage<double> A, double tol, IProgress<
{
current += step;

if (progress != null)
{
progress.Report(k / (double)n);
}
progress?.Report(k / (double)n);
}

// Triangular solve
Expand Down Expand Up @@ -380,7 +377,7 @@ private void SymbolicAnalysis(CompressedColumnStorage<double> A, int[] p)
private int SolveSp(CompressedColumnStorage<double> G, CompressedColumnStorage<double> 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;
Expand Down
4 changes: 2 additions & 2 deletions CSparse/Double/Factorization/SparseQR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -241,7 +241,7 @@ protected override bool ApplyHouseholder(CompressedColumnStorage<double> 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;
Expand Down
18 changes: 9 additions & 9 deletions CSparse/Double/SparseMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ public override void TransposeMultiply(double alpha, ReadOnlySpan<double> x, dou
public override void Add(double alpha, double beta, CompressedColumnStorage<double> other,
CompressedColumnStorage<double> 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));
}
Expand Down Expand Up @@ -332,12 +332,12 @@ public override void Add(double alpha, double beta, CompressedColumnStorage<doub
/// <inheritdoc />
public override void Multiply(CompressedColumnStorage<double> other, CompressedColumnStorage<double> 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));
}
Expand Down Expand Up @@ -411,7 +411,7 @@ public override void Multiply(CompressedColumnStorage<double> other, CompressedC
public override CompressedColumnStorage<double> ParallelMultiply(CompressedColumnStorage<double> other, ParallelOptions options = null)
{
// Check inputs
if (other == null)
if (other is null)
{
throw new ArgumentNullException(nameof(other));
}
Expand Down Expand Up @@ -451,7 +451,7 @@ public override CompressedColumnStorage<double> ParallelMultiply(CompressedColum
return Multiply(other);
}

if (options == null)
if (options is null)
{
options = new ParallelOptions() { MaxDegreeOfParallelism = processorCount };
}
Expand Down Expand Up @@ -563,7 +563,7 @@ public override bool Equals(Matrix<double> other, double tolerance)
{
var o = other as SparseMatrix;

if (o == null)
if (o is null)
{
return false;
}
Expand Down Expand Up @@ -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));
}
Expand Down
5 changes: 1 addition & 4 deletions CSparse/Factorization/SparseQR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ protected void Factorize(CompressedColumnStorage<T> A, IProgress<double> progres
{
current += step;

if (progress != null)
{
progress.Report(k / (double)n);
}
progress?.Report(k / (double)n);
}

rp[k] = rnz; // R(:,k) starts here
Expand Down
Loading