Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Add an overload to IsSymmetric that accepts a tolerance #856

@CatchemAL

Description

@CatchemAL

Currently IsSymmetric() is implemented as a generic method on IComparable. It would be good if it accepted a tolerance. For large symmetric matrices, it feels restrictive if a tiny floating point error caused this to return false.

Will need to be a T4 template job (or just a few special cases like double and float) as IComparable does not allow difference comparisons (AFAIK). I imagine it is faster if it's not generic. Proposed API:

/// Some lovely comments...
/// param isRelative: whether matrix is symmetric based on the relative or absolute error
public static double IsSymmetric(this double[,] a, double tol = 0, bool isRelativeError = false)

so you could say, M[i,j] cannot be different to M[j,i] by more than 0.0001% or maybe 1e-12 etc.

Question

@cesarsouza Is this useful or am I being paranoid (I want it for #832)? Can you envisage any scenario where a matrix that should be symmetric is not exactly symmetric because of tiny rounding errors? if you can, assign this to me, if you can't, feel free to close this issue.

Thanks!
Alex

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions