Browse Source

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

provider
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; return;
} }
// TODO: Map is rather generic, we can do better if (RowCount == ColumnCount)
other.MapIndexed((i, j, x) => _data[i]*x, result, false); {
// 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> /// <summary>

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

@ -932,7 +932,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
} }
var diagonalOther = other as DiagonalMatrix; 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; var diagonal = ((DiagonalMatrixStorage<Complex>)other.Storage).Data;
// TODO: Map is rather generic, we can do better // 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; return;
} }
// TODO: Map is rather generic, we can do better if (RowCount == ColumnCount)
other.MapIndexed((i, j, x) => _data[i]*x, result, false); {
// 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> /// <summary>

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

@ -926,7 +926,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
} }
var diagonalOther = other as DiagonalMatrix; 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; var diagonal = ((DiagonalMatrixStorage<Complex32>)other.Storage).Data;
// TODO: Map is rather generic, we can do better // 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; return;
} }
// TODO: Map is rather generic, we can do better if (RowCount == ColumnCount)
other.MapIndexed((i, j, x) => _data[i]*x, result, false); {
// 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> /// <summary>

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

@ -928,7 +928,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
} }
var diagonalOther = other as DiagonalMatrix; 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; var diagonal = ((DiagonalMatrixStorage<double>)other.Storage).Data;
// TODO: Map is rather generic, we can do better // 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; return;
} }
// TODO: Map is rather generic, we can do better if (RowCount == ColumnCount)
other.MapIndexed((i, j, x) => _data[i]*x, result, false); {
// 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> /// <summary>

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

@ -933,7 +933,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
} }
var diagonalOther = other as DiagonalMatrix; 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; var diagonal = ((DiagonalMatrixStorage<float>)other.Storage).Data;
// TODO: Map is rather generic, we can do better // TODO: Map is rather generic, we can do better

Loading…
Cancel
Save