Skip to content

Commit 752c6f2

Browse files
authored
Merge pull request #1003 from DoctorKrolic/debugger-display
Add debugger display proxy to vector and matrix
2 parents eb89b3d + 927100a commit 752c6f2

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/Numerics/LinearAlgebra/Matrix.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
// OTHER DEALINGS IN THE SOFTWARE.
2828
// </copyright>
2929

30+
using MathNet.Numerics.LinearAlgebra.Storage;
31+
using MathNet.Numerics.Threading;
3032
using System;
3133
using System.Collections.Generic;
34+
using System.Diagnostics;
3235
using System.Linq;
3336
using System.Runtime;
3437
using System.Runtime.CompilerServices;
35-
using MathNet.Numerics.LinearAlgebra.Storage;
36-
using MathNet.Numerics.Threading;
3738

3839
namespace MathNet.Numerics.LinearAlgebra
3940
{
@@ -42,6 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra
4243
/// </summary>
4344
/// <typeparam name="T">Supported data types are <c>double</c>, <c>single</c>, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
4445
[Serializable]
46+
[DebuggerTypeProxy(typeof(MatrixDebuggingView<>))]
4547
public abstract partial class Matrix<T> : IFormattable, IEquatable<Matrix<T>>, ICloneable
4648
where T : struct, IEquatable<T>, IFormattable
4749
{
@@ -1879,4 +1881,18 @@ public bool ForAll2<TOther>(Func<T, TOther, bool> predicate, Matrix<TOther> othe
18791881
return Storage.Find2(other.Storage, (x, y) => !predicate(x, y), zeros) == null;
18801882
}
18811883
}
1884+
1885+
internal class MatrixDebuggingView<T>
1886+
where T : struct, IEquatable<T>, IFormattable
1887+
{
1888+
private readonly Matrix<T> _matrix;
1889+
1890+
public MatrixDebuggingView(Matrix<T> matrix)
1891+
{
1892+
_matrix = matrix;
1893+
}
1894+
1895+
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
1896+
public T[,] Items => _matrix.ToArray();
1897+
}
18821898
}

src/Numerics/LinearAlgebra/Vector.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
// OTHER DEALINGS IN THE SOFTWARE.
2828
// </copyright>
2929

30+
using MathNet.Numerics.LinearAlgebra.Storage;
3031
using System;
3132
using System.Collections;
3233
using System.Collections.Generic;
34+
using System.Diagnostics;
3335
using System.Runtime;
3436
using System.Runtime.CompilerServices;
35-
using MathNet.Numerics.LinearAlgebra.Storage;
3637

3738
namespace MathNet.Numerics.LinearAlgebra
3839
{
@@ -41,6 +42,7 @@ namespace MathNet.Numerics.LinearAlgebra
4142
/// </summary>
4243
/// <typeparam name="T">Supported data types are double, single, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
4344
[Serializable]
45+
[DebuggerTypeProxy(typeof(VectorDebuggingView<>))]
4446
public abstract partial class Vector<T> : IFormattable, IEquatable<Vector<T>>, IList, IList<T>, ICloneable
4547
where T : struct, IEquatable<T>, IFormattable
4648
{
@@ -529,4 +531,18 @@ public bool ForAll2<TOther>(Func<T, TOther, bool> predicate, Vector<TOther> othe
529531
return Storage.Find2(other.Storage, (x, y) => !predicate(x, y), zeros) == null;
530532
}
531533
}
534+
535+
internal class VectorDebuggingView<T>
536+
where T : struct, IEquatable<T>, IFormattable
537+
{
538+
private readonly Vector<T> _vector;
539+
540+
public VectorDebuggingView(Vector<T> vector)
541+
{
542+
_vector = vector;
543+
}
544+
545+
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
546+
public T[] Items => _vector.ToArray();
547+
}
532548
}

0 commit comments

Comments
 (0)