Browse Source

LA: restrict modified sparse*diagonal matrix product to square diagonal matrices only

pull/222/head
Christoph Ruegg 13 years ago
parent
commit
7820018d3b
  1. 10
      src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
  2. 2
      src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
  3. 10
      src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
  4. 2
      src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
  5. 10
      src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
  6. 2
      src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
  7. 10
      src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
  8. 2
      src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

10
src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs

@ -435,8 +435,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return;
}
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
if (RowCount == ColumnCount)
{
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
return;
}
base.DoMultiply(other, result);
}
/// <summary>

2
src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs

@ -932,7 +932,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
var diagonalOther = other as DiagonalMatrix;
if (diagonalOther != null && sparseResult != null)
if (diagonalOther != null && sparseResult != null && other.RowCount == other.ColumnCount)
{
var diagonal = ((DiagonalMatrixStorage<Complex>)other.Storage).Data;
// TODO: Map is rather generic, we can do better

10
src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs

@ -429,8 +429,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return;
}
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
if (RowCount == ColumnCount)
{
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
return;
}
base.DoMultiply(other, result);
}
/// <summary>

2
src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs

@ -926,7 +926,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
var diagonalOther = other as DiagonalMatrix;
if (diagonalOther != null && sparseResult != null)
if (diagonalOther != null && sparseResult != null && other.RowCount == other.ColumnCount)
{
var diagonal = ((DiagonalMatrixStorage<Complex32>)other.Storage).Data;
// TODO: Map is rather generic, we can do better

10
src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs

@ -409,8 +409,14 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return;
}
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
if (RowCount == ColumnCount)
{
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
return;
}
base.DoMultiply(other, result);
}
/// <summary>

2
src/Numerics/LinearAlgebra/Double/SparseMatrix.cs

@ -928,7 +928,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
var diagonalOther = other as DiagonalMatrix;
if (diagonalOther != null && sparseResult != null)
if (diagonalOther != null && sparseResult != null && other.RowCount == other.ColumnCount)
{
var diagonal = ((DiagonalMatrixStorage<double>)other.Storage).Data;
// TODO: Map is rather generic, we can do better

10
src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs

@ -409,8 +409,14 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return;
}
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
if (RowCount == ColumnCount)
{
// TODO: Map is rather generic, we can do better
other.MapIndexed((i, j, x) => _data[i]*x, result, false);
return;
}
base.DoMultiply(other, result);
}
/// <summary>

2
src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

@ -933,7 +933,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
var diagonalOther = other as DiagonalMatrix;
if (diagonalOther != null && sparseResult != null)
if (diagonalOther != null && sparseResult != null && other.RowCount == other.ColumnCount)
{
var diagonal = ((DiagonalMatrixStorage<float>)other.Storage).Data;
// TODO: Map is rather generic, we can do better

Loading…
Cancel
Save