From f2b5133bc6cea115f48df7a9e21c24fc1995861b Mon Sep 17 00:00:00 2001 From: tibel Date: Sat, 2 Feb 2013 07:28:46 +0100 Subject: [PATCH] Add SparseVector.NonZerosCount property --- src/Numerics/LinearAlgebra/Complex/SparseVector.cs | 9 +++++++++ src/Numerics/LinearAlgebra/Complex32/SparseVector.cs | 9 +++++++++ src/Numerics/LinearAlgebra/Double/SparseVector.cs | 9 +++++++++ src/Numerics/LinearAlgebra/Single/SparseVector.cs | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs index e104193c..d3265cfc 100644 --- a/src/Numerics/LinearAlgebra/Complex/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex/SparseVector.cs @@ -49,6 +49,15 @@ namespace MathNet.Numerics.LinearAlgebra.Complex { readonly SparseVectorStorage _storage; + /// + /// Gets the number of non zero elements in the vector. + /// + /// The number of non zero elements. + public int NonZerosCount + { + get { return _storage.ValueCount; } + } + internal SparseVector(SparseVectorStorage storage) : base(storage) { diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs index 90db1090..914fc87d 100644 --- a/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/SparseVector.cs @@ -49,6 +49,15 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 { readonly SparseVectorStorage _storage; + /// + /// Gets the number of non zero elements in the vector. + /// + /// The number of non zero elements. + public int NonZerosCount + { + get { return _storage.ValueCount; } + } + internal SparseVector(SparseVectorStorage storage) : base(storage) { diff --git a/src/Numerics/LinearAlgebra/Double/SparseVector.cs b/src/Numerics/LinearAlgebra/Double/SparseVector.cs index fbf0b1ee..e38ddde7 100644 --- a/src/Numerics/LinearAlgebra/Double/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Double/SparseVector.cs @@ -49,6 +49,15 @@ namespace MathNet.Numerics.LinearAlgebra.Double { readonly SparseVectorStorage _storage; + /// + /// Gets the number of non zero elements in the vector. + /// + /// The number of non zero elements. + public int NonZerosCount + { + get { return _storage.ValueCount; } + } + internal SparseVector(SparseVectorStorage storage) : base(storage) { diff --git a/src/Numerics/LinearAlgebra/Single/SparseVector.cs b/src/Numerics/LinearAlgebra/Single/SparseVector.cs index 4fbd996d..67f65f14 100644 --- a/src/Numerics/LinearAlgebra/Single/SparseVector.cs +++ b/src/Numerics/LinearAlgebra/Single/SparseVector.cs @@ -49,6 +49,15 @@ namespace MathNet.Numerics.LinearAlgebra.Single { readonly SparseVectorStorage _storage; + /// + /// Gets the number of non zero elements in the vector. + /// + /// The number of non zero elements. + public int NonZerosCount + { + get { return _storage.ValueCount; } + } + internal SparseVector(SparseVectorStorage storage) : base(storage) {