Math.NET Numerics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

77 lines
2.4 KiB

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
}