Browse Source

[SymmetricMatrix] Throw exception when attempting to point-wise operate symmetric+non-symmetric into symmetric

Signed-off-by: Alexander Karatarakis <alex@karatarakis.com>
pull/59/head
Alexander Karatarakis 14 years ago
parent
commit
b2aa32c872
  1. 24
      src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs

24
src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs

@ -100,6 +100,12 @@
{
var symmetricOther = other as SymmetricMatrix;
var symmetricResult = result as SymmetricMatrix;
if (symmetricResult != null && !other.IsSymmetric)
{
throw new InvalidOperationException("Symmetric + non-symmetric matrix cannot be a symmetric matrix");
}
if (symmetricOther == null || symmetricResult == null)
{
base.DoAdd(other, result);
@ -135,6 +141,12 @@
{
var symmetricOther = other as SymmetricMatrix;
var symmetricResult = result as SymmetricMatrix;
if (symmetricResult != null && !other.IsSymmetric)
{
throw new InvalidOperationException("Symmetric - non-symmetric matrix cannot be a symmetric matrix");
}
if (symmetricOther == null || symmetricResult == null)
{
base.DoSubtract(other, result);
@ -247,6 +259,12 @@
{
var symmetricOther = other as SymmetricMatrix;
var symmetricResult = result as SymmetricMatrix;
if (symmetricResult != null && !other.IsSymmetric)
{
throw new InvalidOperationException("Symmetric pointwise* non-symmetric matrix cannot be a symmetric matrix");
}
if (symmetricOther == null || symmetricResult == null)
{
base.DoPointwiseMultiply(other, result);
@ -276,6 +294,12 @@
{
var symmetricOther = other as SymmetricMatrix;
var symmetricResult = result as SymmetricMatrix;
if (symmetricResult != null && !other.IsSymmetric)
{
throw new InvalidOperationException("Symmetric pointwise/ non-symmetric matrix cannot be a symmetric matrix");
}
if (symmetricOther == null || symmetricResult == null)
{
base.DoPointwiseDivide(other, result);

Loading…
Cancel
Save