Browse Source
Merge pull request #578 from RMAReader/master
SparseMatrix implementation of DoTransposeThisAndMultiply
pull/601/head
Christoph Ruegg
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
116 additions and
0 deletions
-
src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
-
src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
-
src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
-
src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
|
|
|
@ -1145,6 +1145,35 @@ namespace MathNet.Numerics.LinearAlgebra.Complex |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected override void DoTransposeThisAndMultiply(Vector<Complex> rightSide, Vector<Complex> result) |
|
|
|
{ |
|
|
|
var rowPointers = _storage.RowPointers; |
|
|
|
var columnIndices = _storage.ColumnIndices; |
|
|
|
var values = _storage.Values; |
|
|
|
|
|
|
|
for (var row = 0; row < RowCount; row++) |
|
|
|
{ |
|
|
|
var startIndex = rowPointers[row]; |
|
|
|
var endIndex = rowPointers[row + 1]; |
|
|
|
|
|
|
|
if (startIndex == endIndex) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var rightSideValue = rightSide[row]; |
|
|
|
for (var index = startIndex; index < endIndex; index++) |
|
|
|
{ |
|
|
|
result[columnIndices[index]] += values[index] * rightSideValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -1144,6 +1144,35 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected override void DoTransposeThisAndMultiply(Vector<Complex32> rightSide, Vector<Complex32> result) |
|
|
|
{ |
|
|
|
var rowPointers = _storage.RowPointers; |
|
|
|
var columnIndices = _storage.ColumnIndices; |
|
|
|
var values = _storage.Values; |
|
|
|
|
|
|
|
for (var row = 0; row < RowCount; row++) |
|
|
|
{ |
|
|
|
var startIndex = rowPointers[row]; |
|
|
|
var endIndex = rowPointers[row + 1]; |
|
|
|
|
|
|
|
if (startIndex == endIndex) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var rightSideValue = rightSide[row]; |
|
|
|
for (var index = startIndex; index < endIndex; index++) |
|
|
|
{ |
|
|
|
result[columnIndices[index]] += values[index] * rightSideValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -1142,6 +1142,35 @@ namespace MathNet.Numerics.LinearAlgebra.Double |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected override void DoTransposeThisAndMultiply(Vector<double> rightSide, Vector<double> result) |
|
|
|
{ |
|
|
|
var rowPointers = _storage.RowPointers; |
|
|
|
var columnIndices = _storage.ColumnIndices; |
|
|
|
var values = _storage.Values; |
|
|
|
|
|
|
|
for (var row = 0; row < RowCount; row++) |
|
|
|
{ |
|
|
|
var startIndex = rowPointers[row]; |
|
|
|
var endIndex = rowPointers[row + 1]; |
|
|
|
|
|
|
|
if (startIndex == endIndex) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var rightSideValue = rightSide[row]; |
|
|
|
for (var index = startIndex; index < endIndex; index++) |
|
|
|
{ |
|
|
|
result[columnIndices[index]] += values[index] * rightSideValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -1147,6 +1147,35 @@ namespace MathNet.Numerics.LinearAlgebra.Single |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected override void DoTransposeThisAndMultiply(Vector<float> rightSide, Vector<float> result) |
|
|
|
{ |
|
|
|
var rowPointers = _storage.RowPointers; |
|
|
|
var columnIndices = _storage.ColumnIndices; |
|
|
|
var values = _storage.Values; |
|
|
|
|
|
|
|
for (var row = 0; row < RowCount; row++) |
|
|
|
{ |
|
|
|
var startIndex = rowPointers[row]; |
|
|
|
var endIndex = rowPointers[row + 1]; |
|
|
|
|
|
|
|
if (startIndex == endIndex) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var rightSideValue = rightSide[row]; |
|
|
|
for (var index = startIndex; index < endIndex; index++) |
|
|
|
{ |
|
|
|
result[columnIndices[index]] += values[index] * rightSideValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
|