|
|
#region Copyright � 2009, De Santiago-Castillo JA. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
namespace DotNumerics.LinearAlgebra
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class BaseBandMatrix: BaseMatrix
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
|
protected int MeLowerBandWidth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
|
protected int MeUpperBandWidth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Public Constructors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseBandMatrix(int rows, int columns, int lowerBandWidth, int upperBandWidth)
|
|
|
: base(rows, columns)
|
|
|
{
|
|
|
if (lowerBandWidth < 0 || lowerBandWidth >= rows) throw new System.ArgumentException("lowerBandWidth < 0 || lowerBandWidth >= rows");
|
|
|
if (upperBandWidth < 0 || upperBandWidth >= columns) throw new System.ArgumentException("upperBandWidth < 0 || upperBandWidth >= columns");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.MeLowerBandWidth = lowerBandWidth;
|
|
|
this.MeUpperBandWidth = upperBandWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal BaseBandMatrix(int rows, int columns, int lowerBandWidth, int upperBandWidth, double[] Data)
|
|
|
: base(rows, columns, Data)
|
|
|
{
|
|
|
if (lowerBandWidth < 0 || lowerBandWidth >= rows) throw new System.ArgumentException("lowerBandWidth < 0 || lowerBandWidth >= rows");
|
|
|
if (upperBandWidth < 0 || upperBandWidth >= columns) throw new System.ArgumentException("upperBandWidth < 0 || upperBandWidth >= columns");
|
|
|
|
|
|
this.MeLowerBandWidth = lowerBandWidth;
|
|
|
this.MeUpperBandWidth = upperBandWidth;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal BaseBandMatrix(int size, int lowerBandWidth, int upperBandWidth)
|
|
|
: base(size)
|
|
|
{
|
|
|
if (lowerBandWidth < 0 || lowerBandWidth >= size) throw new System.ArgumentException("lowerBandWidth < 0 || lowerBandWidth >= rows");
|
|
|
if (upperBandWidth < 0 || upperBandWidth >= size) throw new System.ArgumentException("upperBandWidth < 0 || upperBandWidth >= columns");
|
|
|
|
|
|
this.MeLowerBandWidth = lowerBandWidth;
|
|
|
this.MeUpperBandWidth = upperBandWidth;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal BaseBandMatrix(int size, int lowerBandWidth, int upperBandWidth, double[] Data)
|
|
|
: base(size, Data)
|
|
|
{
|
|
|
if (lowerBandWidth < 0 || lowerBandWidth >= size) throw new System.ArgumentException("lowerBandWidth < 0 || lowerBandWidth >= rows");
|
|
|
if (upperBandWidth < 0 || upperBandWidth >= size) throw new System.ArgumentException("upperBandWidth < 0 || upperBandWidth >= columns");
|
|
|
|
|
|
this.MeLowerBandWidth = lowerBandWidth;
|
|
|
this.MeUpperBandWidth = upperBandWidth;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region Overloading Operators
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Public Methods
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override double this[int row, int column]
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
if (column >= this._ColumnCount)
|
|
|
{
|
|
|
throw new ArgumentException("Index was outside the bounds of the matrix.");
|
|
|
}
|
|
|
return this._Data[row + column * this._RowCount];
|
|
|
}
|
|
|
|
|
|
set
|
|
|
{
|
|
|
if (column >= this._ColumnCount)
|
|
|
{
|
|
|
throw new ArgumentException("Index was outside the bounds of the matrix.");
|
|
|
}
|
|
|
|
|
|
|
|
|
if ((row - column) <= this.MeLowerBandWidth && (column - row) <= this.MeUpperBandWidth)
|
|
|
{
|
|
|
this._Data[row + column * this._RowCount] = value;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
|
public int LowerBandWidth
|
|
|
{
|
|
|
get { return MeLowerBandWidth; }
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
|
|
public int UpperBandWidth
|
|
|
{
|
|
|
get { return MeUpperBandWidth; }
|
|
|
}
|
|
|
|
|
|
|
|
|
#region Static methods
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static implicit operator Matrix(BaseBandMatrix bandMatrix)
|
|
|
{
|
|
|
Matrix NewMatrix = new Matrix(bandMatrix.RowCount, bandMatrix.ColumnCount, bandMatrix.Data);
|
|
|
return NewMatrix;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region Private Methods
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
}
|
|
|
} |