13 changed files with 234 additions and 306 deletions
@ -0,0 +1,77 @@ |
|||||
|
using System; |
||||
|
using MathNet.Numerics.Properties; |
||||
|
|
||||
|
namespace MathNet.Numerics.LinearAlgebra.Storage |
||||
|
{ |
||||
|
// ReSharper disable UnusedParameter.Global
|
||||
|
internal static class ArgumentValidation |
||||
|
{ |
||||
|
public static void CopySubMatrixTo( |
||||
|
int sourceRowCount, int sourceColumnCount, |
||||
|
int targetRowCount, int targetColumnCount, |
||||
|
int sourceRowIndex, int targetRowIndex, int rowCount, |
||||
|
int sourceColumnIndex, int targetColumnIndex, int columnCount) |
||||
|
{ |
||||
|
if (rowCount < 1) |
||||
|
{ |
||||
|
throw new ArgumentException(Resources.ArgumentMustBePositive, "rowCount"); |
||||
|
} |
||||
|
|
||||
|
if (columnCount < 1) |
||||
|
{ |
||||
|
throw new ArgumentException(Resources.ArgumentMustBePositive, "columnCount"); |
||||
|
} |
||||
|
|
||||
|
// Verify Source
|
||||
|
|
||||
|
if (sourceRowIndex >= sourceRowCount || sourceRowIndex < 0) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("sourceRowIndex"); |
||||
|
} |
||||
|
|
||||
|
if (sourceColumnIndex >= sourceColumnCount || sourceColumnIndex < 0) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("sourceColumnIndex"); |
||||
|
} |
||||
|
|
||||
|
var sourceRowMax = sourceRowIndex + rowCount; |
||||
|
var sourceColumnMax = sourceColumnIndex + columnCount; |
||||
|
|
||||
|
if (sourceRowMax > sourceRowCount) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("rowCount"); |
||||
|
} |
||||
|
|
||||
|
if (sourceColumnMax > sourceColumnCount) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("columnCount"); |
||||
|
} |
||||
|
|
||||
|
// Verify Target
|
||||
|
|
||||
|
if (targetRowIndex >= targetRowCount || targetRowIndex < 0) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("targetRowIndex"); |
||||
|
} |
||||
|
|
||||
|
if (targetColumnIndex >= targetColumnCount || targetColumnIndex < 0) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("targetColumnIndex"); |
||||
|
} |
||||
|
|
||||
|
var targetRowMax = targetRowIndex + rowCount; |
||||
|
var targetColumnMax = targetColumnIndex + columnCount; |
||||
|
|
||||
|
if (targetRowMax > targetRowCount) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("rowCount"); |
||||
|
} |
||||
|
|
||||
|
if (targetColumnMax > targetColumnCount) |
||||
|
{ |
||||
|
throw new ArgumentOutOfRangeException("columnCount"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// ReSharper restore UnusedParameter.Global
|
||||
|
} |
||||
Loading…
Reference in new issue