Browse Source

LA: Matrix Rank calculation should use a tolerance based on the matrix size #334

pull/336/merge
Christoph Ruegg 11 years ago
parent
commit
de15eb6dc1
  1. 5
      src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs
  2. 5
      src/Numerics/LinearAlgebra/Complex32/Factorization/Svd.cs
  3. 5
      src/Numerics/LinearAlgebra/Double/Factorization/Svd.cs
  4. 2
      src/Numerics/LinearAlgebra/Factorization/Svd.cs
  5. 5
      src/Numerics/LinearAlgebra/Single/Factorization/Svd.cs

5
src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -71,7 +71,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
{ {
get get
{ {
return S.Count(t => !t.Magnitude.AlmostEqual(0.0)); double tolerance = Precision.DoublePrecision*Math.Max(U.RowCount, VT.RowCount);
return S.Count(t => t.Magnitude > tolerance);
} }
} }

5
src/Numerics/LinearAlgebra/Complex32/Factorization/Svd.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -66,7 +66,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
{ {
get get
{ {
return S.Count(t => !t.Magnitude.AlmostEqual(0.0f)); double tolerance = Precision.SinglePrecision*Math.Max(U.RowCount, VT.RowCount);
return S.Count(t => t.Magnitude > tolerance);
} }
} }

5
src/Numerics/LinearAlgebra/Double/Factorization/Svd.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -64,7 +64,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
{ {
get get
{ {
return S.Count(t => !Math.Abs(t).AlmostEqual(0.0)); double tolerance = Precision.DoublePrecision*Math.Max(U.RowCount, VT.RowCount);
return S.Count(t => Math.Abs(t) > tolerance);
} }
} }

2
src/Numerics/LinearAlgebra/Factorization/Svd.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation

5
src/Numerics/LinearAlgebra/Single/Factorization/Svd.cs

@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics // http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com // http://mathnetnumerics.codeplex.com
// //
// Copyright (c) 2009-2013 Math.NET // Copyright (c) 2009-2015 Math.NET
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
@ -64,7 +64,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
{ {
get get
{ {
return S.Count(t => !Math.Abs(t).AlmostEqual(0.0f)); double tolerance = Precision.SinglePrecision*Math.Max(U.RowCount, VT.RowCount);
return S.Count(t => Math.Abs(t) > tolerance);
} }
} }

Loading…
Cancel
Save