|
|
@ -198,6 +198,25 @@ namespace MathNet.Numerics.LinearAlgebra.Double |
|
|
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
|
|
|
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
|
|
|
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
|
|
|
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
|
|
|
public override void Add(Matrix other) |
|
|
public override void Add(Matrix other) |
|
|
|
|
|
{ |
|
|
|
|
|
DenseMatrix m = other as DenseMatrix; |
|
|
|
|
|
if (m == null) |
|
|
|
|
|
{ |
|
|
|
|
|
base.Add(other); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Add(other); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Adds another <see cref="DenseMatrix"/> to this matrix. The result will be written into this matrix.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="other">The <see cref="DenseMatrix"/> to add to this matrix.</param>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
|
|
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
|
|
|
|
|
|
public void Add(DenseMatrix other) |
|
|
{ |
|
|
{ |
|
|
if (other == null) |
|
|
if (other == null) |
|
|
{ |
|
|
{ |
|
|
@ -209,26 +228,35 @@ namespace MathNet.Numerics.LinearAlgebra.Double |
|
|
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); |
|
|
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Control.LinearAlgebraProvider.AddArrays(Data, other.Data, Data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Subtracts another matrix from this matrix. The result will be written into this matrix.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="other">The matrix to subtract.</param>
|
|
|
|
|
|
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
|
|
|
|
|
|
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
|
|
|
|
|
|
public override void Subtract(Matrix other) |
|
|
|
|
|
{ |
|
|
DenseMatrix m = other as DenseMatrix; |
|
|
DenseMatrix m = other as DenseMatrix; |
|
|
if (m == null) |
|
|
if (m == null) |
|
|
{ |
|
|
{ |
|
|
Parallel.For(0, RowCount, i => |
|
|
base.Subtract(other); |
|
|
Parallel.For(0, ColumnCount, j => |
|
|
|
|
|
At(i, j, At(i, j) + other.At(i, j)))); |
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Control.LinearAlgebraProvider.AddArrays(Data, m.Data, Data); |
|
|
Subtract(m); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Subtracts another matrix from this matrix. The result will be written into this matrix.
|
|
|
/// Subtracts another <see cref="DenseMatrix"/> from this matrix. The result will be written into this matrix.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="other">The matrix to subtract.</param>
|
|
|
/// <param name="other">The <see cref="DenseMatrix"/> to subtract.</param>
|
|
|
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
|
|
|
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
|
|
|
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
|
|
|
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
|
|
|
public override void Subtract(Matrix other) |
|
|
public void Subtract(DenseMatrix other) |
|
|
{ |
|
|
{ |
|
|
if (other == null) |
|
|
if (other == null) |
|
|
{ |
|
|
{ |
|
|
@ -239,18 +267,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double |
|
|
{ |
|
|
{ |
|
|
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); |
|
|
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixSameDimensions); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
DenseMatrix m = other as DenseMatrix; |
|
|
Control.LinearAlgebraProvider.SubtractArrays(Data, other.Data, Data); |
|
|
if (m == null) |
|
|
|
|
|
{ |
|
|
|
|
|
Parallel.For(0, RowCount, i => |
|
|
|
|
|
Parallel.For(0, ColumnCount, j => |
|
|
|
|
|
At(i, j, At(i, j) - other.At(i, j)))); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Control.LinearAlgebraProvider.SubtractArrays(Data, m.Data, Data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|
|