forked from tsai/mathnet-numerics
3 changed files with 56 additions and 3 deletions
@ -0,0 +1,52 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace MathNet.Numerics.LinearAlgebra.Storage |
||||
|
{ |
||||
|
using MathNet.Numerics.Properties; |
||||
|
|
||||
|
public abstract class SymmetricMatrixStorage<T> : MatrixStorage<T> |
||||
|
where T : struct, IEquatable<T>, IFormattable |
||||
|
{ |
||||
|
// [ruegg] public fields are OK here
|
||||
|
|
||||
|
protected SymmetricMatrixStorage(int order) |
||||
|
: base(order, order) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public override bool IsFullyMutable |
||||
|
{ |
||||
|
get { return false; } |
||||
|
} |
||||
|
|
||||
|
public override bool IsMutable(int row, int column) |
||||
|
{ |
||||
|
return row <= column; |
||||
|
} |
||||
|
|
||||
|
public override void Clear() |
||||
|
{ |
||||
|
for (var i = 0; i < RowCount; i++) |
||||
|
{ |
||||
|
for (var j = i; j < ColumnCount; j++) |
||||
|
{ |
||||
|
At(i, j, default(T)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public override void Clear(int rowIndex, int rowCount, int columnIndex, int columnCount) |
||||
|
{ |
||||
|
for (var i = rowIndex; i < rowIndex + rowCount; i++) |
||||
|
{ |
||||
|
for (var j = Math.Max(columnIndex, i); j < columnIndex + columnCount; j++) |
||||
|
{ |
||||
|
At(i, j, default(T)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue