diff --git a/src/Numerics/Properties/Resources1.Designer.cs b/src/Numerics/Properties/Resources1.Designer.cs new file mode 100644 index 00000000..afac0b4e --- /dev/null +++ b/src/Numerics/Properties/Resources1.Designer.cs @@ -0,0 +1,792 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.225 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MathNet.Numerics.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MathNet.Numerics.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to The array arguments must have the same length.. + /// + internal static string ArgumentArraysSameLength { + get { + return ResourceManager.GetString("ArgumentArraysSameLength", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The given array is the wrong length. Should be {0}.. + /// + internal static string ArgumentArrayWrongLength { + get { + return ResourceManager.GetString("ArgumentArrayWrongLength", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The argument must be between 0 and 1.. + /// + internal static string ArgumentBetween0And1 { + get { + return ResourceManager.GetString("ArgumentBetween0And1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value cannot be in the range -1 < x < 1.. + /// + internal static string ArgumentCannotBeBetweenOneAndNegativeOne { + get { + return ResourceManager.GetString("ArgumentCannotBeBetweenOneAndNegativeOne", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must be even.. + /// + internal static string ArgumentEven { + get { + return ResourceManager.GetString("ArgumentEven", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The histogram does not contains the value.. + /// + internal static string ArgumentHistogramContainsNot { + get { + return ResourceManager.GetString("ArgumentHistogramContainsNot", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value is expected to be between {0} and {1} (including {0} and {1}).. + /// + internal static string ArgumentInIntervalXYInclusive { + get { + return ResourceManager.GetString("ArgumentInIntervalXYInclusive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to At least one item of {0} is a null reference (Nothing in Visual Basic).. + /// + internal static string ArgumentItemNull { + get { + return ResourceManager.GetString("ArgumentItemNull", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must be greater than or equal to one.. + /// + internal static string ArgumentLessThanOne { + get { + return ResourceManager.GetString("ArgumentLessThanOne", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to han the given upper bound.. + /// + internal static string ArgumentLowerBoundLargerThanUpperBound { + get { + return ResourceManager.GetString("ArgumentLowerBoundLargerThanUpperBound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix dimensions must agree.. + /// + internal static string ArgumentMatrixDimensions { + get { + return ResourceManager.GetString("ArgumentMatrixDimensions", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The requested matrix does not exist.. + /// + internal static string ArgumentMatrixDoesNotExist { + get { + return ResourceManager.GetString("ArgumentMatrixDoesNotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The matrix indices must not be out of range of the given matrix.. + /// + internal static string ArgumentMatrixIndexOutOfRange { + get { + return ResourceManager.GetString("ArgumentMatrixIndexOutOfRange", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must not be rank deficient.. + /// + internal static string ArgumentMatrixNotRankDeficient { + get { + return ResourceManager.GetString("ArgumentMatrixNotRankDeficient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must not be singular.. + /// + internal static string ArgumentMatrixNotSingular { + get { + return ResourceManager.GetString("ArgumentMatrixNotSingular", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must be positive definite.. + /// + internal static string ArgumentMatrixPositiveDefinite { + get { + return ResourceManager.GetString("ArgumentMatrixPositiveDefinite", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix column dimensions must agree.. + /// + internal static string ArgumentMatrixSameColumnDimension { + get { + return ResourceManager.GetString("ArgumentMatrixSameColumnDimension", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix row dimensions must agree.. + /// + internal static string ArgumentMatrixSameRowDimension { + get { + return ResourceManager.GetString("ArgumentMatrixSameRowDimension", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must have exactly one column.. + /// + internal static string ArgumentMatrixSingleColumn { + get { + return ResourceManager.GetString("ArgumentMatrixSingleColumn", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must have exactly one column and row, thus have only one cell.. + /// + internal static string ArgumentMatrixSingleColumnRow { + get { + return ResourceManager.GetString("ArgumentMatrixSingleColumnRow", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must have exactly one row.. + /// + internal static string ArgumentMatrixSingleRow { + get { + return ResourceManager.GetString("ArgumentMatrixSingleRow", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must be square.. + /// + internal static string ArgumentMatrixSquare { + get { + return ResourceManager.GetString("ArgumentMatrixSquare", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must be symmetric.. + /// + internal static string ArgumentMatrixSymmetric { + get { + return ResourceManager.GetString("ArgumentMatrixSymmetric", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Matrix must be symmetric positive definite.. + /// + internal static string ArgumentMatrixSymmetricPositiveDefinite { + get { + return ResourceManager.GetString("ArgumentMatrixSymmetricPositiveDefinite", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In the specified range, the minimum is greater than maximum.. + /// + internal static string ArgumentMinValueGreaterThanMaxValue { + get { + return ResourceManager.GetString("ArgumentMinValueGreaterThanMaxValue", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must be positive.. + /// + internal static string ArgumentMustBePositive { + get { + return ResourceManager.GetString("ArgumentMustBePositive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must neither be infinite nor NaN.. + /// + internal static string ArgumentNotInfinityNaN { + get { + return ResourceManager.GetString("ArgumentNotInfinityNaN", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must not be negative (zero is ok).. + /// + internal static string ArgumentNotNegative { + get { + return ResourceManager.GetString("ArgumentNotNegative", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} is a null reference (Nothing in Visual Basic).. + /// + internal static string ArgumentNull { + get { + return ResourceManager.GetString("ArgumentNull", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must be odd.. + /// + internal static string ArgumentOdd { + get { + return ResourceManager.GetString("ArgumentOdd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} must be greater than {1}.. + /// + internal static string ArgumentOutOfRangeGreater { + get { + return ResourceManager.GetString("ArgumentOutOfRangeGreater", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} must be greater than or equal to {1}.. + /// + internal static string ArgumentOutOfRangeGreaterEqual { + get { + return ResourceManager.GetString("ArgumentOutOfRangeGreaterEqual", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The chosen parameter set is invalid (probably some value is out of range).. + /// + internal static string ArgumentParameterSetInvalid { + get { + return ResourceManager.GetString("ArgumentParameterSetInvalid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The given expression does not represent a complex number.. + /// + internal static string ArgumentParseComplexNumber { + get { + return ResourceManager.GetString("ArgumentParseComplexNumber", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value must be positive (and not zero).. + /// + internal static string ArgumentPositive { + get { + return ResourceManager.GetString("ArgumentPositive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Size must be a Power of Two.. + /// + internal static string ArgumentPowerOfTwo { + get { + return ResourceManager.GetString("ArgumentPowerOfTwo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Size must be a Power of Two in every dimension.. + /// + internal static string ArgumentPowerOfTwoEveryDimension { + get { + return ResourceManager.GetString("ArgumentPowerOfTwoEveryDimension", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The range between {0} and {1} must be less than or equal to {2}.. + /// + internal static string ArgumentRangeLessEqual { + get { + return ResourceManager.GetString("ArgumentRangeLessEqual", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Arguments must be different objects.. + /// + internal static string ArgumentReferenceDifferent { + get { + return ResourceManager.GetString("ArgumentReferenceDifferent", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Array must have exactly one dimension (and not be null).. + /// + internal static string ArgumentSingleDimensionArray { + get { + return ResourceManager.GetString("ArgumentSingleDimensionArray", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value is too large.. + /// + internal static string ArgumentTooLarge { + get { + return ResourceManager.GetString("ArgumentTooLarge", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Value is too large for the current iteration limit.. + /// + internal static string ArgumentTooLargeForIterationLimit { + get { + return ResourceManager.GetString("ArgumentTooLargeForIterationLimit", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type mismatch.. + /// + internal static string ArgumentTypeMismatch { + get { + return ResourceManager.GetString("ArgumentTypeMismatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Array length must be a multiple of {0}.. + /// + internal static string ArgumentVectorLengthsMultipleOf { + get { + return ResourceManager.GetString("ArgumentVectorLengthsMultipleOf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to All vectors must have the same dimensionality.. + /// + internal static string ArgumentVectorsSameLength { + get { + return ResourceManager.GetString("ArgumentVectorsSameLength", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The vector must have 3 dimensions.. + /// + internal static string ArgumentVectorThreeDimensional { + get { + return ResourceManager.GetString("ArgumentVectorThreeDimensional", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The given array is too small. It must be at least {0} long.. + /// + internal static string ArrayTooSmall { + get { + return ResourceManager.GetString("ArrayTooSmall", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Big endian files are not supported.. + /// + internal static string BigEndianNotSupported { + get { + return ResourceManager.GetString("BigEndianNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The supplied collection is empty.. + /// + internal static string CollectionEmpty { + get { + return ResourceManager.GetString("CollectionEmpty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Complex matrices are not supported.. + /// + internal static string ComplexMatricesNotSupported { + get { + return ResourceManager.GetString("ComplexMatricesNotSupported", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to An algorithm failed to converge.. + /// + internal static string ConvergenceFailed { + get { + return ResourceManager.GetString("ConvergenceFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This feature is not implemented yet (but is planned).. + /// + internal static string FeaturePlannedButNotImplementedYet { + get { + return ResourceManager.GetString("FeaturePlannedButNotImplementedYet", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The given file doesn't exist.. + /// + internal static string FileDoesNotExist { + get { + return ResourceManager.GetString("FileDoesNotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid parameterization for the distribution.. + /// + internal static string InvalidDistributionParameters { + get { + return ResourceManager.GetString("InvalidDistributionParameters", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid Left Boundary Condition.. + /// + internal static string InvalidLeftBoundaryCondition { + get { + return ResourceManager.GetString("InvalidLeftBoundaryCondition", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The operation could not be performed because the accumulator is empty.. + /// + internal static string InvalidOperationAccumulatorEmpty { + get { + return ResourceManager.GetString("InvalidOperationAccumulatorEmpty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The operation could not be performed because the histogram is empty.. + /// + internal static string InvalidOperationHistogramEmpty { + get { + return ResourceManager.GetString("InvalidOperationHistogramEmpty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Not enough points in the distribution.. + /// + internal static string InvalidOperationHistogramNotEnoughPoints { + get { + return ResourceManager.GetString("InvalidOperationHistogramNotEnoughPoints", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No Samples Provided. Preparation Required.. + /// + internal static string InvalidOperationNoSamplesProvided { + get { + return ResourceManager.GetString("InvalidOperationNoSamplesProvided", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid Right Boundary Condition.. + /// + internal static string InvalidRightBoundaryCondition { + get { + return ResourceManager.GetString("InvalidRightBoundaryCondition", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to ddd MMM dd HH:mm:ss yyyy. + /// + internal static string MatlabDateHeaderFormat { + get { + return ResourceManager.GetString("MatlabDateHeaderFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The number of columns of a matrix must be positive.. + /// + internal static string MatrixColumnsMustBePositive { + get { + return ResourceManager.GetString("MatrixColumnsMustBePositive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The number of rows of a matrix must be positive.. + /// + internal static string MatrixRowsMustBePositive { + get { + return ResourceManager.GetString("MatrixRowsMustBePositive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The number of rows or columns of a matrix must be positive.. + /// + internal static string MatrixRowsOrColumnsMustBePositive { + get { + return ResourceManager.GetString("MatrixRowsOrColumnsMustBePositive", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Only 1 and 2 dimensional arrays are supported.. + /// + internal static string MoreThan2D { + get { + return ResourceManager.GetString("MoreThan2D", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Data must contain at least {0} values.. + /// + internal static string MustContainAtLeast { + get { + return ResourceManager.GetString("MustContainAtLeast", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name cannot contain a space. name: {0}. + /// + internal static string NameCannotContainASpace { + get { + return ResourceManager.GetString("NameCannotContainASpace", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} is not a supported type.. + /// + internal static string NotSupportedType { + get { + return ResourceManager.GetString("NotSupportedType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The two arguments can't be compared (maybe they are part of a partial ordering?). + /// + internal static string PartialOrderException { + get { + return ResourceManager.GetString("PartialOrderException", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The integer array does not represent a valid permutation.. + /// + internal static string PermutationAsIntArrayInvalid { + get { + return ResourceManager.GetString("PermutationAsIntArrayInvalid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The sampler's proposal distribution is not upper bounding the target density.. + /// + internal static string ProposalDistributionNoUpperBound { + get { + return ResourceManager.GetString("ProposalDistributionNoUpperBound", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The number of rows must greater than or equal to the number of columns.. + /// + internal static string RowsLessThanColumns { + get { + return ResourceManager.GetString("RowsLessThanColumns", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The singular vectors were not computed.. + /// + internal static string SingularVectorsNotComputed { + get { + return ResourceManager.GetString("SingularVectorsNotComputed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This special case is not supported yet (but is planned).. + /// + internal static string SpecialCasePlannedButNotImplementedYet { + get { + return ResourceManager.GetString("SpecialCasePlannedButNotImplementedYet", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The given stop criterium already exist in the collection.. + /// + internal static string StopCriteriumDuplicate { + get { + return ResourceManager.GetString("StopCriteriumDuplicate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to There is no stop criterium in the collection.. + /// + internal static string StopCriteriumMissing { + get { + return ResourceManager.GetString("StopCriteriumMissing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to String parameter cannot be empty or null.. + /// + internal static string StringNullOrEmpty { + get { + return ResourceManager.GetString("StringNullOrEmpty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to We only support sparse matrix with less than int.MaxValue elements.. + /// + internal static string TooManyElements { + get { + return ResourceManager.GetString("TooManyElements", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The moment of the distribution is undefined.. + /// + internal static string UndefinedMoment { + get { + return ResourceManager.GetString("UndefinedMoment", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A user defined provider has not been specified.. + /// + internal static string UserDefinedProviderNotSpecified { + get { + return ResourceManager.GetString("UserDefinedProviderNotSpecified", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The given work array is too small. Check work[0] for the corret size.. + /// + internal static string WorkArrayTooSmall { + get { + return ResourceManager.GetString("WorkArrayTooSmall", resourceCulture); + } + } + } +} diff --git a/src/Numerics/Threading/CommonParallel.cs b/src/Numerics/Threading/CommonParallel.cs index a84b9c43..954d016e 100644 --- a/src/Numerics/Threading/CommonParallel.cs +++ b/src/Numerics/Threading/CommonParallel.cs @@ -362,7 +362,7 @@ namespace MathNet.Numerics.Threading fromInclusive, toExclusive, () => 0.0, - (i, localData) => localData += body(i, localData), + (i, localData) => localData = body(i, localData), localResult => { lock (syncLock) @@ -415,7 +415,7 @@ namespace MathNet.Numerics.Threading fromInclusive, toExclusive, () => 0.0f, - (i, localData) => localData += body(i, localData), + (i, localData) => localData = body(i, localData), localResult => { lock (syncLock) diff --git a/src/Silverlight/MathNet.Numerics.snk b/src/Silverlight/MathNet.Numerics.snk new file mode 100644 index 00000000..93e42734 Binary files /dev/null and b/src/Silverlight/MathNet.Numerics.snk differ diff --git a/src/Silverlight/Properties/AssemblyInfo.cs b/src/Silverlight/Properties/AssemblyInfo.cs index b1d67625..79443832 100644 --- a/src/Silverlight/Properties/AssemblyInfo.cs +++ b/src/Silverlight/Properties/AssemblyInfo.cs @@ -29,6 +29,7 @@ using System; using System.Reflection; using System.Resources; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Math.NET Numerics for Silverlight")] @@ -42,6 +43,7 @@ using System.Runtime.InteropServices; [assembly: CLSCompliant(true)] [assembly: ComVisible(false)] [assembly: Guid("7b66646f-f0ee-425d-9065-910d1937a2df")] +[assembly: InternalsVisibleTo("SilverlightUnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed2314a577643d859571b8b9307c6ff2670525c4598fbb307e57ea65ebf5d4417284cb3da9181636480b623f4db8cc3c1947244ba069df0df86e2431621f51a488f9929519a1c5d0ae595f6e2d0e4094685f0c1229ff658360acbb9f63f1a0258e984dda00dc7ad4fd16dbb550ec1ef8a11df138402b7c1998ee224e652c839b")] [assembly: NeutralResourcesLanguage("en")] [assembly: AssemblyVersion("2011.04.17.0")] [assembly: AssemblyFileVersion("2011.04.17")] \ No newline at end of file diff --git a/src/Silverlight/Silverlight.csproj b/src/Silverlight/Silverlight.csproj index 40188081..d7f1adb0 100644 --- a/src/Silverlight/Silverlight.csproj +++ b/src/Silverlight/Silverlight.csproj @@ -61,6 +61,12 @@ 4 ..\..\out\lib\SL4\MathNet.Numerics.xml + + true + + + MathNet.Numerics.snk + @@ -186,6 +192,9 @@ Distributions\Discrete\NegativeBinomial.cs + + Distributions\Discrete\Poisson.cs + Distributions\Continuous\Zipf.cs @@ -915,6 +924,9 @@ NumberTheory\IntegerTheory.cs + + NumberTheory\IntegerTheory.Euclid.Big.cs + NumberTheory\IntegerTheory.Euclid.cs @@ -924,8 +936,11 @@ Precision.cs - - Resources.Designer.cs + + Properties\Resources1.Designer.cs + True + True + Resources.resx Random\AbstractRandomNumberGenerator.cs @@ -1037,7 +1052,9 @@ - Resources.resx + Properties\Resources.resx + Resources1.Designer.cs + ResXFileCodeGenerator @@ -1055,6 +1072,9 @@ false + + + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs index 6144be72..2ba00918 100644 --- a/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/Properties/AssemblyInfo.cs @@ -1,6 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Resources; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information @@ -33,3 +34,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en")] diff --git a/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj index 29e6a93c..c999f887 100644 --- a/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj +++ b/src/SilverlightUnitTests/SilverlightUnitTests.Web/SilverlightUnitTests.Web.csproj @@ -51,8 +51,14 @@ + + + + + + diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/MathNet.Numerics.snk b/src/SilverlightUnitTests/SilverlightUnitTests/MathNet.Numerics.snk new file mode 100644 index 00000000..93e42734 Binary files /dev/null and b/src/SilverlightUnitTests/SilverlightUnitTests/MathNet.Numerics.snk differ diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs b/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs index 88ba8272..92c8f824 100644 --- a/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs +++ b/src/SilverlightUnitTests/SilverlightUnitTests/Properties/AssemblyInfo.cs @@ -3,6 +3,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Resources; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information @@ -34,4 +35,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en")] diff --git a/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj b/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj index 3a680ded..0910d7a3 100644 --- a/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj +++ b/src/SilverlightUnitTests/SilverlightUnitTests/SilverlightUnitTests.csproj @@ -87,16 +87,20 @@ prompt 4 + + true + + + MathNet.Numerics.snk + ..\..\..\out\debug\SL4\MathNet.Numerics.dll + False $(MSBuildExtensionsPath)\..\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Testing\Microsoft.Silverlight.Testing.dll - - $(MSBuildExtensionsPath)\..\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Testing\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll - ..\..\..\lib\NUnit.Silverlight.2.5.8\NUnit.Silverlight.Compatibility.dll @@ -107,15 +111,30 @@ ..\..\..\lib\NUnit.Silverlight.2.5.8\NUnit.Silverlight.Metadata.dll - + + True + - - - - - + + True + + + True + + + True + + + True + + + True + + + ArrayHelpers.cs + AssertHelpers.cs @@ -929,9 +948,9 @@ + - False @@ -944,6 +963,9 @@ false + + + diff --git a/src/UnitTests/ArrayHelpers.cs b/src/UnitTests/ArrayHelpers.cs new file mode 100644 index 00000000..0791a05b --- /dev/null +++ b/src/UnitTests/ArrayHelpers.cs @@ -0,0 +1,75 @@ +// +// Math.NET Numerics, part of the Math.NET Project +// http://numerics.mathdotnet.com +// http://github.com/mathnet/mathnet-numerics +// http://mathnetnumerics.codeplex.com +// Copyright (c) 2009-2010 Math.NET +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +namespace MathNet.Numerics.UnitTests +{ + using System; + using System.Collections.Generic; + using System.Linq; + + /// + /// Array and List helper/extention for Silverlight + /// + internal static class ArrayHelpers + { + /// + /// Converts an array of one type to an array of another type. + /// + /// The type of the elements of the source array. + /// The type of the elements of the target array. + /// The one-dimensional, zero-based Array to convert to a target type. + /// A Converter that converts each element from one type to another type. + /// An array of the target type containing the converted elements from the source array. + public static TOutput[] ConvertAll(TInput[] array, Converter converter) + { +#if SILVERLIGHT + if (array == null) + throw new ArgumentException(); + + return (from item in array select converter(item)).ToArray(); +#else + return Array.ConvertAll(array, converter); +#endif + } + +#if SILVERLIGHT + /// + /// Determines whether the specified array contains elements that match the conditions defined by the specified predicate. + /// + /// The type of the elements of the array. + /// The one-dimensional, zero-based Array to search. + /// The Predicate<> that defines the conditions of the elements to search for. + /// true if array contains one or more elements that match the conditions defined by the specified predicate; otherwise, false. + public static bool Exists(this List list, Predicate match) + { + if (list == null) + throw new ArgumentException(); + + return list.Any(item => match(item)); + } +#endif + } +} diff --git a/src/UnitTests/AssertHelpers.cs b/src/UnitTests/AssertHelpers.cs index e0bb7393..55915b79 100644 --- a/src/UnitTests/AssertHelpers.cs +++ b/src/UnitTests/AssertHelpers.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs b/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs index 82956864..e6fd7d03 100644 --- a/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs +++ b/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,12 +40,19 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// N parameter. /// K parameter. /// Expected value. - [Test, Sequential] - public void CanCountVariations([Values(0, 1, 10, 10, 10, 10, 10, 10)] int n, [Values(0, 0, 0, 2, 4, 6, 9, 10)] int k, [Values(1, 1, 1, 90, 5040, 151200, 3628800, 3628800)] long expected) + [TestCase(0, 0, 1)] + [TestCase(1, 0, 1)] + [TestCase(10, 0, 1)] + [TestCase(10, 2, 90)] + [TestCase(10, 4, 5040)] + [TestCase(10, 6, 151200)] + [TestCase(10, 9, 3628800)] + [TestCase(10, 10, 3628800)] + public void CanCountVariations(int n, int k, long expected) { Assert.AreEqual( - expected, - Combinatorics.Variations(n, k), + expected, + Combinatorics.Variations(n, k), "Count the number of variations without repetition"); } @@ -54,12 +61,17 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// /// N parameter. /// K parameter. - [Test, Sequential] - public void OutOfRangeVariationsCountToZero([Values(0, 10, 0, 1, -1, -1)] int n, [Values(1, 11, -1, -1, 0, 1)] int k) + [TestCase(0, 1)] + [TestCase(10, 11)] + [TestCase(0, -1)] + [TestCase(1, -1)] + [TestCase(-1, 0)] + [TestCase(-1, 1)] + public void OutOfRangeVariationsCountToZero(int n, int k) { Assert.AreEqual( - 0, - Combinatorics.Variations(n, k), + 0, + Combinatorics.Variations(n, k), "The number of variations without repetition but out of the range must be 0."); } @@ -69,12 +81,20 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// N parameter. /// K parameter. /// Expected value. - [Test, Sequential] - public void CanCountVariationsWithRepetition([Values(0, 1, 10, 10, 10, 10, 10, 10, 10)] int n, [Values(0, 0, 0, 2, 4, 6, 9, 10, 11)] int k, [Values(1, 1, 1, 100, 10000, 1000000, 1000000000, 10000000000, 100000000000)] long expected) + [TestCase(0, 0, 1)] + [TestCase(1, 0, 1)] + [TestCase(10, 0, 1)] + [TestCase(10, 2, 100)] + [TestCase(10, 4, 10000)] + [TestCase(10, 6, 1000000)] + [TestCase(10, 9, 1000000000)] + [TestCase(10, 10, 10000000000)] + [TestCase(10, 11, 100000000000)] + public void CanCountVariationsWithRepetition(int n, int k, long expected) { Assert.AreEqual( - expected, - Combinatorics.VariationsWithRepetition(n, k), + expected, + Combinatorics.VariationsWithRepetition(n, k), "Count the number of variations with repetition"); } @@ -83,12 +103,16 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// /// N parameter. /// K parameter. - [Test, Sequential] - public void OutOfRangeVariationsWithRepetitionCountToZero([Values(0, 0, 1, -1, -1)] int n, [Values(1, -1, -1, 0, 1)] int k) + [TestCase(0, 1)] + [TestCase(0, -1)] + [TestCase(1, -1)] + [TestCase(-1, 0)] + [TestCase(-1, 1)] + public void OutOfRangeVariationsWithRepetitionCountToZero(int n, int k) { Assert.AreEqual( - 0, - Combinatorics.VariationsWithRepetition(n, k), + 0, + Combinatorics.VariationsWithRepetition(n, k), "The number of variations with repetition but out of the range must be 0."); } @@ -98,12 +122,19 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// N parameter. /// K parameter. /// Expected value. - [Test, Sequential] - public void CanCountCombinations([Values(0, 1, 10, 10, 10, 10, 10, 10)] int n, [Values(0, 0, 0, 2, 4, 6, 9, 10)] int k, [Values(1, 1, 1, 45, 210, 210, 10, 1)] long expected) + [TestCase(0, 0, 1)] + [TestCase(1, 0, 1)] + [TestCase(10, 0, 1)] + [TestCase(10, 2, 45)] + [TestCase(10, 4, 210)] + [TestCase(10, 6, 210)] + [TestCase(10, 9, 10)] + [TestCase(10, 10, 1)] + public void CanCountCombinations(int n, int k, long expected) { Assert.AreEqual( - expected, - Combinatorics.Combinations(n, k), + expected, + Combinatorics.Combinations(n, k), "Count the number of combinations without repetition"); } @@ -112,12 +143,17 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// /// N parameter. /// K parameter. - [Test, Sequential] - public void OutOfRangeCombinationsCountToZero([Values(0, 10, 0, 1, -1, -1)] int n, [Values(1, 11, -1, -1, 0, 1)] int k) + [TestCase(0, 1)] + [TestCase(10, 11)] + [TestCase(0, -1)] + [TestCase(1, -1)] + [TestCase(-1, 0)] + [TestCase(-1, 1)] + public void OutOfRangeCombinationsCountToZero(int n, int k) { Assert.AreEqual( - 0, - Combinatorics.Combinations(n, k), + 0, + Combinatorics.Combinations(n, k), "The number of combinations without repetition but out of the range must be 0."); } @@ -127,12 +163,20 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// N parameter. /// K parameter. /// Expected value. - [Test, Sequential] - public void CanCountCombinationsWithRepetition([Values(0, 1, 10, 10, 10, 10, 10, 10, 10)] int n, [Values(0, 0, 0, 2, 4, 6, 9, 10, 11)] int k, [Values(1, 1, 1, 55, 715, 5005, 48620, 92378, 167960)] long expected) + [TestCase(0, 0, 1)] + [TestCase(1, 0, 1)] + [TestCase(10, 0, 1)] + [TestCase(10, 2, 55)] + [TestCase(10, 4, 715)] + [TestCase(10, 6, 5005)] + [TestCase(10, 9, 48620)] + [TestCase(10, 10, 92378)] + [TestCase(10, 11, 167960)] + public void CanCountCombinationsWithRepetition(int n, int k, long expected) { Assert.AreEqual( - expected, - Combinatorics.CombinationsWithRepetition(n, k), + expected, + Combinatorics.CombinationsWithRepetition(n, k), "Count the number of combinations with repetition"); } @@ -141,12 +185,16 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// /// N parameter. /// K parameter. - [Test, Sequential] - public void OutOfRangeCombinationsWithRepetitionCountToZero([Values(0, 0, 1, -1, -1)] int n, [Values(1, -1, -1, 0, 1)] int k) + [TestCase(0, 1)] + [TestCase(0, -1)] + [TestCase(1, -1)] + [TestCase(-1, 0)] + [TestCase(-1, 1)] + public void OutOfRangeCombinationsWithRepetitionCountToZero(int n, int k) { Assert.AreEqual( - 0, - Combinatorics.CombinationsWithRepetition(n, k), + 0, + Combinatorics.CombinationsWithRepetition(n, k), "The number of combinations with repetition but out of the range must be 0."); } @@ -155,12 +203,16 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests /// /// N parameter. /// Expected value. - [Test, Sequential] - public void CanCountPermutations([Values(0, 1, 2, 8, 15)] int n, [Values(1, 1, 2, 40320, 1307674368000)] long expected) + [TestCase(0, 1)] + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(8, 40320)] + [TestCase(15, 1307674368000)] + public void CanCountPermutations(int n, long expected) { Assert.AreEqual( - expected, - Combinatorics.Permutations(n), + expected, + Combinatorics.Permutations(n), "Count the number of permutations"); } } diff --git a/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs b/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs index 95eb7d65..ad808acd 100644 --- a/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs +++ b/src/UnitTests/ComplexTests/Complex32Test.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,23 +42,35 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Real part. /// Imaginary part. /// Expected value. - [Test, Sequential] - public void CanFormatComplexToString( - [Values(1, 1, 1, 0, 0, 0, Single.NaN, Single.NaN, 0, Single.PositiveInfinity, 1.1f, -1.1f, 0, 0, 1.1f)] float real, - [Values(-2, 2, 0, -2, 2, 0, Single.NaN, 0, Single.NaN, Single.PositiveInfinity, 0, 0, 1.1f, -1.1f, 1.1f)] float imag, - [Values("(1, -2)", "(1, 2)", "(1, 0)", "(0, -2)", "(0, 2)", "(0, 0)", "({1}, {1})", "({1}, 0)", "(0, {1})", "({2}, {2})", "(1{0}1, 0)", "(-1{0}1, 0)", "(0, 1{0}1)", "(0, -1{0}1)", "(1{0}1, 1{0}1)")] string expected) + [TestCase(1, -2, "(1, -2)")] + [TestCase(1, 2, "(1, 2)")] + [TestCase(1, 0, "(1, 0)")] + [TestCase(0, -2, "(0, -2)")] + [TestCase(0, 2, "(0, 2)")] + [TestCase(0, 0, "(0, 0)")] + [TestCase(Single.NaN, Single.NaN, "({1}, {1})")] + [TestCase(Single.NaN, 0, "({1}, 0)")] + [TestCase(0, Single.NaN, "(0, {1})")] + [TestCase(Single.PositiveInfinity, Single.PositiveInfinity, "({2}, {2})")] + [TestCase(1.1f, 0, "(1{0}1, 0)")] + [TestCase(-1.1f, 0, "(-1{0}1, 0)")] + [TestCase(0, 1.1f, "(0, 1{0}1)")] + [TestCase(0, -1.1f, "(0, -1{0}1)")] + [TestCase(1.1f, 1.1f, "(1{0}1, 1{0}1)")] + public void CanFormatComplexToString(float real, float imag, string expected) { var numberFormat = NumberFormatInfo.CurrentInfo; var a = new Complex32(real, imag); Assert.AreEqual( String.Format( - expected, - numberFormat.NumberDecimalSeparator, - numberFormat.NaNSymbol, - numberFormat.PositiveInfinitySymbol), + expected, + numberFormat.NumberDecimalSeparator, + numberFormat.NaNSymbol, + numberFormat.PositiveInfinitySymbol), a.ToString()); } +#if !SILVERLIGHT /// /// Can format complex to string with culture. /// @@ -66,14 +78,14 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Not a number name. /// Infinity name. /// Complex Number. - [Test, Sequential] - public void CanFormatComplexToStringWithCulture( - [Values("en-US", "tr-TR", "de-DE", "de-CH", "he-IL")] string cultureName, - [Values("NaN", "NaN", "n. def.", "n. def.", "לא מספר")] string nan, - [Values("Infinity", "Infinity", "+unendlich", "+unendlich", "אינסוף חיובי")] string infinity, - [Values("1.1", "1,1", "1,1", "1.1", "1.1")] string number) + [TestCase("en-US", "NaN", "Infinity", "1.1")] + [TestCase("tr-TR", "NaN", "Infinity", "1,1")] + [TestCase("de-DE", "n. def.", "+unendlich", "1,1")] + [TestCase("de-CH", "n. def.", "+unendlich", "1.1")] + [TestCase("he-IL", "לא מספר", "אינסוף חיובי", "1.1")] + public void CanFormatComplexToStringWithCulture(string cultureName, string nan, string infinity, string number) { - var provider = CultureInfo.GetCultureInfo(cultureName); + var provider = new CultureInfo(cultureName); Assert.AreEqual("(" + nan + ", " + nan + ")", Complex32.NaN.ToString(provider)); Assert.AreEqual("(" + infinity + ", " + infinity + ")", Complex32.Infinity.ToString(provider)); Assert.AreEqual("(0, 0)", Complex32.Zero.ToString(provider)); @@ -83,6 +95,7 @@ namespace MathNet.Numerics.UnitTests.ComplexTests Assert.AreEqual("(0, " + String.Format("{0}", number) + ")", new Complex32(0.0f, 1.1f).ToString(provider)); Assert.AreEqual("(" + String.Format("{0}", number) + ", " + String.Format("{0}", number) + ")", new Complex32(1.1f, 1.1f).ToString(provider)); } +#endif /// /// Can format complex to string with format. @@ -132,14 +145,11 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Expected real part. /// Expected imaginary part. /// Culture ID. - [Test, Sequential] - public void CanParseStringToComplexWithCulture( - [Values("-1 -2i", "-1 - 2i ")] string text, - [Values(-1, -1)] float expectedReal, - [Values(-2, -2)] float expectedImaginary, - [Values("en-US", "de-CH")] string cultureName) + [TestCase("-1 -2i", -1, -2, "en-US")] + [TestCase("-1 - 2i ", -1, -2, "de-CH")] + public void CanParseStringToComplexWithCulture(string text, float expectedReal, float expectedImaginary, string cultureName) { - var parsed = Complex32.Parse(text, CultureInfo.GetCultureInfo(cultureName)); + var parsed = Complex32.Parse(text, new CultureInfo(cultureName)); Assert.AreEqual(expectedReal, parsed.Real); Assert.AreEqual(expectedImaginary, parsed.Imaginary); } @@ -150,11 +160,35 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// String to parse. /// Expected real part. /// Expected imaginary part. - [Test, Sequential] - public void CanTryParseStringToComplexWithInvariant( - [Values("1", "-1", "-i", "i", "2i", "1 + 2i", "1+2i", "1 - 2i", "1-2i", "1,2 ", "1 , 2", "1,2i", "-1, -2i", " - 1 , - 2 i ", "(+1,2i)", "(-1 , -2)", "(-1 , -2i)", "(+1e1 , -2e-2i)", "(-1E1 -2e2i)", "(-1e+1 -2e2i)", "(-1e1 -2e+2i)", "(-1e-1 -2E2i)", "(-1e1 -2e-2i)", "(-1E+1 -2e+2i)", "(-1e-1,-2e-2i)", "(+1 +2i)", "(-1E+1 -2e+2i)", "(-1e-1,-2e-2i)")] string str, - [Values(1, -1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 10, -10, -10, -10, -0.1f, -10, -10, -0.1f, 1, -10, -0.1f)] float expectedReal, - [Values(0, 0, -1, 1, 2, 2, 2, -2, -2, 2, 2, 2, -2, -2, 2, -2, -2, -0.02f, -200, -200, -200, -200, -0.02f, -200, -0.02f, 2, -200, -0.02f)] float expectedImaginary) + [TestCase("1", 1, 0)] + [TestCase("-1", -1, 0)] + [TestCase("-i", 0, -1)] + [TestCase("i", 0, 1)] + [TestCase("2i", 0, 2)] + [TestCase("1 + 2i", 1, 2)] + [TestCase("1+2i", 1, 2)] + [TestCase("1 - 2i", 1, -2)] + [TestCase("1-2i", 1, -2)] + [TestCase("1,2 ", 1, 2)] + [TestCase("1 , 2", 1, 2)] + [TestCase("1,2i", 1, 2)] + [TestCase("-1, -2i", -1, -2)] + [TestCase(" - 1 , - 2 i ", -1, -2)] + [TestCase("(+1,2i)", 1, 2)] + [TestCase("(-1 , -2)", -1, -2)] + [TestCase("(-1 , -2i)", -1, -2)] + [TestCase("(+1e1 , -2e-2i)", 10, -0.02f)] + [TestCase("(-1E1 -2e2i)", -10, -200)] + [TestCase("(-1e+1 -2e2i)", -10, -200)] + [TestCase("(-1e1 -2e+2i)", -10, -200)] + [TestCase("(-1e-1 -2E2i)", -0.1f, -200)] + [TestCase("(-1e1 -2e-2i)", -10, -0.02f)] + [TestCase("(-1E+1 -2e+2i)", -10, -200)] + [TestCase("(-1e-1,-2e-2i)", -0.1f, -0.02f)] + [TestCase("(+1 +2i)", 1, 2)] + [TestCase("(-1E+1 -2e+2i)", -10, -200)] + [TestCase("(-1e-1,-2e-2i)", -0.1f, -0.02f)] + public void CanTryParseStringToComplexWithInvariant(string str, float expectedReal, float expectedImaginary) { var invariantCulture = CultureInfo.InvariantCulture; Complex32 z; @@ -204,22 +238,27 @@ namespace MathNet.Numerics.UnitTests.ComplexTests Assert.AreEqual(float.NaN, z.Imaginary, "D3"); ret = Complex32.TryParse( - float.MaxValue.ToString("R") + " " + float.MinValue.ToString("R") + "i", + float.MaxValue.ToString("R") + " " + float.MinValue.ToString("R") + "i", out z); Assert.IsTrue(ret, "E1"); Assert.AreEqual(float.MaxValue, z.Real, "E2"); Assert.AreEqual(float.MinValue, z.Imaginary, "E3"); } +#if !SILVERLIGHT /// /// Try parse can handle symbols with a culture. /// /// Culture ID. - [Test] - public void TryParseCanHandleSymbolsWithCulture([Values("en-US", "tr-TR", "de-DE", "de-CH", "he-IL")] string cultureName) + [TestCase("en-US")] + [TestCase("tr-TR")] + [TestCase("de-DE")] + [TestCase("de-CH")] + [TestCase("he-IL")] + public void TryParseCanHandleSymbolsWithCulture(string cultureName) { Complex32 z; - var culture = CultureInfo.GetCultureInfo(cultureName); + var culture = new CultureInfo(cultureName); var ni = culture.NumberFormat; var separator = culture.TextInfo.ListSeparator; var ret = Complex32.TryParse( @@ -244,20 +283,35 @@ namespace MathNet.Numerics.UnitTests.ComplexTests Assert.AreEqual(float.NaN, z.Imaginary, "D3"); ret = Complex32.TryParse( - float.MaxValue.ToString("R", culture) + " " + float.MinValue.ToString("R", culture) + "i", - culture, + float.MaxValue.ToString("R", culture) + " " + float.MinValue.ToString("R", culture) + "i", + culture, out z); Assert.IsTrue(ret, "E1"); Assert.AreEqual(float.MaxValue, z.Real, "E2"); Assert.AreEqual(float.MinValue, z.Imaginary, "E3"); } +#endif /// /// Try parse returns false when given bad value with invariant. /// /// String to parse. - [Test] - public void TryParseReturnsFalseWhenGivenBadValueWithInvariant([Values("", "+", "1-", "i+", "1/2i", "1i+2i", "i1i", "(1i,2)", "1e+", "1e", "1,", ",1", null, "()", "( )")] string str) + [TestCase("")] + [TestCase("+")] + [TestCase("1-")] + [TestCase("i+")] + [TestCase("1/2i")] + [TestCase("1i+2i")] + [TestCase("i1i")] + [TestCase("(1i,2)")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase(null)] + [TestCase("()")] + [TestCase("( )")] + public void TryParseReturnsFalseWhenGivenBadValueWithInvariant(string str) { Complex32 z; var ret = Complex32.TryParse(str, CultureInfo.InvariantCulture, out z); diff --git a/src/UnitTests/ComplexTests/Complex32Test.cs b/src/UnitTests/ComplexTests/Complex32Test.cs index 96520226..09ce3097 100644 --- a/src/UnitTests/ComplexTests/Complex32Test.cs +++ b/src/UnitTests/ComplexTests/Complex32Test.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -127,8 +127,12 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Imaginary part. /// Expected real part. /// Expected imaginary part. - [Test, Sequential] - public void CanComputeNaturalLogarithm([Values(0.0f, 0.0f, -1.0f, -111.1f, 111.1f)] float real, [Values(0.0f, 1.0f, 1.0f, 111.1f, -111.1f)] float imag, [Values(float.NegativeInfinity, 0.0f, 0.34657359027997264f, 5.0570042869255571f, 5.0570042869255571f)] float expectedReal, [Values(0.0f, 1.5707963267948966f, 2.3561944901923448f, 2.3561944901923448f, -0.78539816339744828f)] float expectedImag) + [TestCase(0.0f, 0.0f, float.NegativeInfinity, 0.0f)] + [TestCase(0.0f, 1.0f, 0.0f, 1.5707963267948966f)] + [TestCase(-1.0f, 1.0f, 0.34657359027997264f, 2.3561944901923448f)] + [TestCase(-111.1f, 111.1f, 5.0570042869255571f, 2.3561944901923448f)] + [TestCase(111.1f, -111.1f, 5.0570042869255571f, -0.78539816339744828f)] + public void CanComputeNaturalLogarithm(float real, float imag, float expectedReal, float expectedImag) { var value = new Complex32(real, imag); var expected = new Complex32(expectedReal, expectedImag); @@ -548,8 +552,11 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Real part. /// Imaginary part. /// Expected value. - [Test, Sequential] - public void CanComputeMagnitude([Values(0.0f, 0.0f, -1.0f, -111.1f)] float real, [Values(0.0f, 1.0f, 1.0f, 111.1f)] float imag, [Values(0.0f, 1.0f, 1.4142135623730951f, 157.11912677965086f)] float expected) + [TestCase(0.0f, 0.0f, 0.0f)] + [TestCase(0.0f, 1.0f, 1.0f)] + [TestCase(-1.0f, 1.0f, 1.4142135623730951f)] + [TestCase(-111.1f, 111.1f, 157.11912677965086f)] + public void CanComputeMagnitude(float real, float imag, float expected) { Assert.AreEqual(expected, new Complex32(real, imag).Magnitude); } @@ -561,8 +568,14 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Imaginary part. /// Expected real value. /// Expected imaginary value. - [Test, Sequential] - public void CanComputeSign([Values(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity, 0.0f, -1.0f, -111.1f)] float real, [Values(float.PositiveInfinity, float.NegativeInfinity, float.PositiveInfinity, float.NegativeInfinity, 0.0f, 1.0f, 111.1f)] float imag, [Values((float)Constants.Sqrt1Over2, (float)Constants.Sqrt1Over2, (float)-Constants.Sqrt1Over2, (float)-Constants.Sqrt1Over2, 0.0f, -0.70710678118654746f, -0.70710678118654746f)] float expectedReal, [Values((float)Constants.Sqrt1Over2, (float)-Constants.Sqrt1Over2, (float)-Constants.Sqrt1Over2, (float)Constants.Sqrt1Over2, 0.0f, 0.70710678118654746f, 0.70710678118654746f)] float expectedImag) + [TestCase(float.PositiveInfinity, float.PositiveInfinity, (float)Constants.Sqrt1Over2, (float)Constants.Sqrt1Over2)] + [TestCase(float.PositiveInfinity, float.NegativeInfinity, (float)Constants.Sqrt1Over2, (float)-Constants.Sqrt1Over2)] + [TestCase(float.NegativeInfinity, float.PositiveInfinity, (float)-Constants.Sqrt1Over2, (float)-Constants.Sqrt1Over2)] + [TestCase(float.NegativeInfinity, float.NegativeInfinity, (float)-Constants.Sqrt1Over2, (float)Constants.Sqrt1Over2)] + [TestCase(0.0f, 0.0f, 0.0f, 0.0f)] + [TestCase(-1.0f, 1.0f, -0.70710678118654746f, 0.70710678118654746f)] + [TestCase(-111.1f, 111.1f, -0.70710678118654746f, 0.70710678118654746f)] + public void CanComputeSign(float real, float imag, float expectedReal, float expectedImag) { Assert.AreEqual(new Complex32(expectedReal, expectedImag), new Complex32(real, imag).Sign); } diff --git a/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs b/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs index e5e962f2..fa46690e 100644 --- a/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs +++ b/src/UnitTests/ComplexTests/ComplexTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -44,14 +44,11 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Expected real part. /// Expected imaginary part. /// Culture ID. - [Test, Sequential] - public void CanParseStringToComplexWithCulture( - [Values("-1 -2i", "-1 - 2i ")] string text, - [Values(-1, -1)] double expectedReal, - [Values(-2, -2)] double expectedImaginary, - [Values("en-US", "de-CH")] string cultureName) + [TestCase("-1 -2i", -1, -2, "en-US")] + [TestCase("-1 - 2i ", -1, -2, "de-CH")] + public void CanParseStringToComplexWithCulture(string text, double expectedReal, double expectedImaginary, string cultureName) { - var parsed = text.ToComplex(CultureInfo.GetCultureInfo(cultureName)); + var parsed = text.ToComplex(new CultureInfo(cultureName)); Assert.AreEqual(expectedReal, parsed.Real); Assert.AreEqual(expectedImaginary, parsed.Imaginary); } @@ -62,11 +59,35 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// String to parse. /// Expected real part. /// Expected imaginary part. - [Test, Sequential] - public void CanTryParseStringToComplexWithInvariant( - [Values("1", "-1", "-i", "i", "2i", "1 + 2i", "1+2i", "1 - 2i", "1-2i", "1,2 ", "1 , 2", "1,2i", "-1, -2i", " - 1 , - 2 i ", "(+1,2i)", "(-1 , -2)", "(-1 , -2i)", "(+1e1 , -2e-2i)", "(-1E1 -2e2i)", "(-1e+1 -2e2i)", "(-1e1 -2e+2i)", "(-1e-1 -2E2i)", "(-1e1 -2e-2i)", "(-1E+1 -2e+2i)", "(-1e-1,-2e-2i)", "(+1 +2i)", "(-1E+1 -2e+2i)", "(-1e-1,-2e-2i)")] string str, - [Values(1, -1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 10, -10, -10, -10, -0.1, -10, -10, -0.1, 1, -10, -0.1)] double expectedReal, - [Values(0, 0, -1, 1, 2, 2, 2, -2, -2, 2, 2, 2, -2, -2, 2, -2, -2, -0.02, -200, -200, -200, -200, -0.02, -200, -0.02, 2, -200, -0.02)] double expectedImaginary) + [TestCase("1", 1, 0)] + [TestCase("-1", -1, 0)] + [TestCase("-i", 0, -1)] + [TestCase("i", 0, 1)] + [TestCase("2i", 0, 2)] + [TestCase("1 + 2i", 1, 2)] + [TestCase("1+2i", 1, 2)] + [TestCase("1 - 2i", 1, -2)] + [TestCase("1-2i", 1, -2)] + [TestCase("1,2 ", 1, 2)] + [TestCase("1 , 2", 1, 2)] + [TestCase("1,2i", 1, 2)] + [TestCase("-1, -2i", -1, -2)] + [TestCase(" - 1 , - 2 i ", -1, -2)] + [TestCase("(+1,2i)", 1, 2)] + [TestCase("(-1 , -2)", -1, -2)] + [TestCase("(-1 , -2i)", -1, -2)] + [TestCase("(+1e1 , -2e-2i)", 10, -0.02)] + [TestCase("(-1E1 -2e2i)", -10, -200)] + [TestCase("(-1e+1 -2e2i)", -10, -200)] + [TestCase("(-1e1 -2e+2i)", -10, -200)] + [TestCase("(-1e-1 -2E2i)", -0.1, -200)] + [TestCase("(-1e1 -2e-2i)", -10, -0.02)] + [TestCase("(-1E+1 -2e+2i)", -10, -200)] + [TestCase("(-1e-1,-2e-2i)", -0.1, -0.02)] + [TestCase("(+1 +2i)", 1, 2)] + [TestCase("(-1E+1 -2e+2i)", -10, -200)] + [TestCase("(-1e-1,-2e-2i)", -0.1, -0.02)] + public void CanTryParseStringToComplexWithInvariant(string str, double expectedReal, double expectedImaginary) { var invariantCulture = CultureInfo.InvariantCulture; Complex z; @@ -126,15 +147,20 @@ namespace MathNet.Numerics.UnitTests.ComplexTests Assert.AreEqual(double.MinValue, z.Imaginary, "E3"); } +#if !SILVERLIGHT /// /// Try parse can handle symbols with a culture. /// /// Culture ID. - [Test] - public void TryParseCanHandleSymbolsWithCulture([Values("en-US", "tr-TR", "de-DE", "de-CH", "he-IL")] string cultureName) + [TestCase("en-US")] + [TestCase("tr-TR")] + [TestCase("de-DE")] + [TestCase("de-CH")] + [TestCase("he-IL")] + public void TryParseCanHandleSymbolsWithCulture(string cultureName) { Complex z; - var culture = CultureInfo.GetCultureInfo(cultureName); + var culture = new CultureInfo(cultureName); var ni = culture.NumberFormat; var separator = culture.TextInfo.ListSeparator; @@ -168,13 +194,28 @@ namespace MathNet.Numerics.UnitTests.ComplexTests Assert.AreEqual(double.MaxValue, z.Real, "E2"); Assert.AreEqual(double.MinValue, z.Imaginary, "E3"); } +#endif /// /// Try parse returns false when given bad value with invariant. /// /// String to parse. - [Test] - public void TryParseReturnsFalseWhenGivenBadValueWithInvariant([Values("", "+", "1-", "i+", "1/2i", "1i+2i", "i1i", "(1i,2)", "1e+", "1e", "1,", ",1", null, "()", "( )")] string str) + [TestCase("")] + [TestCase("+")] + [TestCase("1-")] + [TestCase("i+")] + [TestCase("1/2i")] + [TestCase("1i+2i")] + [TestCase("i1i")] + [TestCase("(1i,2)")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase(null)] + [TestCase("()")] + [TestCase("( )")] + public void TryParseReturnsFalseWhenGivenBadValueWithInvariant(string str) { Complex z; var ret = str.TryToComplex(CultureInfo.InvariantCulture, out z); diff --git a/src/UnitTests/ComplexTests/ComplexTest.cs b/src/UnitTests/ComplexTests/ComplexTest.cs index f48a6845..862f88b2 100644 --- a/src/UnitTests/ComplexTests/ComplexTest.cs +++ b/src/UnitTests/ComplexTests/ComplexTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,11 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Imaginary part. /// Expected real part. /// Expected imaginary part. - [Test, Sequential] - public void CanComputeExponential([Values(0.0, 0.0, -1.0, -111.1)] double real, [Values(0.0, 1.0, 1.0, 111.1)] double imag, [Values(1.0, 0.54030230586813977, 0.19876611034641295, -2.3259065941590448e-49)] double expectedReal, [Values(0.0, 0.8414709848078965, 0.30955987565311222, -5.1181940185795617e-49)] double expectedImag) + [TestCase(0.0, 0.0, 1.0, 0.0)] + [TestCase(0.0, 1.0, 0.54030230586813977, 0.8414709848078965)] + [TestCase(-1.0, 1.0, 0.19876611034641295, 0.30955987565311222)] + [TestCase(-111.1, 111.1, -2.3259065941590448e-49, -5.1181940185795617e-49)] + public void CanComputeExponential(double real, double imag, double expectedReal, double expectedImag) { var value = new Complex(real, imag); var expected = new Complex(expectedReal, expectedImag); @@ -57,8 +60,12 @@ namespace MathNet.Numerics.UnitTests.ComplexTests /// Imaginary part. /// Expected real part. /// Expected imaginary part. - [Test, Sequential] - public void CanComputeNaturalLogarithm([Values(0.0, 0.0, -1.0, -111.1, 111.1)] double real, [Values(0.0, 1.0, 1.0, 111.1, -111.1)] double imag, [Values(double.NegativeInfinity, 0.0, 0.34657359027997264, 5.0570042869255571, 5.0570042869255571)] double expectedReal, [Values(0.0, 1.5707963267948966, 2.3561944901923448, 2.3561944901923448, -0.78539816339744828)] double expectedImag) + [TestCase(0.0, 0.0, double.NegativeInfinity, 0.0)] + [TestCase(0.0, 1.0, 0.0, 1.5707963267948966)] + [TestCase(-1.0, 1.0, 0.34657359027997264, 2.3561944901923448)] + [TestCase(-111.1, 111.1, 5.0570042869255571, 2.3561944901923448)] + [TestCase(111.1, -111.1, 5.0570042869255571, -0.78539816339744828)] + public void CanComputeNaturalLogarithm(double real, double imag, double expectedReal, double expectedImag) { var value = new Complex(real, imag); var expected = new Complex(expectedReal, expectedImag); diff --git a/src/UnitTests/DistributionTests/CommonDistributionTests.cs b/src/UnitTests/DistributionTests/CommonDistributionTests.cs index 85aaa210..01b2ba96 100644 --- a/src/UnitTests/DistributionTests/CommonDistributionTests.cs +++ b/src/UnitTests/DistributionTests/CommonDistributionTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -106,20 +106,20 @@ namespace MathNet.Numerics.UnitTests.DistributionTests { _discreteDistributions = new List { - new Bernoulli(0.6), - new Binomial(0.7, 10), - new Categorical(new[] { 0.7, 0.3 }), + new Bernoulli(0.6), + new Binomial(0.7, 10), + new Categorical(new[] { 0.7, 0.3 }), new DiscreteUniform(1, 10) }; _continuousDistributions = new List { - new Beta(1.0, 1.0), - new ContinuousUniform(0.0, 1.0), - new Gamma(1.0, 1.0), - new Normal(0.0, 1.0), - new Weibull(1.0, 1.0), - new LogNormal(1.0, 1.0), + new Beta(1.0, 1.0), + new ContinuousUniform(0.0, 1.0), + new Gamma(1.0, 1.0), + new Normal(0.0, 1.0), + new Weibull(1.0, 1.0), + new LogNormal(1.0, 1.0), new StudentT(0.0, 1.0, 5.0) }; } diff --git a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs index 76254837..65fec5d4 100644 --- a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Parameter A. /// Parameter B. - [Test, Sequential] - public void CanCreateBeta([Values(0.0, 0.0, 1.0, 1.0, 9.0, 5.0, 1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] double a, [Values(0.0, 0.1, 0.0, 1.0, 1.0, 100.0, Double.PositiveInfinity, 1.0, Double.PositiveInfinity, 0.0)] double b) + [TestCase(0.0, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(1.0, 0.0)] + [TestCase(1.0, 1.0)] + [TestCase(9.0, 1.0)] + [TestCase(5.0, 100.0)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + public void CanCreateBeta(double a, double b) { var n = new Beta(a, b); Assert.AreEqual(a, n.A); @@ -87,8 +96,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can Set Shape A /// /// New A value. - [Test] - public void CanSetShapeA([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double a) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetShapeA(double a) { new Beta(1.0, 1.0) { @@ -110,8 +124,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set shape B. /// /// New B value. - [Test] - public void CanSetShapeB([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double b) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetShapeB(double b) { new Beta(1.0, 1.0) { @@ -122,7 +141,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Set shape B fails with negative B. /// - [Test, Sequential] + [Test] public void SetShapeBFailsWithNegativeB() { var n = new Beta(1.0, 1.0); @@ -135,8 +154,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter A. /// Parameter B. /// Mean value. - [Test, Sequential] - public void ValidateMean([Values(0.0, 0.0, 1.0, 1.0, 9.0, 5.0, 1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] double a, [Values(0.0, 0.1, 0.0, 1.0, 1.0, 100.0, Double.PositiveInfinity, 1.0, Double.PositiveInfinity, 0.0)] double b, [Values(0.5, 0.0, 1.0, 0.5, 0.9, 0.047619047619047619047616, 0.0, 1.0, 0.0, 1.0)] double mean) + [TestCase(0.0, 0.0, 0.5)] + [TestCase(0.0, 0.1, 0.0)] + [TestCase(1.0, 0.0, 1.0)] + [TestCase(1.0, 1.0, 0.5)] + [TestCase(9.0, 1.0, 0.9)] + [TestCase(5.0, 100.0, 0.047619047619047619047616)] + [TestCase(1.0, Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 1.0)] + [TestCase(0.0, Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 1.0)] + public void ValidateMean(double a, double b, double mean) { var n = new Beta(a, b); Assert.AreEqual(mean, n.Mean); @@ -148,8 +176,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter A. /// Parameter B. /// Entropy value. - [Test, Sequential] - public void ValidateEntropy([Values(0.0, 0.0, 1.0, 1.0, 9.0, 5.0, 1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] double a, [Values(0.0, 0.1, 0.0, 1.0, 1.0, 100.0, Double.PositiveInfinity, 1.0, Double.PositiveInfinity, 0.0)] double b, [Values(0.693147180559945309417232121458176568075500134360255, 0.0, 0.0, 0.0, -1.3083356884473304939016015849561625204060922267565917, -2.5201623187602743679459255108827601222133603091753153, 0.0, 0.0, 0.0, 0.0)] double entropy) + [TestCase(0.0, 0.0, 0.693147180559945309417232121458176568075500134360255)] + [TestCase(0.0, 0.1, 0.0)] + [TestCase(1.0, 0.0, 0.0)] + [TestCase(1.0, 1.0, 0.0)] + [TestCase(9.0, 1.0, -1.3083356884473304939016015849561625204060922267565917)] + [TestCase(5.0, 100.0, -2.5201623187602743679459255108827601222133603091753153)] + [TestCase(1.0, Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(0.0, Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 0.0)] + public void ValidateEntropy(double a, double b, double entropy) { var n = new Beta(a, b); AssertHelpers.AlmostEqual(entropy, n.Entropy, 14); @@ -161,8 +198,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter A. /// Parameter B. /// Skewness value. - [Test, Sequential] - public void ValidateSkewness([Values(0.0, 0.0, 1.0, 1.0, 9.0, 5.0, 1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] double a, [Values(0.0, 0.1, 0.0, 1.0, 1.0, 100.0, Double.PositiveInfinity, 1.0, Double.PositiveInfinity, 0.0)] double b, [Values(0.0, 2.0, -2.0, 0.0, -1.4740554623801777107177478829647496373009282424841579, 0.81759410927553430354583159143895018978562196953345572, 2.0, -2.0, 2.0, -2.0)] double skewness) + [TestCase(0.0, 0.0, 0.0)] + [TestCase(0.0, 0.1, 2.0)] + [TestCase(1.0, 0.0, -2.0)] + [TestCase(1.0, 1.0, 0.0)] + [TestCase(9.0, 1.0, -1.4740554623801777107177478829647496373009282424841579)] + [TestCase(5.0, 100.0, 0.81759410927553430354583159143895018978562196953345572)] + [TestCase(1.0, Double.PositiveInfinity, 2.0)] + [TestCase(Double.PositiveInfinity, 1.0, -2.0)] + [TestCase(0.0, Double.PositiveInfinity, 2.0)] + [TestCase(Double.PositiveInfinity, 0.0, -2.0)] + public void ValidateSkewness(double a, double b, double skewness) { var n = new Beta(a, b); AssertHelpers.AlmostEqual(skewness, n.Skewness, 15); @@ -174,8 +220,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter A. /// Parameter B. /// Mode value. - [Test, Sequential] - public void ValidateMode([Values(0.0, 0.0, 1.0, 1.0, 9.0, 5.0, 1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] double a, [Values(0.0, 0.1, 0.0, 1.0, 1.0, 100.0, Double.PositiveInfinity, 1.0, Double.PositiveInfinity, 0.0)] double b, [Values(0.5, 0.0, 1.0, 0.5, 1.0, 0.038834951456310676243255386452801758423447608947753906, 0.0, 1.0, 0.0, 1.0)] double mode) + [TestCase(0.0, 0.0, 0.5)] + [TestCase(0.0, 0.1, 0.0)] + [TestCase(1.0, 0.0, 1.0)] + [TestCase(1.0, 1.0, 0.5)] + [TestCase(9.0, 1.0, 1.0)] + [TestCase(5.0, 100.0, 0.038834951456310676243255386452801758423447608947753906)] + [TestCase(1.0, Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 1.0)] + [TestCase(0.0, Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 1.0)] + public void ValidateMode(double a, double b, double mode) { var n = new Beta(a, b); Assert.AreEqual(mode, n.Mode); @@ -276,12 +331,39 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter B. /// Input value X. /// Density value. - [Test, Sequential] - public void ValidateDensity( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 9.0, 5.0, 5.0, 5.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double a, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100, 100, 100, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0)] double b, - [Values(0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, -1.0, 2.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0)] double x, - [Values(Double.PositiveInfinity, 0.0, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0, 0.0, Double.PositiveInfinity, 1.0, 1.0, 1.0, 0.0, 0.03515625, 9.0, 0.0, 0.0, 0.0, 1.0881845516040810386311829462908430145307026037926335e-21, 0.0, Double.PositiveInfinity, 0.0, 0.0, 0.0, 0.0, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0, 0.0, Double.PositiveInfinity)] double pdf) + [TestCase(0.0, 0.0, 0.0, Double.PositiveInfinity)] + [TestCase(0.0, 0.0, 0.5, 0.0)] + [TestCase(0.0, 0.0, 1.0, Double.PositiveInfinity)] + [TestCase(0.0, 0.1, 0.0, Double.PositiveInfinity)] + [TestCase(0.0, 0.1, 0.5, 0.0)] + [TestCase(0.0, 0.1, 1.0, 0.0)] + [TestCase(1.0, 0.0, 0.0, 0.0)] + [TestCase(1.0, 0.0, 0.5, 0.0)] + [TestCase(1.0, 0.0, 1.0, Double.PositiveInfinity)] + [TestCase(1.0, 1.0, 0.0, 1.0)] + [TestCase(1.0, 1.0, 0.5, 1.0)] + [TestCase(1.0, 1.0, 1.0, 1.0)] + [TestCase(9.0, 1.0, 0.0, 0.0)] + [TestCase(9.0, 1.0, 0.5, 0.03515625)] + [TestCase(9.0, 1.0, 1.0, 9.0)] + [TestCase(9.0, 1.0, -1.0, 0.0)] + [TestCase(9.0, 1.0, 2.0, 0.0)] + [TestCase(5.0, 100, 0.0, 0.0)] + [TestCase(5.0, 100, 0.5, 1.0881845516040810386311829462908430145307026037926335e-21)] + [TestCase(5.0, 100, 1.0, 0.0)] + [TestCase(1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity, 0.5, 0.0)] + [TestCase(1.0, Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 0.0, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 0.5, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 1.0, Double.PositiveInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 0.5, 0.0)] + [TestCase(0.0, Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 0.0, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 0.5, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 1.0, Double.PositiveInfinity)] + public void ValidateDensity(double a, double b, double x, double pdf) { var n = new Beta(a, b); AssertHelpers.AlmostEqual(pdf, n.Density(x), 13); @@ -294,12 +376,39 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter B. /// Input value X. /// Density log value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 9.0, 5.0, 5.0, 5.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double a, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100, 100, 100, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0)] double b, - [Values(0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, -1.0, 2.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0)] double x, - [Values(Double.PositiveInfinity, Double.NegativeInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0, Double.NegativeInfinity, -3.3479528671433430925473664978203611353090199592365458, 2.1972245773362193827904904738450514092949811156454996, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -51.447830024537682154565870837960406410586196074573801, Double.NegativeInfinity, Double.PositiveInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, Double.PositiveInfinity)] double pdfln) + [TestCase(0.0, 0.0, 0.0, Double.PositiveInfinity)] + [TestCase(0.0, 0.0, 0.5, Double.NegativeInfinity)] + [TestCase(0.0, 0.0, 1.0, Double.PositiveInfinity)] + [TestCase(0.0, 0.1, 0.0, Double.PositiveInfinity)] + [TestCase(0.0, 0.1, 0.5, Double.NegativeInfinity)] + [TestCase(0.0, 0.1, 1.0, Double.NegativeInfinity)] + [TestCase(1.0, 0.0, 0.0, Double.NegativeInfinity)] + [TestCase(1.0, 0.0, 0.5, Double.NegativeInfinity)] + [TestCase(1.0, 0.0, 1.0, Double.PositiveInfinity)] + [TestCase(1.0, 1.0, 0.0, 0.0)] + [TestCase(1.0, 1.0, 0.5, 0.0)] + [TestCase(1.0, 1.0, 1.0, 0.0)] + [TestCase(9.0, 1.0, 0.0, Double.NegativeInfinity)] + [TestCase(9.0, 1.0, 0.5, -3.3479528671433430925473664978203611353090199592365458)] + [TestCase(9.0, 1.0, 1.0, 2.1972245773362193827904904738450514092949811156454996)] + [TestCase(9.0, 1.0, -1.0, Double.NegativeInfinity)] + [TestCase(9.0, 1.0, 2.0, Double.NegativeInfinity)] + [TestCase(5.0, 100, 0.0, Double.NegativeInfinity)] + [TestCase(5.0, 100, 0.5, -51.447830024537682154565870837960406410586196074573801)] + [TestCase(5.0, 100, 1.0, Double.NegativeInfinity)] + [TestCase(1.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity, 0.5, Double.NegativeInfinity)] + [TestCase(1.0, Double.PositiveInfinity, 1.0, Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity, 1.0, 0.0, Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity, 1.0, 0.5, Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity, 1.0, 1.0, Double.PositiveInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 0.0, Double.PositiveInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 0.5, Double.NegativeInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 1.0, Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity, 0.0, 0.0, Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity, 0.0, 0.5, Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity, 0.0, 1.0, Double.PositiveInfinity)] + public void ValidateDensityLn(double a, double b, double x, double pdfln) { var n = new Beta(a, b); AssertHelpers.AlmostEqual(pdfln, n.DensityLn(x), 14); @@ -312,12 +421,37 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Parameter B. /// Input value X. /// Cumulative distribution value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 5.0, 5.0, 5.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double a, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 100, 100, 100, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, 0.0, 0.0, 0.0)] double b, - [Values(0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0)] double x, - [Values(0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 0.001953125, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0)] double cdf) + [TestCase(0.0, 0.0, 0.0, 0.5)] + [TestCase(0.0, 0.0, 0.5, 0.5)] + [TestCase(0.0, 0.0, 1.0, 1.0)] + [TestCase(0.0, 0.1, 0.0, 1.0)] + [TestCase(0.0, 0.1, 0.5, 1.0)] + [TestCase(0.0, 0.1, 1.0, 1.0)] + [TestCase(1.0, 0.0, 0.0, 0.0)] + [TestCase(1.0, 0.0, 0.5, 0.0)] + [TestCase(1.0, 0.0, 1.0, 1.0)] + [TestCase(1.0, 1.0, 0.0, 0.0)] + [TestCase(1.0, 1.0, 0.5, 0.5)] + [TestCase(1.0, 1.0, 1.0, 1.0)] + [TestCase(9.0, 1.0, 0.0, 0.0)] + [TestCase(9.0, 1.0, 0.5, 0.001953125)] + [TestCase(9.0, 1.0, 1.0, 1.0)] + [TestCase(5.0, 100, 0.0, 0.0)] + [TestCase(5.0, 100, 0.5, 1.0)] + [TestCase(5.0, 100, 1.0, 1.0)] + [TestCase(1.0, Double.PositiveInfinity, 0.0, 1.0)] + [TestCase(1.0, Double.PositiveInfinity, 0.5, 1.0)] + [TestCase(1.0, Double.PositiveInfinity, 1.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0, 0.0, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 0.5, 0.0)] + [TestCase(Double.PositiveInfinity, 1.0, 1.0, 1.0)] + [TestCase(0.0, Double.PositiveInfinity, 0.0, 1.0)] + [TestCase(0.0, Double.PositiveInfinity, 0.5, 1.0)] + [TestCase(0.0, Double.PositiveInfinity, 1.0, 1.0)] + [TestCase(Double.PositiveInfinity, 0.0, 0.0, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 0.5, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0, 1.0, 1.0)] + public void ValidateCumulativeDistribution(double a, double b, double x, double cdf) { var n = new Beta(a, b); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 13); diff --git a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs index d43ae8b8..95e4c5de 100644 --- a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -62,8 +62,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void CanCreateCauchy([Values(0.0, 0.0, 0.0, 10.0, -5.0, 0.0)] double location, [Values(0.1, 1.0, 10.0, 11.0, 100.0, Double.PositiveInfinity)] double scale) + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void CanCreateCauchy(double location, double scale) { var n = new Cauchy(location, scale); Assert.AreEqual(location, n.Location); @@ -75,8 +80,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void CauchyCreateFailsWithBadParameters([Values(Double.NaN, 1.0, Double.NaN, 1.0)] double location, [Values(1.0, Double.NaN, Double.NaN, 0.0)] double scale) + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + [TestCase(1.0, 0.0)] + public void CauchyCreateFailsWithBadParameters(double location, double scale) { Assert.Throws(() => new Cauchy(location, scale)); } @@ -95,8 +103,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set location. /// /// Location value. - [Test] - public void CanSetLocation([Values(-10.0, -0.0, 0.0, 0.1, 1.0)] double location) + [TestCase(-10.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + public void CanSetLocation(double location) { new Cauchy { @@ -118,8 +130,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(1.0, 2.0, 12.0)] double scale) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(12.0)] + public void CanSetScale(double scale) { new Cauchy { @@ -142,8 +156,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateEntropy([Values(-0.0, 0.0, 0.1, 1.0, 10.0)] double location, [Values(2.0, 2.0, 4.0, 10.0, 11.0)] double scale) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + public void ValidateEntropy(double location, double scale) { var n = new Cauchy(location, scale); Assert.AreEqual(Math.Log(4.0 * Constants.Pi * scale), n.Entropy); @@ -164,8 +182,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateMode([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double location, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double scale) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMode(double location, double scale) { var n = new Cauchy(location, scale); Assert.AreEqual(location, n.Mode); @@ -176,8 +199,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateMedian([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double location, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double scale) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMedian(double location, double scale) { var n = new Cauchy(location, scale); Assert.AreEqual(location, n.Median); @@ -188,8 +216,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateMinimum([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double location, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double scale) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMinimum(double location, double scale) { var n = new Cauchy(location, scale); Assert.AreEqual(Double.NegativeInfinity, n.Minimum); @@ -200,8 +233,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateMaximum([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double location, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double scale) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMaximum(double location, double scale) { var n = new Cauchy(location, scale); Assert.AreEqual(Double.PositiveInfinity, n.Maximum); @@ -212,8 +250,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateDensity([Values(0.0, 0.0, 0.0, -5.0, 0.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity, 1.0)] double scale) + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 1.0)] + public void ValidateDensity(double location, double scale) { var n = new Cauchy(location, scale); for (var i = 0; i < 11; i++) @@ -228,8 +271,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateDensityLn([Values(0.0, 0.0, 0.0, -5.0, 0.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity, 1.0)] double scale) + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 1.0)] + public void ValidateDensityLn(double location, double scale) { var n = new Cauchy(location, scale); for (var i = 0; i < 11; i++) @@ -265,8 +313,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Sequential] - public void ValidateCumulativeDistribution([Values(0.0, 0.0, 0.0, -5.0, 0.0)] double location, [Values(0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double scale) + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double location, double scale) { var n = new Cauchy(location, scale); for (var i = 0; i < 11; i++) diff --git a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs index 36e152da..b8430b83 100644 --- a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can create chi square. /// /// Degrees of freedom. - [Test] - public void CanCreateChiSquare([Values(1.0, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void CanCreateChiSquare(double dof) { var n = new ChiSquare(dof); Assert.AreEqual(dof, n.DegreesOfFreedom); @@ -61,8 +63,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Chi square create fails with bad parameters. /// /// Degrees of freedom. - [Test] - public void ChiSquareCreateFailsWithBadParameters([Values(0.0, -1.0, -100.0, Double.NegativeInfinity, Double.NaN)] double dof) + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-100.0)] + [TestCase(Double.NegativeInfinity)] + [TestCase(Double.NaN)] + public void ChiSquareCreateFailsWithBadParameters(double dof) { Assert.Throws(() => new ChiSquare(dof)); } @@ -81,8 +87,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set degrees of freedom. /// /// Degrees of freedom. - [Test] - public void CanSetDoF([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double dof) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetDoF(double dof) { new ChiSquare(1.0) { @@ -94,8 +103,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set Degrees of freedom fails with non-positive value. /// /// Degrees of freedom. - [Test] - public void SetDofFailsWithNonPositiveDoF([Values(-1.0, -0.0, 0.0)] double dof) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetDofFailsWithNonPositiveDoF(double dof) { var n = new ChiSquare(1.0); Assert.Throws(() => n.DegreesOfFreedom = dof); @@ -105,8 +116,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mean. /// /// Degrees of freedom. - [Test] - public void ValidateMean([Values(1.0, 2.0, 2.5, 5.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(5.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMean(double dof) { var n = new ChiSquare(dof); Assert.AreEqual(dof, n.Mean); @@ -116,8 +131,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate variance. /// /// Degrees of freedom - [Test] - public void ValidateVariance([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateVariance(double dof) { var n = new ChiSquare(dof); Assert.AreEqual(2 * dof, n.Variance); @@ -127,8 +146,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate standard deviation /// /// Degrees of freedom - [Test] - public void ValidateStdDev([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateStdDev(double dof) { var n = new ChiSquare(dof); Assert.AreEqual(Math.Sqrt(n.Variance), n.StdDev); @@ -138,8 +161,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mode. /// /// Degrees of freedom - [Test] - public void ValidateMode([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMode(double dof) { var n = new ChiSquare(dof); Assert.AreEqual(dof - 2, n.Mode); @@ -149,8 +176,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate median. /// /// Degrees of freedom - [Test] - public void ValidateMedian([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMedian(double dof) { var n = new ChiSquare(dof); Assert.AreEqual(dof - (2.0 / 3.0), n.Median); @@ -181,10 +212,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom. /// Input X value. - [Test, Sequential] - public void ValidateDensity( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x) + [TestCase(1.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(1.0, 5.5)] + [TestCase(1.0, 110.1)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(2.0, 0.0)] + [TestCase(2.0, 0.1)] + [TestCase(2.0, 1.0)] + [TestCase(2.0, 5.5)] + [TestCase(2.0, 110.1)] + [TestCase(2.0, Double.PositiveInfinity)] + [TestCase(2.5, 0.0)] + [TestCase(2.5, 0.1)] + [TestCase(2.5, 1.0)] + [TestCase(2.5, 5.5)] + [TestCase(2.5, 110.1)] + [TestCase(2.5, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(Double.PositiveInfinity, 5.5)] + [TestCase(Double.PositiveInfinity, 110.1)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensity(double dof, double x) { var n = new ChiSquare(dof); Assert.AreEqual((Math.Pow(x, (dof / 2.0) - 1.0) * Math.Exp(-x / 2.0)) / (Math.Pow(2.0, dof / 2.0) * SpecialFunctions.Gamma(dof / 2.0)), n.Density(x)); @@ -195,10 +247,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom. /// Input X value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x) + [TestCase(1.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(1.0, 5.5)] + [TestCase(1.0, 110.1)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(2.0, 0.0)] + [TestCase(2.0, 0.1)] + [TestCase(2.0, 1.0)] + [TestCase(2.0, 5.5)] + [TestCase(2.0, 110.1)] + [TestCase(2.0, Double.PositiveInfinity)] + [TestCase(2.5, 0.0)] + [TestCase(2.5, 0.1)] + [TestCase(2.5, 1.0)] + [TestCase(2.5, 5.5)] + [TestCase(2.5, 110.1)] + [TestCase(2.5, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(Double.PositiveInfinity, 5.5)] + [TestCase(Double.PositiveInfinity, 110.1)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensityLn(double dof, double x) { var n = new ChiSquare(dof); Assert.AreEqual((-x / 2.0) + (((dof / 2.0) - 1.0) * Math.Log(x)) - ((dof / 2.0) * Math.Log(2)) - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x)); @@ -248,10 +321,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom. /// Input X value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x) + [TestCase(1.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(1.0, 5.5)] + [TestCase(1.0, 110.1)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(2.0, 0.0)] + [TestCase(2.0, 0.1)] + [TestCase(2.0, 1.0)] + [TestCase(2.0, 5.5)] + [TestCase(2.0, 110.1)] + [TestCase(2.0, Double.PositiveInfinity)] + [TestCase(2.5, 0.0)] + [TestCase(2.5, 0.1)] + [TestCase(2.5, 1.0)] + [TestCase(2.5, 5.5)] + [TestCase(2.5, 110.1)] + [TestCase(2.5, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(Double.PositiveInfinity, 5.5)] + [TestCase(Double.PositiveInfinity, 110.1)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double dof, double x) { var n = new ChiSquare(dof); Assert.AreEqual(SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x / 2.0) / SpecialFunctions.Gamma(dof / 2.0), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs index 2764de60..44f51771 100644 --- a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can create chi. /// /// Degrees of freedom - [Test] - public void CanCreateChi([Values(1.0, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void CanCreateChi(double dof) { var n = new Chi(dof); Assert.AreEqual(dof, n.DegreesOfFreedom); @@ -61,8 +63,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Chi create fails with bad parameters. /// /// Degrees of freedom. - [Test] - public void ChiCreateFailsWithBadParameters([Values(0.0, -1.0, -100.0, Double.NegativeInfinity, Double.NaN)] double dof) + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-100.0)] + [TestCase(Double.NegativeInfinity)] + [TestCase(Double.NaN)] + public void ChiCreateFailsWithBadParameters(double dof) { Assert.Throws(() => new Chi(dof)); } @@ -81,8 +87,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set degrees of freedom. /// /// Degrees of freedom. - [Test] - public void CanSetDoF([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double dof) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetDoF(double dof) { new Chi(1.0) { @@ -94,8 +103,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set Degrees of freedom fails with non-positive value. /// /// Degrees of freedom. - [Test] - public void SetDofFailsWithNonPositiveDoF([Values(-1.0, -0.0, 0.0)] double dof) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetDofFailsWithNonPositiveDoF(double dof) { var n = new Chi(1.0); Assert.Throws(() => n.DegreesOfFreedom = dof); @@ -105,8 +116,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mean. /// /// Degrees of freedom. - [Test] - public void ValidateMean([Values(1.0, 2.0, 2.5, 5.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(5.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMean(double dof) { var n = new Chi(dof); Assert.AreEqual(Math.Sqrt(2) * (SpecialFunctions.Gamma((dof + 1.0) / 2.0) / SpecialFunctions.Gamma(dof / 2.0)), n.Mean); @@ -116,8 +131,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate variance. /// /// Degrees of freedom - [Test] - public void ValidateVariance([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateVariance(double dof) { var n = new Chi(dof); Assert.AreEqual(dof - (n.Mean * n.Mean), n.Variance); @@ -127,8 +146,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate standard deviation /// /// Degrees of freedom - [Test] - public void ValidateStdDev([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateStdDev(double dof) { var n = new Chi(dof); Assert.AreEqual(Math.Sqrt(n.Variance), n.StdDev); @@ -138,8 +161,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mode. /// /// Degrees of freedom - [Test] - public void ValidateMode([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(2.5)] + [TestCase(3.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMode(double dof) { var n = new Chi(dof); if (dof >= 1) @@ -183,10 +210,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom. /// Input X value. - [Test, Sequential] - public void ValidateDensity( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x) + [TestCase(1.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(1.0, 5.5)] + [TestCase(1.0, 110.1)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(2.0, 0.0)] + [TestCase(2.0, 0.1)] + [TestCase(2.0, 1.0)] + [TestCase(2.0, 5.5)] + [TestCase(2.0, 110.1)] + [TestCase(2.0, Double.PositiveInfinity)] + [TestCase(2.5, 0.0)] + [TestCase(2.5, 0.1)] + [TestCase(2.5, 1.0)] + [TestCase(2.5, 5.5)] + [TestCase(2.5, 110.1)] + [TestCase(2.5, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(Double.PositiveInfinity, 5.5)] + [TestCase(Double.PositiveInfinity, 110.1)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensity(double dof, double x) { var n = new Chi(dof); Assert.AreEqual((Math.Pow(2.0, 1.0 - (dof / 2.0)) * Math.Pow(x, dof - 1.0) * Math.Exp(-x * (x / 2.0))) / SpecialFunctions.Gamma(dof / 2.0), n.Density(x)); @@ -197,10 +245,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom. /// Input X value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x) + [TestCase(1.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(1.0, 5.5)] + [TestCase(1.0, 110.1)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(2.0, 0.0)] + [TestCase(2.0, 0.1)] + [TestCase(2.0, 1.0)] + [TestCase(2.0, 5.5)] + [TestCase(2.0, 110.1)] + [TestCase(2.0, Double.PositiveInfinity)] + [TestCase(2.5, 0.0)] + [TestCase(2.5, 0.1)] + [TestCase(2.5, 1.0)] + [TestCase(2.5, 5.5)] + [TestCase(2.5, 110.1)] + [TestCase(2.5, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(Double.PositiveInfinity, 5.5)] + [TestCase(Double.PositiveInfinity, 110.1)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensityLn(double dof, double x) { var n = new Chi(dof); Assert.AreEqual(((1.0 - (dof / 2.0)) * Math.Log(2.0)) + ((dof - 1.0) * Math.Log(x)) - (x * (x / 2.0)) - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x)); @@ -232,10 +301,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom. /// Input X value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x) + [TestCase(1.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(1.0, 5.5)] + [TestCase(1.0, 110.1)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(2.0, 0.0)] + [TestCase(2.0, 0.1)] + [TestCase(2.0, 1.0)] + [TestCase(2.0, 5.5)] + [TestCase(2.0, 110.1)] + [TestCase(2.0, Double.PositiveInfinity)] + [TestCase(2.5, 0.0)] + [TestCase(2.5, 0.1)] + [TestCase(2.5, 1.0)] + [TestCase(2.5, 5.5)] + [TestCase(2.5, 110.1)] + [TestCase(2.5, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(Double.PositiveInfinity, 5.5)] + [TestCase(Double.PositiveInfinity, 110.1)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double dof, double x) { var n = new Chi(dof); Assert.AreEqual(SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x * x / 2.0) / SpecialFunctions.Gamma(dof / 2.0), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs index 8b641e65..18e1fdb1 100644 --- a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs @@ -62,8 +62,14 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void CanCreateContinuousUniform([Values(0.0, 0.0, 0.0, 10.0, -5.0)] double lower, [Values(0.0, 0.1, 1.0, 10.0, 11.0, 100.0, Double.PositiveInfinity)] double upper) + [TestCase(0.0, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(-5.0, 11.0)] + [TestCase(-5.0, 100.0)] + [TestCase(Double.NegativeInfinity, Double.PositiveInfinity)] + public void CanCreateContinuousUniform(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual(lower, n.Lower); @@ -75,8 +81,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ContinuousUniformCreateFailsWithBadParameters([Values(Double.NaN, 1.0, Double.NaN, 1.0)] double lower, [Values(1.0, Double.NaN, Double.NaN, 0.0)] double upper) + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + [TestCase(1.0, 0.0)] + public void ContinuousUniformCreateFailsWithBadParameters(double lower, double upper) { Assert.Throws(() => new ContinuousUniform(lower, upper)); } @@ -95,8 +104,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set lower bound. /// /// Lower bound. - [Test] - public void CanSetLower([Values(-10.0, -0.0, 0.0, 0.1, 1.0)] double lower) + [TestCase(-10.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + public void CanSetLower(double lower) { new ContinuousUniform { @@ -118,8 +131,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set upper bound. /// /// Upper bound. - [Test] - public void CanSetUpper([Values(1.0, 2.0, 12.0)] double upper) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(12.0)] + public void CanSetUpper(double upper) { new ContinuousUniform { @@ -142,8 +157,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateEntropy([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double lower, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double upper) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateEntropy(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual(Math.Log(upper - lower), n.Entropy); @@ -154,8 +174,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateSkewness([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double lower, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double upper) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateSkewness(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual(0.0, n.Skewness); @@ -166,8 +191,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateMode([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double lower, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double upper) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMode(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual((lower + upper) / 2.0, n.Mode); @@ -178,8 +208,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateMedian([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double lower, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double upper) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMedian(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual((lower + upper) / 2.0, n.Median); @@ -190,8 +225,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateMinimum([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double lower, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double upper) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMinimum(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual(lower, n.Minimum); @@ -202,8 +242,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateMaximum([Values(-0.0, 0.0, 0.1, 1.0, 10.0, 0.0)] double lower, [Values(2.0, 2.0, 4.0, 10.0, 11.0, Double.PositiveInfinity)] double upper) + [TestCase(-0.0, 2.0)] + [TestCase(0.0, 2.0)] + [TestCase(0.1, 4.0)] + [TestCase(1.0, 10.0)] + [TestCase(10.0, 11.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateMaximum(double lower, double upper) { var n = new ContinuousUniform(lower, upper); Assert.AreEqual(upper, n.Maximum); @@ -214,8 +259,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateDensity([Values(0.0, 0.0, 0.0, 0.0, -5.0, 0.0)] double lower, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double upper) + [TestCase(0.0, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateDensity(double lower, double upper) { var n = new ContinuousUniform(lower, upper); for (var i = 0; i < 11; i++) @@ -237,8 +287,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateDensityLn([Values(0.0, 0.0, 0.0, 0.0, -5.0, 0.0)] double lower, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double upper) + [TestCase(0.0, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateDensityLn(double lower, double upper) { var n = new ContinuousUniform(lower, upper); for (var i = 0; i < 11; i++) @@ -318,8 +373,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateCumulativeDistribution([Values(0.0, 0.0, 0.0, 0.0, -5.0, 0.0)] double lower, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double upper) + [TestCase(0.0, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(-5.0, 100.0)] + [TestCase(0.0, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double lower, double upper) { var n = new ContinuousUniform(lower, upper); for (var i = 0; i < 11; i++) diff --git a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs index df6f12e9..c6ed9ddb 100644 --- a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Inverse scale value. - [Test, Sequential] - public void CanCreateErlang([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale) + [TestCase(0, 0.0)] + [TestCase(1, 0.1)] + [TestCase(1, 1.0)] + [TestCase(10, 10.0)] + [TestCase(10, 1.0)] + [TestCase(10, Double.PositiveInfinity)] + public void CanCreateErlang(int shape, double invScale) { var n = new Erlang(shape, invScale); Assert.AreEqual(shape, n.Shape); @@ -64,8 +69,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Inverse scale value. - [Test, Sequential] - public void ErlangCreateFailsWithBadParameters([Values(1, 1, -1, -1, -1)] int shape, [Values(Double.NaN, -1.0, 1.0, -1.0, Double.NaN)] double invScale) + [TestCase(1, Double.NaN)] + [TestCase(1, -1.0)] + [TestCase(-1, 1.0)] + [TestCase(-1, -1.0)] + [TestCase(-1, Double.NaN)] + public void ErlangCreateFailsWithBadParameters(int shape, double invScale) { Assert.Throws(() => new Erlang(shape, invScale)); } @@ -75,8 +84,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Inverse scale value. - [Test, Sequential] - public void CanCreateErlangWithShapeInvScale([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale) + [TestCase(0, 0.0)] + [TestCase(1, 0.1)] + [TestCase(1, 1.0)] + [TestCase(10, 10.0)] + [TestCase(10, 1.0)] + [TestCase(10, Double.PositiveInfinity)] + public void CanCreateErlangWithShapeInvScale(int shape, double invScale) { var n = Erlang.WithShapeInvScale(shape, invScale); Assert.AreEqual(shape, n.Shape); @@ -88,8 +102,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Scale value. - [Test, Sequential] - public void CanCreateErlangWithShapeScale([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double scale) + [TestCase(0, 0.0)] + [TestCase(1, 0.1)] + [TestCase(1, 1.0)] + [TestCase(10, 10.0)] + [TestCase(10, 1.0)] + [TestCase(10, Double.PositiveInfinity)] + public void CanCreateErlangWithShapeScale(int shape, double scale) { var n = Erlang.WithShapeScale(shape, scale); Assert.AreEqual(shape, n.Shape); @@ -110,8 +129,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set shape. /// /// New shape value. - [Test] - public void CanSetShape([Values(-0, 0, 1, 10)] int shape) + [TestCase(-0)] + [TestCase(0)] + [TestCase(1)] + [TestCase(10)] + public void CanSetShape(int shape) { new Erlang(1, 1.0) { @@ -133,8 +155,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale /// /// New scale value. - [Test] - public void CanSetScale([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Erlang(1, 1.0) { @@ -156,8 +183,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set inverse scale. /// /// Inverse scale value. - [Test] - public void CanSetInvScale([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double invScale) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetInvScale(double invScale) { new Erlang(1, 1.0) { @@ -181,8 +213,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected mean. - [Test, Sequential] - public void ValidateMean([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 10.0, 1.0, 1.0, 10.0, 10.0)] double mean) + [TestCase(0, 0.0, Double.NaN)] + [TestCase(1, 0.1, 10.0)] + [TestCase(1, 1.0, 1.0)] + [TestCase(10, 10.0, 1.0)] + [TestCase(10, 1.0, 10.0)] + [TestCase(10, Double.PositiveInfinity, 10.0)] + public void ValidateMean(int shape, double invScale, double mean) { var n = new Erlang(shape, invScale); Assert.AreEqual(mean, n.Mean); @@ -194,8 +231,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected variance. - [Test, Sequential] - public void ValidateVariance([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 100.0, 1.0, 0.1, 10.0, 0.0)] double var) + [TestCase(0, 0.0, Double.NaN)] + [TestCase(1, 0.1, 100.0)] + [TestCase(1, 1.0, 1.0)] + [TestCase(10, 10.0, 0.1)] + [TestCase(10, 1.0, 10.0)] + [TestCase(10, Double.PositiveInfinity, 0.0)] + public void ValidateVariance(int shape, double invScale, double var) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(var, n.Variance, 15); @@ -207,8 +249,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateStdDev([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 10.0, 1.0, 0.31622776601683794197697302588502426416723164097476643, 3.1622776601683793319988935444327185337195551393252168, 0.0)] double sdev) + [TestCase(0, 0.0, Double.NaN)] + [TestCase(1, 0.1, 10.0)] + [TestCase(1, 1.0, 1.0)] + [TestCase(10, 10.0, 0.31622776601683794197697302588502426416723164097476643)] + [TestCase(10, 1.0, 3.1622776601683793319988935444327185337195551393252168)] + [TestCase(10, Double.PositiveInfinity, 0.0)] + public void ValidateStdDev(int shape, double invScale, double sdev) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(sdev, n.StdDev, 15); @@ -220,8 +267,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateEntropy([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 3.3025850929940456285068402234265387271634735938763824, 1.0, 0.23346908548693395836262094490967812177376750477943892, 2.5360541784809796423806123995940423293748689934081866, 0.0)] double entropy) + [TestCase(0, 0.0, Double.NaN)] + [TestCase(1, 0.1, 3.3025850929940456285068402234265387271634735938763824)] + [TestCase(1, 1.0, 1.0)] + [TestCase(10, 10.0, 0.23346908548693395836262094490967812177376750477943892)] + [TestCase(10, 1.0, 2.5360541784809796423806123995940423293748689934081866)] + [TestCase(10, Double.PositiveInfinity, 0.0)] + public void ValidateEntropy(int shape, double invScale, double entropy) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(entropy, n.Entropy, 13); @@ -233,8 +285,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateSkewness([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 2.0, 2.0, 0.63245553203367586639977870888654370674391102786504337, 0.63245553203367586639977870888654370674391102786504337, 0.0)] double skewness) + [TestCase(0, 0.0, Double.NaN)] + [TestCase(1, 0.1, 2.0)] + [TestCase(1, 1.0, 2.0)] + [TestCase(10, 10.0, 0.63245553203367586639977870888654370674391102786504337)] + [TestCase(10, 1.0, 0.63245553203367586639977870888654370674391102786504337)] + [TestCase(10, Double.PositiveInfinity, 0.0)] + public void ValidateSkewness(int shape, double invScale, double skewness) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(skewness, n.Skewness, 15); @@ -246,8 +303,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateMode([Values(1, 1, 10, 10, 10)] int shape, [Values(0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(0.0, 0.0, 0.9, 9.0, 10.0)] double mode) + [TestCase(1, 0.1, 0.0)] + [TestCase(1, 1.0, 0.0)] + [TestCase(10, 10.0, 0.9)] + [TestCase(10, 1.0, 9.0)] + [TestCase(10, Double.PositiveInfinity, 10.0)] + public void ValidateMode(int shape, double invScale, double mode) { var n = new Erlang(shape, invScale); Assert.AreEqual(mode, n.Mode); @@ -290,12 +351,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Inverse scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensity( - [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(0.0, 0.0, 0.0, 0.10000000000000000555111512312578270211815834045410156, 0.090483741803595961836995913651194571475319347018875963, 0.036787944117144234201693506390001264039984687455876246, 1.0, 0.36787944117144232159552377016146086744581113103176804, 0.000045399929762484851535591515560550610237918088866564953, 0.0, 1.2511003572113329898476497894772544708420990097708588, 1.0251532120868705806216092933926141802686541811003037e-30, 0.0, 0.0000010137771196302974029859010421116095333052555418644397, 0.12511003572113329898476497894772544708420990097708601, 0.0, 0.0, Double.PositiveInfinity)] double pdf) + [TestCase(0, 0.0, 0.0, 0.0)] + [TestCase(0, 0.0, 1.0, 0.0)] + [TestCase(0, 0.0, 10.0, 0.0)] + [TestCase(1, 0.1, 0.0, 0.10000000000000000555111512312578270211815834045410156)] + [TestCase(1, 0.1, 1.0, 0.090483741803595961836995913651194571475319347018875963)] + [TestCase(1, 0.1, 10.0, 0.036787944117144234201693506390001264039984687455876246)] + [TestCase(1, 1.0, 0.0, 1.0)] + [TestCase(1, 1.0, 1.0, 0.36787944117144232159552377016146086744581113103176804)] + [TestCase(1, 1.0, 10.0, 0.000045399929762484851535591515560550610237918088866564953)] + [TestCase(10, 10.0, 0.0, 0.0)] + [TestCase(10, 10.0, 1.0, 1.2511003572113329898476497894772544708420990097708588)] + [TestCase(10, 10.0, 10.0, 1.0251532120868705806216092933926141802686541811003037e-30)] + [TestCase(10, 1.0, 0.0, 0.0)] + [TestCase(10, 1.0, 1.0, 0.0000010137771196302974029859010421116095333052555418644397)] + [TestCase(10, 1.0, 10.0, 0.12511003572113329898476497894772544708420990097708601)] + [TestCase(10, Double.PositiveInfinity, 0.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 10.0, Double.PositiveInfinity)] + public void ValidateDensity(int shape, double invScale, double x, double pdf) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(pdf, n.Density(x), 14); @@ -308,12 +382,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Inverse scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -2.3025850929940456285068402234265387271634735938763824, -2.402585092994045634057955346552321429281631934330484, -3.3025850929940456285068402234265387271634735938763824, 0.0, -1.0, -10.0, Double.NegativeInfinity, 0.22402344985898722897219667227693591172986563062456522, -69.052710713194601614865880235563786219860220971716511, Double.NegativeInfinity, -13.801827480081469611207717874566706164281149255663166, -2.0785616431350584550457947824074282958712358580042068, Double.NegativeInfinity, Double.NegativeInfinity, Double.PositiveInfinity)] double pdfln) + [TestCase(0, 0.0, 0.0, Double.NegativeInfinity)] + [TestCase(0, 0.0, 1.0, Double.NegativeInfinity)] + [TestCase(0, 0.0, 10.0, Double.NegativeInfinity)] + [TestCase(1, 0.1, 0.0, -2.3025850929940456285068402234265387271634735938763824)] + [TestCase(1, 0.1, 1.0, -2.402585092994045634057955346552321429281631934330484)] + [TestCase(1, 0.1, 10.0, -3.3025850929940456285068402234265387271634735938763824)] + [TestCase(1, 1.0, 0.0, 0.0)] + [TestCase(1, 1.0, 1.0, -1.0)] + [TestCase(1, 1.0, 10.0, -10.0)] + [TestCase(10, 10.0, 0.0, Double.NegativeInfinity)] + [TestCase(10, 10.0, 1.0, 0.22402344985898722897219667227693591172986563062456522)] + [TestCase(10, 10.0, 10.0, -69.052710713194601614865880235563786219860220971716511)] + [TestCase(10, 1.0, 0.0, Double.NegativeInfinity)] + [TestCase(10, 1.0, 1.0, -13.801827480081469611207717874566706164281149255663166)] + [TestCase(10, 1.0, 10.0, -2.0785616431350584550457947824074282958712358580042068)] + [TestCase(10, Double.PositiveInfinity, 0.0, Double.NegativeInfinity)] + [TestCase(10, Double.PositiveInfinity, 1.0, Double.NegativeInfinity)] + [TestCase(10, Double.PositiveInfinity, 10.0, Double.PositiveInfinity)] + public void ValidateDensityLn(int shape, double invScale, double x, double pdfln) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(pdfln, n.DensityLn(x), 14); @@ -347,12 +434,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Inverse scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(0.0, 0.0, 0.0, 0.0, 0.095162581964040431858607615783064404690935346242622848, 0.63212055882855767840447622983853913255418886896823196, 0.0, 0.63212055882855767840447622983853913255418886896823196, 0.99995460007023751514846440848443944938976208191113396, 0.0, 0.54207028552814779168583514294066541824736464003242184, 0.99999999999999999999999999999988746526039157266114706, 0.0, 0.00000011142547833872067735305068724025236288094949815466035, 0.54207028552814779168583514294066541824736464003242184, 0.0, 0.0, 1.0)] double cdf) + [TestCase(0, 0.0, 0.0, 0.0)] + [TestCase(0, 0.0, 1.0, 0.0)] + [TestCase(0, 0.0, 10.0, 0.0)] + [TestCase(1, 0.1, 0.0, 0.0)] + [TestCase(1, 0.1, 1.0, 0.095162581964040431858607615783064404690935346242622848)] + [TestCase(1, 0.1, 10.0, 0.63212055882855767840447622983853913255418886896823196)] + [TestCase(1, 1.0, 0.0, 0.0)] + [TestCase(1, 1.0, 1.0, 0.63212055882855767840447622983853913255418886896823196)] + [TestCase(1, 1.0, 10.0, 0.99995460007023751514846440848443944938976208191113396)] + [TestCase(10, 10.0, 0.0, 0.0)] + [TestCase(10, 10.0, 1.0, 0.54207028552814779168583514294066541824736464003242184)] + [TestCase(10, 10.0, 10.0, 0.99999999999999999999999999999988746526039157266114706)] + [TestCase(10, 1.0, 0.0, 0.0)] + [TestCase(10, 1.0, 1.0, 0.00000011142547833872067735305068724025236288094949815466035)] + [TestCase(10, 1.0, 10.0, 0.54207028552814779168583514294066541824736464003242184)] + [TestCase(10, Double.PositiveInfinity, 0.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 10.0, 1.0)] + public void ValidateCumulativeDistribution(int shape, double invScale, double x, double cdf) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 14); diff --git a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs index e5125caf..4e1c5add 100644 --- a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can create exponential. /// /// Lambda value. - [Test] - public void CanCreateExponential([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanCreateExponential(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(lambda, n.Lambda); @@ -61,8 +65,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Exponential create fails with bad parameter. /// /// Lambda value. - [Test] - public void ExponentialCreateFailsWithBadParameters([Values(Double.NaN, -1.0, -10.0)] double lambda) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(-10.0)] + public void ExponentialCreateFailsWithBadParameters(double lambda) { Assert.Throws(() => new Exponential(lambda)); } @@ -81,8 +87,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set lambda. /// /// Lambda value. - [Test] - public void CanSetLambda([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetLambda(double lambda) { new Exponential(1.0) { @@ -104,8 +115,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mean. /// /// Lambda value. - [Test] - public void ValidateMean([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMean(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(1.0 / lambda, n.Mean); @@ -115,8 +130,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate variance. /// /// Lambda value. - [Test] - public void ValidateVariance([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateVariance(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(1.0 / (lambda * lambda), n.Variance); @@ -126,8 +145,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate standard deviation. /// /// Lambda value. - [Test] - public void ValidateStdDev([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateStdDev(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(1.0 / lambda, n.StdDev); @@ -137,8 +160,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate entropy. /// /// Lambda value. - [Test] - public void ValidateEntropy([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateEntropy(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(1.0 - Math.Log(lambda), n.Entropy); @@ -148,8 +175,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate skewness. /// /// Lambda value. - [Test] - public void ValidateSkewness([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateSkewness(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(2.0, n.Skewness); @@ -159,8 +190,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mode. /// /// Lambda value. - [Test] - public void ValidateMode([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMode(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(0.0, n.Mode); @@ -170,8 +205,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate median. /// /// Lambda value. - [Test] - public void ValidateMedian([Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMedian(double lambda) { var n = new Exponential(lambda); Assert.AreEqual(Math.Log(2.0) / lambda, n.Median); @@ -202,10 +241,27 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lambda value. /// Input X value. - [Test, Sequential] - public void ValidateDensity( - [Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double x) + [TestCase(0.0, 0.0)] + [TestCase(0.1, 0.0)] + [TestCase(1.0, 0.0)] + [TestCase(10.0, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.0, Double.PositiveInfinity)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensity(double lambda, double x) { var n = new Exponential(lambda); if (x >= 0) @@ -223,10 +279,27 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lambda value. /// Input X value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double x) + [TestCase(0.0, 0.0)] + [TestCase(0.1, 0.0)] + [TestCase(1.0, 0.0)] + [TestCase(10.0, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.0, Double.PositiveInfinity)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensityLn(double lambda, double x) { var n = new Exponential(lambda); Assert.AreEqual(Math.Log(lambda) - (lambda * x), n.DensityLn(x)); @@ -258,10 +331,27 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Lambda value. /// Input X value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double lambda, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double x) + [TestCase(0.0, 0.0)] + [TestCase(0.1, 0.0)] + [TestCase(1.0, 0.0)] + [TestCase(10.0, 0.0)] + [TestCase(Double.PositiveInfinity, 0.0)] + [TestCase(0.0, 0.1)] + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.0, 1.0)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.0, Double.PositiveInfinity)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double lambda, double x) { var n = new Exponential(lambda); if (x >= 0.0) diff --git a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs index 84186d6a..916f3902 100644 --- a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,10 +51,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test] - public void CanCreateFisherSnedecor( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double d2) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void CanCreateFisherSnedecor(double d1, double d2) { var n = new FisherSnedecor(d1, d2); Assert.AreEqual(d1, n.DegreeOfFreedom1); @@ -66,10 +75,23 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test, Sequential] - public void FisherSnedecorCreateFailsWithBadParameters( - [Values(Double.NaN, 0.0, -1.0, -10.0, Double.NaN, 0.0, -1.0, -10.0, Double.NaN, 0.0, -1.0, -10.0, Double.NaN, 0.0, -1.0, -10.0)] double d1, - [Values(Double.NaN, Double.NaN, Double.NaN, Double.NaN, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -10.0, -10.0, -10.0, -10.0)] double d2) + [TestCase(Double.NaN, Double.NaN)] + [TestCase(0.0, Double.NaN)] + [TestCase(-1.0, Double.NaN)] + [TestCase(-10.0, Double.NaN)] + [TestCase(Double.NaN, 0.0)] + [TestCase(0.0, 0.0)] + [TestCase(-1.0, 0.0)] + [TestCase(-10.0, 0.0)] + [TestCase(Double.NaN, -1.0)] + [TestCase(0.0, -1.0)] + [TestCase(-1.0, -1.0)] + [TestCase(-10.0, -1.0)] + [TestCase(Double.NaN, -10.0)] + [TestCase(0.0, -10.0)] + [TestCase(-1.0, -10.0)] + [TestCase(-10.0, -10.0)] + public void FisherSnedecorCreateFailsWithBadParameters(double d1, double d2) { Assert.Throws(() => new FisherSnedecor(d1, d2)); } @@ -88,8 +110,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set degree of freedom 1. /// /// Degrees of freedom 1 - [Test] - public void CanSetDegreeOfFreedom1([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double d1) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetDegreeOfFreedom1(double d1) { new FisherSnedecor(1.0, 2.0) { @@ -111,8 +136,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set degree of freedom 2. /// /// Degrees of freedom 2 - [Test] - public void CanSetDegreeOfFreedom2([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double d2) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetDegreeOfFreedom2(double d2) { new FisherSnedecor(1.0, 2.0) { @@ -135,10 +163,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test, Sequential] - public void ValidateMean( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double d2) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMean(double d1, double d2) { var n = new FisherSnedecor(d1, d2); if (d2 > 2) @@ -152,10 +189,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test, Sequential] - public void ValidateVariance( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double d2) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateVariance(double d1, double d2) { var n = new FisherSnedecor(d1, d2); if (d2 > 4) @@ -169,10 +215,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test, Sequential] - public void ValidateStdDev( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double d2) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateStdDev(double d1, double d2) { var n = new FisherSnedecor(d1, d2); if (d2 > 4) @@ -196,10 +251,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test, Sequential] - public void ValidateSkewness( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double d2) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(Double.PositiveInfinity, 0.1)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(Double.PositiveInfinity, 1.0)] + [TestCase(0.1, Double.PositiveInfinity)] + [TestCase(1.0, Double.PositiveInfinity)] + [TestCase(10.0, Double.PositiveInfinity)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateSkewness(double d1, double d2) { var n = new FisherSnedecor(d1, d2); if (d2 > 6) @@ -213,10 +277,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Degrees of freedom 1 /// Degrees of freedom 2 - [Test, Sequential] - public void ValidateMode( - [Values(0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 100.0, 100.0, 100.0, 100.0)] double d2) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 0.1)] + [TestCase(10.0, 0.1)] + [TestCase(100.0, 0.1)] + [TestCase(0.1, 1.0)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 1.0)] + [TestCase(100.0, 1.0)] + [TestCase(0.1, 100.0)] + [TestCase(1.0, 100.0)] + [TestCase(10.0, 100.0)] + [TestCase(100.0, 100.0)] + public void ValidateMode(double d1, double d2) { var n = new FisherSnedecor(d1, d2); if (d1 > 2) @@ -261,11 +334,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Degrees of freedom 1 /// Degrees of freedom 2 /// Input X value - [Test, Sequential] - public void ValidateDensity( - [Values(0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 100.0, 100.0, 100.0, 100.0, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 100.0, 100.0, 100.0, 100.0)] double d2, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0)] double x) + [TestCase(0.1, 0.1, 1.0)] + [TestCase(1.0, 0.1, 1.0)] + [TestCase(10.0, 0.1, 1.0)] + [TestCase(100.0, 0.1, 1.0)] + [TestCase(0.1, 1.0, 1.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 1.0, 1.0)] + [TestCase(100.0, 1.0, 1.0)] + [TestCase(0.1, 100.0, 1.0)] + [TestCase(1.0, 100.0, 1.0)] + [TestCase(10.0, 100.0, 1.0)] + [TestCase(100.0, 100.0, 1.0)] + [TestCase(0.1, 0.1, 10.0)] + [TestCase(1.0, 0.1, 10.0)] + [TestCase(10.0, 0.1, 10.0)] + [TestCase(100.0, 0.1, 10.0)] + [TestCase(0.1, 1.0, 10.0)] + [TestCase(1.0, 1.0, 10.0)] + [TestCase(10.0, 1.0, 10.0)] + [TestCase(100.0, 1.0, 10.0)] + [TestCase(0.1, 100.0, 10.0)] + [TestCase(1.0, 100.0, 10.0)] + [TestCase(10.0, 100.0, 10.0)] + [TestCase(100.0, 100.0, 10.0)] + public void ValidateDensity(double d1, double d2, double x) { var n = new FisherSnedecor(d1, d2); Assert.AreEqual(Math.Sqrt(Math.Pow(d1 * x, d1) * Math.Pow(d2, d2) / Math.Pow((d1 * x) + d2, d1 + d2)) / (x * SpecialFunctions.Beta(d1 / 2.0, d2 / 2.0)), n.Density(x)); @@ -277,11 +370,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Degrees of freedom 1 /// Degrees of freedom 2 /// Input X value - [Test, Sequential] - public void ValidateDensityLn( - [Values(0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0, 0.1, 1.0, 10.0, 100.0)] double d1, - [Values(0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 100.0, 100.0, 100.0, 100.0, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 100.0, 100.0, 100.0, 100.0)] double d2, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0)] double x) + [TestCase(0.1, 0.1, 1.0)] + [TestCase(1.0, 0.1, 1.0)] + [TestCase(10.0, 0.1, 1.0)] + [TestCase(100.0, 0.1, 1.0)] + [TestCase(0.1, 1.0, 1.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 1.0, 1.0)] + [TestCase(100.0, 1.0, 1.0)] + [TestCase(0.1, 100.0, 1.0)] + [TestCase(1.0, 100.0, 1.0)] + [TestCase(10.0, 100.0, 1.0)] + [TestCase(100.0, 100.0, 1.0)] + [TestCase(0.1, 0.1, 10.0)] + [TestCase(1.0, 0.1, 10.0)] + [TestCase(10.0, 0.1, 10.0)] + [TestCase(100.0, 0.1, 10.0)] + [TestCase(0.1, 1.0, 10.0)] + [TestCase(1.0, 1.0, 10.0)] + [TestCase(10.0, 1.0, 10.0)] + [TestCase(100.0, 1.0, 10.0)] + [TestCase(0.1, 100.0, 10.0)] + [TestCase(1.0, 100.0, 10.0)] + [TestCase(10.0, 100.0, 10.0)] + [TestCase(100.0, 100.0, 10.0)] + public void ValidateDensityLn(double d1, double d2, double x) { var n = new FisherSnedecor(d1, d2); Assert.AreEqual(Math.Log(n.Density(x)), n.DensityLn(x)); @@ -314,11 +427,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Degrees of freedom 1 /// Degrees of freedom 2 /// Input X value - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.1, 1.0, 10.0, 0.1, 1.0, 10.0, 0.1, 1.0, 10.0, 0.1, 1.0, 10.0)] double d1, - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0)] double d2, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0)] double x) + [TestCase(0.1, 0.1, 1.0)] + [TestCase(1.0, 0.1, 1.0)] + [TestCase(10.0, 0.1, 1.0)] + [TestCase(0.1, 1.0, 1.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 1.0, 1.0)] + [TestCase(0.1, 0.1, 10.0)] + [TestCase(1.0, 0.1, 10.0)] + [TestCase(10.0, 0.1, 10.0)] + [TestCase(0.1, 1.0, 10.0)] + [TestCase(1.0, 1.0, 10.0)] + [TestCase(10.0, 1.0, 10.0)] + public void ValidateCumulativeDistribution(double d1, double d2, double x) { var n = new FisherSnedecor(d1, d2); Assert.AreEqual(SpecialFunctions.BetaRegularized(d1 / 2.0, d2 / 2.0, d1 * x / (d2 + (x * d1))), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs index b02ad7e8..abf5269d 100644 --- a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Inverse scale value. - [Test, Sequential] - public void CanCreateGamma([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale) + [TestCase(0.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(10.0, 1.0)] + [TestCase(10.0, Double.PositiveInfinity)] + public void CanCreateGamma(double shape, double invScale) { var n = new Gamma(shape, invScale); Assert.AreEqual(shape, n.Shape); @@ -64,8 +69,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Inverse scale value. - [Test, Sequential] - public void GammaCreateFailsWithBadParameters([Values(1.0, 1.0, -1.0, -1.0, -1.0)] double shape, [Values(Double.NaN, -1.0, 1.0, -1.0, Double.NaN)] double invScale) + [TestCase(1.0, Double.NaN)] + [TestCase(1.0, -1.0)] + [TestCase(-1.0, 1.0)] + [TestCase(-1.0, -1.0)] + [TestCase(-1.0, Double.NaN)] + public void GammaCreateFailsWithBadParameters(double shape, double invScale) { Assert.Throws(() => new Gamma(shape, invScale)); } @@ -75,8 +84,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Inverse scale value. - [Test, Sequential] - public void CanCreateGammaWithShapeInvScale([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale) + [TestCase(0.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(10.0, 1.0)] + [TestCase(10.0, Double.PositiveInfinity)] + public void CanCreateGammaWithShapeInvScale(double shape, double invScale) { var n = Gamma.WithShapeInvScale(shape, invScale); Assert.AreEqual(shape, n.Shape); @@ -88,8 +102,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Scale value. - [Test, Sequential] - public void CanCreateGammaWithShapeScale([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double scale) + [TestCase(0.0, 0.0)] + [TestCase(1.0, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(10.0, 1.0)] + [TestCase(10.0, Double.PositiveInfinity)] + public void CanCreateGammaWithShapeScale(double shape, double scale) { var n = Gamma.WithShapeScale(shape, scale); Assert.AreEqual(shape, n.Shape); @@ -110,8 +129,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set shape. /// /// Shape value. - [Test] - public void CanSetShape([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetShape(double shape) { new Gamma(1.0, 1.0) { @@ -133,8 +157,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Gamma(1.0, 1.0) { @@ -156,8 +185,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set inverse scale. /// /// Inverse scale value. - [Test] - public void CanSetInvScale([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double invScale) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetInvScale(double invScale) { new Gamma(1.0, 1.0) { @@ -181,8 +215,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateMean([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 10.0, 1.0, 1.0, 10.0, 10.0)] double mean) + [TestCase(0.0, 0.0, Double.NaN)] + [TestCase(1.0, 0.1, 10.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 1.0)] + [TestCase(10.0, 1.0, 10.0)] + [TestCase(10.0, Double.PositiveInfinity, 10.0)] + public void ValidateMean(double shape, double invScale, double mean) { var n = new Gamma(shape, invScale); Assert.AreEqual(mean, n.Mean); @@ -194,8 +233,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateVariance([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 100.0, 1.0, 0.1, 10.0, 0.0)] double var) + [TestCase(0.0, 0.0, Double.NaN)] + [TestCase(1.0, 0.1, 100.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 0.1)] + [TestCase(10.0, 1.0, 10.0)] + [TestCase(10.0, Double.PositiveInfinity, 0.0)] + public void ValidateVariance(double shape, double invScale, double var) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(var, n.Variance, 15); @@ -207,8 +251,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateStdDev([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 10.0, 1.0, 0.31622776601683794197697302588502426416723164097476643, 3.1622776601683793319988935444327185337195551393252168, 0.0)] double sdev) + [TestCase(0.0, 0.0, Double.NaN)] + [TestCase(1.0, 0.1, 10.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 0.31622776601683794197697302588502426416723164097476643)] + [TestCase(10.0, 1.0, 3.1622776601683793319988935444327185337195551393252168)] + [TestCase(10.0, Double.PositiveInfinity, 0.0)] + public void ValidateStdDev(double shape, double invScale, double sdev) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(sdev, n.StdDev, 15); @@ -220,8 +269,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateEntropy([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 3.3025850929940456285068402234265387271634735938763824, 1.0, 0.23346908548693395836262094490967812177376750477943892, 2.5360541784809796423806123995940423293748689934081866, 0.0)] double entropy) + [TestCase(0.0, 0.0, Double.NaN)] + [TestCase(1.0, 0.1, 3.3025850929940456285068402234265387271634735938763824)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 0.23346908548693395836262094490967812177376750477943892)] + [TestCase(10.0, 1.0, 2.5360541784809796423806123995940423293748689934081866)] + [TestCase(10.0, Double.PositiveInfinity, 0.0)] + public void ValidateEntropy(double shape, double invScale, double entropy) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(entropy, n.Entropy, 13); @@ -233,8 +287,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateSkewness([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 2.0, 2.0, 0.63245553203367586639977870888654370674391102786504337, 0.63245553203367586639977870888654370674391102786504337, 0.0)] double skewness) + [TestCase(0.0, 0.0, Double.NaN)] + [TestCase(1.0, 0.1, 2.0)] + [TestCase(1.0, 1.0, 2.0)] + [TestCase(10.0, 10.0, 0.63245553203367586639977870888654370674391102786504337)] + [TestCase(10.0, 1.0, 0.63245553203367586639977870888654370674391102786504337)] + [TestCase(10.0, Double.PositiveInfinity, 0.0)] + public void ValidateSkewness(double shape, double invScale, double skewness) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(skewness, n.Skewness, 15); @@ -246,8 +305,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Inverse scale value. /// Expected value. - [Test, Sequential] - public void ValidateMode([Values(0.0, 1.0, 1.0, 10.0, 10.0, 10.0)] double shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale, [Values(Double.NaN, 0.0, 0.0, 0.9, 9.0, 10.0)] double mode) + [TestCase(0.0, 0.0, Double.NaN)] + [TestCase(1.0, 0.1, 0.0)] + [TestCase(1.0, 1.0, 0.0)] + [TestCase(10.0, 10.0, 0.9)] + [TestCase(10.0, 1.0, 9.0)] + [TestCase(10.0, Double.PositiveInfinity, 10.0)] + public void ValidateMode(double shape, double invScale, double mode) { var n = new Gamma(shape, invScale); Assert.AreEqual(mode, n.Mode); @@ -290,12 +354,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Inverse scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensity( - [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(0.0, 0.0, 0.0, 0.10000000000000000555111512312578270211815834045410156, 0.090483741803595961836995913651194571475319347018875963, 0.036787944117144234201693506390001264039984687455876246, 1.0, 0.36787944117144232159552377016146086744581113103176804, 0.000045399929762484851535591515560550610237918088866564953, 0.0, 1.2511003572113329898476497894772544708420990097708588, 1.0251532120868705806216092933926141802686541811003037e-30, 0.0, 0.0000010137771196302974029859010421116095333052555418644397, 0.12511003572113329898476497894772544708420990097708601, 0.0, 0.0, Double.PositiveInfinity)] double pdf) + [TestCase(0, 0.0, 0.0, 0.0)] + [TestCase(0, 0.0, 1.0, 0.0)] + [TestCase(0, 0.0, 10.0, 0.0)] + [TestCase(1, 0.1, 0.0, 0.10000000000000000555111512312578270211815834045410156)] + [TestCase(1, 0.1, 1.0, 0.090483741803595961836995913651194571475319347018875963)] + [TestCase(1, 0.1, 10.0, 0.036787944117144234201693506390001264039984687455876246)] + [TestCase(1, 1.0, 0.0, 1.0)] + [TestCase(1, 1.0, 1.0, 0.36787944117144232159552377016146086744581113103176804)] + [TestCase(1, 1.0, 10.0, 0.000045399929762484851535591515560550610237918088866564953)] + [TestCase(10, 10.0, 0.0, 0.0)] + [TestCase(10, 10.0, 1.0, 1.2511003572113329898476497894772544708420990097708588)] + [TestCase(10, 10.0, 10.0, 1.0251532120868705806216092933926141802686541811003037e-30)] + [TestCase(10, 1.0, 0.0, 0.0)] + [TestCase(10, 1.0, 1.0, 0.0000010137771196302974029859010421116095333052555418644397)] + [TestCase(10, 1.0, 10.0, 0.12511003572113329898476497894772544708420990097708601)] + [TestCase(10, Double.PositiveInfinity, 0.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 10.0, Double.PositiveInfinity)] + public void ValidateDensity(int shape, double invScale, double x, double pdf) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(pdf, n.Density(x), 14); @@ -308,12 +385,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Inverse scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -2.3025850929940456285068402234265387271634735938763824, -2.402585092994045634057955346552321429281631934330484, -3.3025850929940456285068402234265387271634735938763824, 0.0, -1.0, -10.0, Double.NegativeInfinity, 0.22402344985898722897219667227693591172986563062456522, -69.052710713194601614865880235563786219860220971716511, Double.NegativeInfinity, -13.801827480081469611207717874566706164281149255663166, -2.0785616431350584550457947824074282958712358580042068, Double.NegativeInfinity, Double.NegativeInfinity, Double.PositiveInfinity)] double pdfln) + [TestCase(0, 0.0, 0.0, Double.NegativeInfinity)] + [TestCase(0, 0.0, 1.0, Double.NegativeInfinity)] + [TestCase(0, 0.0, 10.0, Double.NegativeInfinity)] + [TestCase(1, 0.1, 0.0, -2.3025850929940456285068402234265387271634735938763824)] + [TestCase(1, 0.1, 1.0, -2.402585092994045634057955346552321429281631934330484)] + [TestCase(1, 0.1, 10.0, -3.3025850929940456285068402234265387271634735938763824)] + [TestCase(1, 1.0, 0.0, 0.0)] + [TestCase(1, 1.0, 1.0, -1.0)] + [TestCase(1, 1.0, 10.0, -10.0)] + [TestCase(10, 10.0, 0.0, Double.NegativeInfinity)] + [TestCase(10, 10.0, 1.0, 0.22402344985898722897219667227693591172986563062456522)] + [TestCase(10, 10.0, 10.0, -69.052710713194601614865880235563786219860220971716511)] + [TestCase(10, 1.0, 0.0, Double.NegativeInfinity)] + [TestCase(10, 1.0, 1.0, -13.801827480081469611207717874566706164281149255663166)] + [TestCase(10, 1.0, 10.0, -2.0785616431350584550457947824074282958712358580042068)] + [TestCase(10, Double.PositiveInfinity, 0.0, Double.NegativeInfinity)] + [TestCase(10, Double.PositiveInfinity, 1.0, Double.NegativeInfinity)] + [TestCase(10, Double.PositiveInfinity, 10.0, Double.PositiveInfinity)] + public void ValidateDensityLn(int shape, double invScale, double x, double pdfln) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(pdfln, n.DensityLn(x), 14); @@ -384,12 +474,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Inverse scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, - [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(0.0, 0.0, 0.0, 0.0, 0.095162581964040431858607615783064404690935346242622848, 0.63212055882855767840447622983853913255418886896823196, 0.0, 0.63212055882855767840447622983853913255418886896823196, 0.99995460007023751514846440848443944938976208191113396, 0.0, 0.54207028552814779168583514294066541824736464003242184, 0.99999999999999999999999999999988746526039157266114706, 0.0, 0.00000011142547833872067735305068724025236288094949815466035, 0.54207028552814779168583514294066541824736464003242184, 0.0, 0.0, 1.0)] double cdf) + [TestCase(0, 0.0, 0.0, 0.0)] + [TestCase(0, 0.0, 1.0, 0.0)] + [TestCase(0, 0.0, 10.0, 0.0)] + [TestCase(1, 0.1, 0.0, 0.0)] + [TestCase(1, 0.1, 1.0, 0.095162581964040431858607615783064404690935346242622848)] + [TestCase(1, 0.1, 10.0, 0.63212055882855767840447622983853913255418886896823196)] + [TestCase(1, 1.0, 0.0, 0.0)] + [TestCase(1, 1.0, 1.0, 0.63212055882855767840447622983853913255418886896823196)] + [TestCase(1, 1.0, 10.0, 0.99995460007023751514846440848443944938976208191113396)] + [TestCase(10, 10.0, 0.0, 0.0)] + [TestCase(10, 10.0, 1.0, 0.54207028552814779168583514294066541824736464003242184)] + [TestCase(10, 10.0, 10.0, 0.99999999999999999999999999999988746526039157266114706)] + [TestCase(10, 1.0, 0.0, 0.0)] + [TestCase(10, 1.0, 1.0, 0.00000011142547833872067735305068724025236288094949815466035)] + [TestCase(10, 1.0, 10.0, 0.54207028552814779168583514294066541824736464003242184)] + [TestCase(10, Double.PositiveInfinity, 0.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 1.0, 0.0)] + [TestCase(10, Double.PositiveInfinity, 10.0, 1.0)] + public void ValidateCumulativeDistribution(int shape, double invScale, double x, double cdf) { var n = new Gamma(shape, invScale); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 14); diff --git a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs index 7927c0dc..a8744cf5 100644 --- a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// A parameter. /// B parameter. - [Test, Combinatorial] - public void CanCreateInverseGamma([Values(0.1, 1.0, Double.PositiveInfinity)] double a, [Values(0.1, 1.0, Double.PositiveInfinity)] double b) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void CanCreateInverseGamma(double a, double b) { var n = new InverseGamma(a, b); Assert.AreEqual(a, n.Shape); @@ -64,8 +66,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// A parameter. /// B parameter. - [Test, Sequential] - public void InverseGammaCreateFailsWithBadParameters([Values(0.0, -1.0, -100.0, Double.NegativeInfinity, Double.NaN, 1.0, 1.0, 1.0, 1.0, 1.0)] double a, [Values(1.0, 1.0, 1.0, 1.0, 1.0, 0.0, -1.0, -100.0, Double.NegativeInfinity, Double.NaN)] double b) + [TestCase(0.0, 1.0)] + [TestCase(-1.0, 1.0)] + [TestCase(-100.0, 1.0)] + [TestCase(Double.NegativeInfinity, 1.0)] + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, 0.0)] + [TestCase(1.0, -1.0)] + [TestCase(1.0, -100.0)] + [TestCase(1.0, Double.NegativeInfinity)] + [TestCase(1.0, Double.NaN)] + public void InverseGammaCreateFailsWithBadParameters(double a, double b) { Assert.Throws(() => new InverseGamma(a, b)); } @@ -84,8 +95,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set A. /// /// A parameter. - [Test] - public void CanSetA([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double a) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetA(double a) { new InverseGamma(1.0, 1.0) { @@ -97,8 +111,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set A fails with non-positive value. /// /// A parameter. - [Test] - public void SetAFailsWithNonPositiveA([Values(-1.0, -0.0, 0.0)] double a) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetAFailsWithNonPositiveA(double a) { var n = new InverseGamma(1.0, 1.0); Assert.Throws(() => n.Shape = a); @@ -108,8 +124,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set B. /// /// B parameter. - [Test] - public void CanSetB([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double b) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetB(double b) { new InverseGamma(1.0, 1.0) { @@ -121,8 +140,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set B fails with non-positive value. /// /// B parameter. - [Test] - public void SetBFailsWithNonPositiveB([Values(-1.0, -0.0, 0.0)] double b) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetBFailsWithNonPositiveB(double b) { var n = new InverseGamma(1.0, 1.0); Assert.Throws(() => n.Scale = b); @@ -133,8 +154,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// A parameter. /// B parameter. - [Test, Combinatorial] - public void ValidateMean([Values(0.1, 1.0, Double.PositiveInfinity)] double a, [Values(0.1, 1.0, Double.PositiveInfinity)] double b) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMean(double a, double b) { var n = new InverseGamma(a, b); if (a > 1) @@ -148,8 +171,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// A parameter. /// B parameter. - [Test, Combinatorial] - public void ValidateVariance([Values(0.1, 1.0, Double.PositiveInfinity)] double a, [Values(0.1, 1.0, Double.PositiveInfinity)] double b) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateVariance(double a, double b) { var n = new InverseGamma(a, b); if (a > 2) @@ -163,8 +188,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// A parameter. /// B parameter. - [Test, Combinatorial] - public void ValidateStdDev([Values(0.1, 1.0, Double.PositiveInfinity)] double a, [Values(0.1, 1.0, Double.PositiveInfinity)] double b) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateStdDev(double a, double b) { var n = new InverseGamma(a, b); if (a > 2) @@ -178,8 +205,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// A parameter. /// B parameter. - [Test, Combinatorial] - public void ValidateMode([Values(0.1, 1.0, Double.PositiveInfinity)] double a, [Values(0.1, 1.0, Double.PositiveInfinity)] double b) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMode(double a, double b) { var n = new InverseGamma(a, b); Assert.AreEqual(b / (a + 1.0), n.Mode); @@ -221,11 +250,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// A parameter. /// B parameter. /// Input X valuer. - [Test, Sequential] - public void ValidateDensity( - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double a, - [Values(0.1, 1.0, Double.PositiveInfinity, 0.1, 1.0, Double.PositiveInfinity, 0.1, 1.0, Double.PositiveInfinity)] double b, - [Values(1.2, 2.0, 1.1, 1.5, 1.2, 1.5, 5.0, 2.5, 1.0)] double x) + [TestCase(0.1, 0.1, 1.2)] + [TestCase(0.1, 1.0, 2.0)] + [TestCase(0.1, Double.PositiveInfinity, 1.1)] + [TestCase(1.0, 0.1, 1.5)] + [TestCase(1.0, 1.0, 1.2)] + [TestCase(1.0, Double.PositiveInfinity, 1.5)] + [TestCase(Double.PositiveInfinity, 0.1, 5.0)] + [TestCase(Double.PositiveInfinity, 1.0, 2.5)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, 1.0)] + public void ValidateDensity(double a, double b, double x) { var n = new InverseGamma(a, b); if (x >= 0) @@ -244,11 +278,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// A parameter. /// B parameter. /// Input X valuer. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double a, - [Values(0.1, 1.0, Double.PositiveInfinity, 0.1, 1.0, Double.PositiveInfinity, 0.1, 1.0, Double.PositiveInfinity)] double b, - [Values(1.2, 2.0, 1.1, 1.5, 1.2, 1.5, 5.0, 2.5, 1.0)] double x) + [TestCase(0.1, 0.1, 1.2)] + [TestCase(0.1, 1.0, 2.0)] + [TestCase(0.1, Double.PositiveInfinity, 1.1)] + [TestCase(1.0, 0.1, 1.5)] + [TestCase(1.0, 1.0, 1.2)] + [TestCase(1.0, Double.PositiveInfinity, 1.5)] + [TestCase(Double.PositiveInfinity, 0.1, 5.0)] + [TestCase(Double.PositiveInfinity, 1.0, 2.5)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, 1.0)] + public void ValidateDensityLn(double a, double b, double x) { var n = new InverseGamma(a, b); Assert.AreEqual(Math.Log(n.Density(x)), n.DensityLn(x)); @@ -281,11 +320,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// A parameter. /// B parameter. /// Input X valuer. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double a, - [Values(0.1, 1.0, Double.PositiveInfinity, 0.1, 1.0, Double.PositiveInfinity, 0.1, 1.0, Double.PositiveInfinity)] double b, - [Values(1.2, 2.0, 1.1, 1.5, 1.2, 1.5, 5.0, 2.5, 1.0)] double x) + [TestCase(0.1, 0.1, 1.2)] + [TestCase(0.1, 1.0, 2.0)] + [TestCase(0.1, Double.PositiveInfinity, 1.1)] + [TestCase(1.0, 0.1, 1.5)] + [TestCase(1.0, 1.0, 1.2)] + [TestCase(1.0, Double.PositiveInfinity, 1.5)] + [TestCase(Double.PositiveInfinity, 0.1, 5.0)] + [TestCase(Double.PositiveInfinity, 1.0, 2.5)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, 1.0)] + public void ValidateCumulativeDistribution(double a, double b, double x) { var n = new InverseGamma(a, b); Assert.AreEqual(SpecialFunctions.GammaUpperRegularized(a, b / x), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs index cdda4fe1..415b522e 100644 --- a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -62,8 +62,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void CanCreateLaplace([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void CanCreateLaplace(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Location); @@ -84,8 +89,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set location. /// /// Location value. - [Test] - public void CanSetLocation([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location) + [TestCase(Double.NegativeInfinity)] + [TestCase(-5.0 - 1.0)] + [TestCase(0.0)] + [TestCase(1.0)] + [TestCase(5.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetLocation(double location) { new Laplace { @@ -107,8 +117,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Laplace { @@ -120,8 +133,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set scale fails with negative value. /// /// Scale value. - [Test] - public void SetScaleFailsWithNegativeScale([Values(0.0, -1.0, -5.0, Double.NegativeInfinity, Double.NaN)] double scale) + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-5.0)] + [TestCase(Double.NegativeInfinity)] + [TestCase(Double.NaN)] + public void SetScaleFailsWithNegativeScale(double scale) { var n = new Laplace(); Assert.Throws(() => n.Scale = scale); @@ -132,8 +149,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateMean([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMean(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Mean); @@ -144,8 +166,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateVariance([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateVariance(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(2.0 * scale * scale, n.Variance); @@ -156,8 +183,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateStdDev([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateStdDev(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Sqrt(2.0) * scale, n.StdDev); @@ -168,8 +200,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateEntropy([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateEntropy(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Log(2.0 * Constants.E * scale), n.Entropy); @@ -180,8 +217,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateSkewness([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateSkewness(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(0.0, n.Skewness); @@ -192,8 +234,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateMode([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMode(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Mode); @@ -204,8 +251,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Location value. /// Scale value. - [Test, Combinatorial] - public void ValidateMedian([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(Double.NegativeInfinity, 0.1)] + [TestCase(-5.0 - 1.0, 1.0)] + [TestCase(0.0, 5.0)] + [TestCase(1.0, 7.0)] + [TestCase(5.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMedian(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Median); @@ -237,11 +289,28 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Input X value. - [Test, Sequential] - public void ValidateDensity( - [Values(0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity)] double location, - [Values(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double scale, - [Values(1.5, 2.8, -5.4, -4.9, 2.0, 5.5, -0.0, Double.PositiveInfinity, 5.0, -1.0, -1.0, 2.5, 2.0, 15.0, 89.3, -0.1, 0.1, -6.1, -10.0, 2.0, -5.1)] double x) + [TestCase(0.0, 0.1, 1.5)] + [TestCase(1.0, 0.1, 2.8)] + [TestCase(-1.0, 0.1, -5.4)] + [TestCase(5.0, 0.1, -4.9)] + [TestCase(-5.0, 0.1, 2.0)] + [TestCase(Double.PositiveInfinity, 0.1, 5.5)] + [TestCase(Double.NegativeInfinity, 0.1, -0.0)] + [TestCase(0.0, 1.0, Double.PositiveInfinity)] + [TestCase(1.0, 1.0, 5.0)] + [TestCase(-1.0, 1.0, -1.0)] + [TestCase(5.0, 1.0, -1.0)] + [TestCase(-5.0, 1.0, 2.5)] + [TestCase(Double.PositiveInfinity, 1.0, 2.0)] + [TestCase(Double.NegativeInfinity, 1.0, 15.0)] + [TestCase(0.0, Double.PositiveInfinity, 89.3)] + [TestCase(1.0, Double.PositiveInfinity, -0.1)] + [TestCase(-1.0, Double.PositiveInfinity, 0.1)] + [TestCase(5.0, Double.PositiveInfinity, -6.1)] + [TestCase(-5.0, Double.PositiveInfinity, -10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, 2.0)] + [TestCase(Double.NegativeInfinity, Double.PositiveInfinity, -5.1)] + public void ValidateDensity(double location, double scale, double x) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Exp(-Math.Abs(x - location) / scale) / (2.0 * scale), n.Density(x)); @@ -253,11 +322,28 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Input X value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity)] double location, - [Values(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double scale, - [Values(1.5, 2.8, -5.4, -4.9, 2.0, 5.5, -0.0, Double.PositiveInfinity, 5.0, -1.0, -1.0, 2.5, 2.0, 15.0, 89.3, -0.1, 0.1, -6.1, -10.0, 2.0, -5.1)] double x) + [TestCase(0.0, 0.1, 1.5)] + [TestCase(1.0, 0.1, 2.8)] + [TestCase(-1.0, 0.1, -5.4)] + [TestCase(5.0, 0.1, -4.9)] + [TestCase(-5.0, 0.1, 2.0)] + [TestCase(Double.PositiveInfinity, 0.1, 5.5)] + [TestCase(Double.NegativeInfinity, 0.1, -0.0)] + [TestCase(0.0, 1.0, Double.PositiveInfinity)] + [TestCase(1.0, 1.0, 5.0)] + [TestCase(-1.0, 1.0, -1.0)] + [TestCase(5.0, 1.0, -1.0)] + [TestCase(-5.0, 1.0, 2.5)] + [TestCase(Double.PositiveInfinity, 1.0, 2.0)] + [TestCase(Double.NegativeInfinity, 1.0, 15.0)] + [TestCase(0.0, Double.PositiveInfinity, 89.3)] + [TestCase(1.0, Double.PositiveInfinity, -0.1)] + [TestCase(-1.0, Double.PositiveInfinity, 0.1)] + [TestCase(5.0, Double.PositiveInfinity, -6.1)] + [TestCase(-5.0, Double.PositiveInfinity, -10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, 2.0)] + [TestCase(Double.NegativeInfinity, Double.PositiveInfinity, -5.1)] + public void ValidateDensityLn(double location, double scale, double x) { var n = new Laplace(location, scale); Assert.AreEqual(-Math.Log(2.0 * scale) - (Math.Abs(x - location) / scale), n.DensityLn(x)); @@ -290,11 +376,28 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Input X value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity)] double location, - [Values(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double scale, - [Values(1.5, 2.8, -5.4, -4.9, 2.0, 5.5, -0.0, Double.PositiveInfinity, 5.0, -1.0, -1.0, 2.5, 2.0, 15.0, 89.3, -0.1, 0.1, -6.1, -10.0, 2.0, -5.1)] double x) + [TestCase(0.0, 0.1, 1.5)] + [TestCase(1.0, 0.1, 2.8)] + [TestCase(-1.0, 0.1, -5.4)] + [TestCase(5.0, 0.1, -4.9)] + [TestCase(-5.0, 0.1, 2.0)] + [TestCase(Double.PositiveInfinity, 0.1, 5.5)] + [TestCase(Double.NegativeInfinity, 0.1, -0.0)] + [TestCase(0.0, 1.0, Double.PositiveInfinity)] + [TestCase(1.0, 1.0, 5.0)] + [TestCase(-1.0, 1.0, -1.0)] + [TestCase(5.0, 1.0, -1.0)] + [TestCase(-5.0, 1.0, 2.5)] + [TestCase(Double.PositiveInfinity, 1.0, 2.0)] + [TestCase(Double.NegativeInfinity, 1.0, 15.0)] + [TestCase(0.0, Double.PositiveInfinity, 89.3)] + [TestCase(1.0, Double.PositiveInfinity, -0.1)] + [TestCase(-1.0, Double.PositiveInfinity, 0.1)] + [TestCase(5.0, Double.PositiveInfinity, -6.1)] + [TestCase(-5.0, Double.PositiveInfinity, -10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, 2.0)] + [TestCase(Double.NegativeInfinity, Double.PositiveInfinity, -5.1)] + public void ValidateCumulativeDistribution(double location, double scale, double x) { var n = new Laplace(location, scale); Assert.AreEqual(0.5 * (1.0 + (Math.Sign(x - location) * (1.0 - Math.Exp(-Math.Abs(x - location) / scale)))), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs index 9dff5e88..76e6480c 100644 --- a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mu parameter. /// Sigma value. - [Test, Combinatorial] - public void CanCreateLogNormal([Values(0.0, 10.0, -5.0)] double mu, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sigma) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void CanCreateLogNormal(double mu, double sigma) { var n = new LogNormal(mu, sigma); Assert.AreEqual(mu, n.Mu); @@ -64,8 +69,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mu parameter. /// Sigma value. - [Test, Sequential] - public void LogNormalCreateFailsWithBadParameters([Values(Double.NaN, 1.0, Double.NaN, 1.0)] double mu, [Values(1.0, Double.NaN, Double.NaN, -1.0)] double sigma) + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + [TestCase(1.0, -1.0)] + public void LogNormalCreateFailsWithBadParameters(double mu, double sigma) { Assert.Throws(() => new LogNormal(mu, sigma)); } @@ -84,8 +92,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set sigma. /// /// Sigma value. - [Test] - public void CanSetSigma([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double sigma) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetSigma(double sigma) { new LogNormal(1.0, 2.0) { @@ -107,8 +120,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set mu. /// /// Mu parameter. - [Test] - public void CanSetMu([Values(Double.NegativeInfinity, -1.0, -0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double mu) + [TestCase(Double.NegativeInfinity)] + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetMu(double mu) { new LogNormal(1.0, 2.0) { @@ -122,11 +142,32 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Mu parameter. /// Sigma value. /// Expected value. - [Test, Sequential] - public void ValidateEntropy( - [Values(-1.000000, -1.000000, -1.000000, -1.000000, -0.100000, -0.100000, -0.100000, -0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000, 3.0)] double mu, - [Values(0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.0)] double sigma, - [Values(-1.8836465597893728867265104870209210873020761202386, 0.82440364131283712375834285186996677643338789710028, 1.335229265078827806963856948173628711311498693546, 2.1236866254430979764250411929125703716076041932149, -0.9836465597893728922776256101467037894202344606927, 1.7244036413128371182072277287441840743152295566462, 2.2352292650788278014127418250478460091933403530919, 3.0236866254430979708739260697867876694894458527608, -0.7836465597893728811753953638951383851839177797845, 1.9244036413128371293094579749957494785515462375544, 2.4352292650788278125149720712994114134296570340001, 3.223686625443097981976156316038353073725762533669, 0.6163534402106271132734895129790789126979238797614, 3.3244036413128371237583428518699667764333878971003, 3.835229265078827806963856948173628711311498693546, 4.6236866254430979764250411929125703716076041932149, 1.6163534402106271132734895129790789126979238797614, 4.3244036413128371237583428518699667764333878971003, 4.835229265078827806963856948173628711311498693546, 5.6236866254430979764250411929125703716076041932149, 4.6163534402106271132734895129790789126979238797614, 7.3244036413128371237583428518699667764333878971003, 7.835229265078827806963856948173628711311498693546, 8.6236866254430979764250411929125703716076041932149, Double.NegativeInfinity)] double entropy) + [TestCase(-1.000000, 0.100000, -1.8836465597893728867265104870209210873020761202386)] + [TestCase(-1.000000, 1.500000, 0.82440364131283712375834285186996677643338789710028)] + [TestCase(-1.000000, 2.500000, 1.335229265078827806963856948173628711311498693546)] + [TestCase(-1.000000, 5.500000, 2.1236866254430979764250411929125703716076041932149)] + [TestCase(-0.100000, 0.100000, -0.9836465597893728922776256101467037894202344606927)] + [TestCase(-0.100000, 1.500000, 1.7244036413128371182072277287441840743152295566462)] + [TestCase(-0.100000, 2.500000, 2.2352292650788278014127418250478460091933403530919)] + [TestCase(-0.100000, 5.500000, 3.0236866254430979708739260697867876694894458527608)] + [TestCase(0.100000, 0.100000, -0.7836465597893728811753953638951383851839177797845)] + [TestCase(0.100000, 1.500000, 1.9244036413128371293094579749957494785515462375544)] + [TestCase(0.100000, 2.500000, 2.4352292650788278125149720712994114134296570340001)] + [TestCase(0.100000, 5.500000, 3.223686625443097981976156316038353073725762533669)] + [TestCase(1.500000, 0.100000, 0.6163534402106271132734895129790789126979238797614)] + [TestCase(1.500000, 1.500000, 3.3244036413128371237583428518699667764333878971003)] + [TestCase(1.500000, 2.500000, 3.835229265078827806963856948173628711311498693546)] + [TestCase(1.500000, 5.500000, 4.6236866254430979764250411929125703716076041932149)] + [TestCase(2.500000, 0.100000, 1.6163534402106271132734895129790789126979238797614)] + [TestCase(2.500000, 1.500000, 4.3244036413128371237583428518699667764333878971003)] + [TestCase(2.500000, 2.500000, 4.835229265078827806963856948173628711311498693546)] + [TestCase(2.500000, 5.500000, 5.6236866254430979764250411929125703716076041932149)] + [TestCase(5.500000, 0.100000, 4.6163534402106271132734895129790789126979238797614)] + [TestCase(5.500000, 1.500000, 7.3244036413128371237583428518699667764333878971003)] + [TestCase(5.500000, 2.500000, 7.835229265078827806963856948173628711311498693546)] + [TestCase(5.500000, 5.500000, 8.6236866254430979764250411929125703716076041932149)] + [TestCase(3.0, 0.0, Double.NegativeInfinity)] + public void ValidateEntropy(double mu, double sigma, double entropy) { var n = new LogNormal(mu, sigma); AssertHelpers.AlmostEqual(entropy, n.Entropy, 14); @@ -138,11 +179,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Mu parameter. /// Sigma value. /// Expected value. - [Test, Sequential] - public void ValidateSkewness( - [Values(-1.000000, -1.000000, -1.000000, -1.000000, -0.100000, -0.100000, -0.100000, -0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000)] double mu, - [Values(0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000)] double sigma, - [Values(0.30175909933883402945387113824982918009810212213629, 33.46804679732172529147579024311650645764144530123, 11824.007933610287521341659465200553739278936344799, 50829064464591483629.132631635472412625371367420496, 0.30175909933883402945387113824982918009810212213629, 33.46804679732172529147579024311650645764144530123, 11824.007933610287521341659465200553739278936344799, 50829064464591483629.132631635472412625371367420496, 0.30175909933883402945387113824982918009810212213629, 33.46804679732172529147579024311650645764144530123, 11824.007933610287521341659465200553739278936344799, 50829064464591483629.132631635472412625371367420496, 0.30175909933883402945387113824982918009810212213629, 33.46804679732172529147579024311650645764144530123, 11824.007933610287521341659465200553739278936344799, 50829064464591483629.132631635472412625371367420496, 0.30175909933883402945387113824982918009810212213629, 33.46804679732172529147579024311650645764144530123, 11824.007933610287521341659465200553739278936344799, 50829064464591483629.132631635472412625371367420496, 0.30175909933883402945387113824982918009810212213629, 33.46804679732172529147579024311650645764144530123, 11824.007933610287521341659465200553739278936344799, 50829064464591483629.132631635472412625371367420496)] double skewness) + [TestCase(-1.000000, 0.100000, 0.30175909933883402945387113824982918009810212213629)] + [TestCase(-1.000000, 1.500000, 33.46804679732172529147579024311650645764144530123)] + [TestCase(-1.000000, 2.500000, 11824.007933610287521341659465200553739278936344799)] + [TestCase(-1.000000, 5.500000, 50829064464591483629.132631635472412625371367420496)] + [TestCase(-0.100000, 0.100000, 0.30175909933883402945387113824982918009810212213629)] + [TestCase(-0.100000, 1.500000, 33.46804679732172529147579024311650645764144530123)] + [TestCase(-0.100000, 2.500000, 11824.007933610287521341659465200553739278936344799)] + [TestCase(-0.100000, 5.500000, 50829064464591483629.132631635472412625371367420496)] + [TestCase(0.100000, 0.100000, 0.30175909933883402945387113824982918009810212213629)] + [TestCase(0.100000, 1.500000, 33.46804679732172529147579024311650645764144530123)] + [TestCase(0.100000, 2.500000, 11824.007933610287521341659465200553739278936344799)] + [TestCase(0.100000, 5.500000, 50829064464591483629.132631635472412625371367420496)] + [TestCase(1.500000, 0.100000, 0.30175909933883402945387113824982918009810212213629)] + [TestCase(1.500000, 1.500000, 33.46804679732172529147579024311650645764144530123)] + [TestCase(1.500000, 2.500000, 11824.007933610287521341659465200553739278936344799)] + [TestCase(1.500000, 5.500000, 50829064464591483629.132631635472412625371367420496)] + [TestCase(2.500000, 0.100000, 0.30175909933883402945387113824982918009810212213629)] + [TestCase(2.500000, 1.500000, 33.46804679732172529147579024311650645764144530123)] + [TestCase(2.500000, 2.500000, 11824.007933610287521341659465200553739278936344799)] + [TestCase(2.500000, 5.500000, 50829064464591483629.132631635472412625371367420496)] + [TestCase(5.500000, 0.100000, 0.30175909933883402945387113824982918009810212213629)] + [TestCase(5.500000, 1.500000, 33.46804679732172529147579024311650645764144530123)] + [TestCase(5.500000, 2.500000, 11824.007933610287521341659465200553739278936344799)] + [TestCase(5.500000, 5.500000, 50829064464591483629.132631635472412625371367420496)] + public void ValidateSkewness(double mu, double sigma, double skewness) { var n = new LogNormal(mu, sigma); AssertHelpers.AlmostEqual(skewness, n.Skewness, 14); @@ -154,11 +215,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Mu parameter. /// Sigma value. /// Expected value. - [Test, Sequential] - public void ValidateMode( - [Values(-1.000000, -1.000000, -1.000000, -1.000000, -0.100000, -0.100000, -0.100000, -0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000)] double mu, - [Values(0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000)] double sigma, - [Values(0.36421897957152331652213191863106773137983085909534, 0.03877420783172200988689983526759614326014406193602, 0.0007101743888425490635846003705775444086763023873619, 0.000000000000026810038677818032221548731163905979029274677187036, 0.89583413529652823774737070060865897390995185639633, 0.095369162215549610417813418326627245539514227574881, 0.0017467471362611196181003627521060283221112106850165, 0.00000000000006594205454219929159167575814655534255162059017114, 1.0941742837052103542285651753780976842292770841345, 0.11648415777349696821514223131929465848700730137808, 0.0021334817700377079925027678518795817076296484352472, 0.000000000000080541807296590798973741710866097756565304960216803, 4.4370955190036645692996309927420381428715912422597, 0.47236655274101470713804655094326791297020357913648, 0.008651695203120634177071503957250390848166331197708, 0.00000000000032661313427874471360158184468030186601222739665225, 12.061276120444720299113038763305617245808510584994, 1.2840254166877414840734205680624364583362808652815, 0.023517745856009108236151185100432939470067655273072, 0.00000000000088782654784596584473099190326928541185172970391855, 242.2572068579541371904816252345031593584721473492, 25.790339917193062089080107669377221876655268848954, 0.47236655274101470713804655094326791297020357913648, 0.000000000017832472908146389493511850431527026413424899198327)] double mode) + [TestCase(-1.000000, 0.100000, 0.36421897957152331652213191863106773137983085909534)] + [TestCase(-1.000000, 1.500000, 0.03877420783172200988689983526759614326014406193602)] + [TestCase(-1.000000, 2.500000, 0.0007101743888425490635846003705775444086763023873619)] + [TestCase(-1.000000, 5.500000, 0.000000000000026810038677818032221548731163905979029274677187036)] + [TestCase(-0.100000, 0.100000, 0.89583413529652823774737070060865897390995185639633)] + [TestCase(-0.100000, 1.500000, 0.095369162215549610417813418326627245539514227574881)] + [TestCase(-0.100000, 2.500000, 0.0017467471362611196181003627521060283221112106850165)] + [TestCase(-0.100000, 5.500000, 0.00000000000006594205454219929159167575814655534255162059017114)] + [TestCase(0.100000, 0.100000, 1.0941742837052103542285651753780976842292770841345)] + [TestCase(0.100000, 1.500000, 0.11648415777349696821514223131929465848700730137808)] + [TestCase(0.100000, 2.500000, 0.0021334817700377079925027678518795817076296484352472)] + [TestCase(0.100000, 5.500000, 0.000000000000080541807296590798973741710866097756565304960216803)] + [TestCase(1.500000, 0.100000, 4.4370955190036645692996309927420381428715912422597)] + [TestCase(1.500000, 1.500000, 0.47236655274101470713804655094326791297020357913648)] + [TestCase(1.500000, 2.500000, 0.008651695203120634177071503957250390848166331197708)] + [TestCase(1.500000, 5.500000, 0.00000000000032661313427874471360158184468030186601222739665225)] + [TestCase(2.500000, 0.100000, 12.061276120444720299113038763305617245808510584994)] + [TestCase(2.500000, 1.500000, 1.2840254166877414840734205680624364583362808652815)] + [TestCase(2.500000, 2.500000, 0.023517745856009108236151185100432939470067655273072)] + [TestCase(2.500000, 5.500000, 0.00000000000088782654784596584473099190326928541185172970391855)] + [TestCase(5.500000, 0.100000, 242.2572068579541371904816252345031593584721473492)] + [TestCase(5.500000, 1.500000, 25.790339917193062089080107669377221876655268848954)] + [TestCase(5.500000, 2.500000, 0.47236655274101470713804655094326791297020357913648)] + [TestCase(5.500000, 5.500000, 0.000000000017832472908146389493511850431527026413424899198327)] + public void ValidateMode(double mu, double sigma, double mode) { var n = new LogNormal(mu, sigma); Assert.AreEqual(mode, n.Mode); @@ -170,11 +251,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Mu parameter. /// Sigma value. /// Expected value. - [Test, Sequential] - public void ValidateMedian( - [Values(-1.000000, -1.000000, -1.000000, -1.000000, -0.100000, -0.100000, -0.100000, -0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000)] double mu, - [Values(0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000)] double sigma, - [Values(0.36787944117144232159552377016146086744581113103177, 0.36787944117144232159552377016146086744581113103177, 0.36787944117144232159552377016146086744581113103177, 0.36787944117144232159552377016146086744581113103177, 0.90483741803595956814139238421693559530906465375738, 0.90483741803595956814139238421693559530906465375738, 0.90483741803595956814139238421693559530906465375738, 0.90483741803595956814139238421693559530906465375738, 1.1051709180756476309466388234587796577416634163742, 1.1051709180756476309466388234587796577416634163742, 1.1051709180756476309466388234587796577416634163742, 1.1051709180756476309466388234587796577416634163742, 4.4816890703380648226020554601192758190057498683697, 4.4816890703380648226020554601192758190057498683697, 4.4816890703380648226020554601192758190057498683697, 4.4816890703380648226020554601192758190057498683697, 12.182493960703473438070175951167966183182767790063, 12.182493960703473438070175951167966183182767790063, 12.182493960703473438070175951167966183182767790063, 12.182493960703473438070175951167966183182767790063, 244.6919322642203879151889495118393501842287101075, 244.6919322642203879151889495118393501842287101075, 244.6919322642203879151889495118393501842287101075, 244.6919322642203879151889495118393501842287101075)] double median) + [TestCase(-1.000000, 0.100000, 0.36787944117144232159552377016146086744581113103177)] + [TestCase(-1.000000, 1.500000, 0.36787944117144232159552377016146086744581113103177)] + [TestCase(-1.000000, 2.500000, 0.36787944117144232159552377016146086744581113103177)] + [TestCase(-1.000000, 5.500000, 0.36787944117144232159552377016146086744581113103177)] + [TestCase(-0.100000, 0.100000, 0.90483741803595956814139238421693559530906465375738)] + [TestCase(-0.100000, 1.500000, 0.90483741803595956814139238421693559530906465375738)] + [TestCase(-0.100000, 2.500000, 0.90483741803595956814139238421693559530906465375738)] + [TestCase(-0.100000, 5.500000, 0.90483741803595956814139238421693559530906465375738)] + [TestCase(0.100000, 0.100000, 1.1051709180756476309466388234587796577416634163742)] + [TestCase(0.100000, 1.500000, 1.1051709180756476309466388234587796577416634163742)] + [TestCase(0.100000, 2.500000, 1.1051709180756476309466388234587796577416634163742)] + [TestCase(0.100000, 5.500000, 1.1051709180756476309466388234587796577416634163742)] + [TestCase(1.500000, 0.100000, 4.4816890703380648226020554601192758190057498683697)] + [TestCase(1.500000, 1.500000, 4.4816890703380648226020554601192758190057498683697)] + [TestCase(1.500000, 2.500000, 4.4816890703380648226020554601192758190057498683697)] + [TestCase(1.500000, 5.500000, 4.4816890703380648226020554601192758190057498683697)] + [TestCase(2.500000, 0.100000, 12.182493960703473438070175951167966183182767790063)] + [TestCase(2.500000, 1.500000, 12.182493960703473438070175951167966183182767790063)] + [TestCase(2.500000, 2.500000, 12.182493960703473438070175951167966183182767790063)] + [TestCase(2.500000, 5.500000, 12.182493960703473438070175951167966183182767790063)] + [TestCase(5.500000, 0.100000, 244.6919322642203879151889495118393501842287101075)] + [TestCase(5.500000, 1.500000, 244.6919322642203879151889495118393501842287101075)] + [TestCase(5.500000, 2.500000, 244.6919322642203879151889495118393501842287101075)] + [TestCase(5.500000, 5.500000, 244.6919322642203879151889495118393501842287101075)] + public void ValidateMedian(double mu, double sigma, double median) { var n = new LogNormal(mu, sigma); Assert.AreEqual(median, n.Median); @@ -186,11 +287,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Mu parameter. /// Sigma value. /// Expected value. - [Test, Sequential] - public void ValidateMean( - [Values(-1.000000, -1.000000, -1.000000, -1.000000, -0.100000, -0.100000, -0.100000, -0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000)] double mu, - [Values(0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000, 0.100000, 1.500000, 2.500000, 5.500000)] double sigma, - [Values(0.36972344454405898424295931933535060663729727450496, 1.1331484530668263168290072278117938725655031317452, 8.3728974881272646632047051583699874196015291437918, 1362729.1842528548177103892815156762190272224157908, 0.90937293446823141948366366799116134283184493055232, 2.7870954605658505209699655454000403395863724001622, 20.594004711196027346218102453235151379866942184579, 3351772.9412526949983798753257651403306685815830315, 1.1107106103557052433570611860384876269319432656698, 3.4041660827908192886708290528609320712960422205023, 25.153574155818364061848601838108180348672588964125, 4093864.7151726636524297378613262447736728507467499, 4.5041536302884836520306376113128094189800629942172, 13.804574186067094919261248628970575865946258844868, 102.00277308269968445339478193484494686013688925329, 16601440.057234774713918640507932346750889433699096, 12.243558965801025772304627735965552181680541950402, 37.524723159600998914070697772298569304087527691818, 277.27228452313398040814702091277144916631260200421, 45127392.833833379992911980630933945681066040228608, 245.91845567882191847293631456824227914641401674654, 753.70421255456126566058070133948176772966773355511, 5569.16270856600407442234466894967473356247174813, 906407915.01115491334464289369168840924937330105415)] double mean) + [TestCase(-1.000000, 0.100000, 0.36972344454405898424295931933535060663729727450496)] + [TestCase(-1.000000, 1.500000, 1.1331484530668263168290072278117938725655031317452)] + [TestCase(-1.000000, 2.500000, 8.3728974881272646632047051583699874196015291437918)] + [TestCase(-1.000000, 5.500000, 1362729.1842528548177103892815156762190272224157908)] + [TestCase(-0.100000, 0.100000, 0.90937293446823141948366366799116134283184493055232)] + [TestCase(-0.100000, 1.500000, 2.7870954605658505209699655454000403395863724001622)] + [TestCase(-0.100000, 2.500000, 20.594004711196027346218102453235151379866942184579)] + [TestCase(-0.100000, 5.500000, 3351772.9412526949983798753257651403306685815830315)] + [TestCase(0.100000, 0.100000, 1.1107106103557052433570611860384876269319432656698)] + [TestCase(0.100000, 1.500000, 3.4041660827908192886708290528609320712960422205023)] + [TestCase(0.100000, 2.500000, 25.153574155818364061848601838108180348672588964125)] + [TestCase(0.100000, 5.500000, 4093864.7151726636524297378613262447736728507467499)] + [TestCase(1.500000, 0.100000, 4.5041536302884836520306376113128094189800629942172)] + [TestCase(1.500000, 1.500000, 13.804574186067094919261248628970575865946258844868)] + [TestCase(1.500000, 2.500000, 102.00277308269968445339478193484494686013688925329)] + [TestCase(1.500000, 5.500000, 16601440.057234774713918640507932346750889433699096)] + [TestCase(2.500000, 0.100000, 12.243558965801025772304627735965552181680541950402)] + [TestCase(2.500000, 1.500000, 37.524723159600998914070697772298569304087527691818)] + [TestCase(2.500000, 2.500000, 277.27228452313398040814702091277144916631260200421)] + [TestCase(2.500000, 5.500000, 45127392.833833379992911980630933945681066040228608)] + [TestCase(5.500000, 0.100000, 245.91845567882191847293631456824227914641401674654)] + [TestCase(5.500000, 1.500000, 753.70421255456126566058070133948176772966773355511)] + [TestCase(5.500000, 2.500000, 5569.16270856600407442234466894967473356247174813)] + [TestCase(5.500000, 5.500000, 906407915.01115491334464289369168840924937330105415)] + public void ValidateMean(double mu, double sigma, double mean) { var n = new LogNormal(mu, sigma); AssertHelpers.AlmostEqual(mean, n.Mean, 14); @@ -223,12 +344,35 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Sigma value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensity( - [Values(-0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000)] double mu, - [Values(0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000)] double sigma, - [Values(-0.100000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000)] double x, - [Values(0.0, 1.7968349035073582236359415565799753846986440127816e-104, 0.00000018288923328441197822391757965928083462391836798722, 2.3363114904470413709866234247494393485647978367885, 0.90492497850024368541682348133921492204585092983646, 0.49191985207660942803818797602364034466489243416574, 0.33133347214343229148978298237579567194870525187207, 1.0824698632626565182080576574958317806389057196768, 0.31029619474753883558901295436486123689563749784867, 0.19922929916156673799861939824205622734205083805245, 4.1070141770545881694056265342787422035256248474059e-313, 2.8602688726477103843476657332784045661507239533567e-104, 1.6670425710002183246335601541889400558525870482613e-64, 0.10698412103361841220076392503406214751353235895732, 0.18266125308224685664142384493330155315630876975024, 0.17185785323404088913982425377565512294017306418953, 0.50186885259059181992025035649158160252576845315332, 0.21721369314437986034957451699565540205404697589349, 0.15729636000661278918949298391170443742675565300598, 5.6836826548848916385760779034504046896805825555997e-500, 3.1225608678589488061206338085285607881363155340377e-221, 4.6994713794671660918554320071312374073172560048297e-161, 0.015806486291412916772431170442330946677601577502353, 0.055184331257528847223852028950484131834529030116388, 0.063982134749859504449658286955049840393511776984362, 0.25212505662402617595900822552548977822542300480086, 0.14117186955911792460646517002386088579088567275401, 0.11021452580363707866161369621432656293405065561317)] double p) + [TestCase(-0.100000, 0.100000, -0.100000, 0.0)] + [TestCase(-0.100000, 0.100000, 0.100000, 1.7968349035073582236359415565799753846986440127816e-104)] + [TestCase(-0.100000, 0.100000, 0.500000, 0.00000018288923328441197822391757965928083462391836798722)] + [TestCase(-0.100000, 0.100000, 0.800000, 2.3363114904470413709866234247494393485647978367885)] + [TestCase(-0.100000, 1.500000, 0.100000, 0.90492497850024368541682348133921492204585092983646)] + [TestCase(-0.100000, 1.500000, 0.500000, 0.49191985207660942803818797602364034466489243416574)] + [TestCase(-0.100000, 1.500000, 0.800000, 0.33133347214343229148978298237579567194870525187207)] + [TestCase(-0.100000, 2.500000, 0.100000, 1.0824698632626565182080576574958317806389057196768)] + [TestCase(-0.100000, 2.500000, 0.500000, 0.31029619474753883558901295436486123689563749784867)] + [TestCase(-0.100000, 2.500000, 0.800000, 0.19922929916156673799861939824205622734205083805245)] + [TestCase(1.500000, 0.100000, 0.100000, 4.1070141770545881694056265342787422035256248474059e-313)] + [TestCase(1.500000, 0.100000, 0.500000, 2.8602688726477103843476657332784045661507239533567e-104)] + [TestCase(1.500000, 0.100000, 0.800000, 1.6670425710002183246335601541889400558525870482613e-64)] + [TestCase(1.500000, 1.500000, 0.100000, 0.10698412103361841220076392503406214751353235895732)] + [TestCase(1.500000, 1.500000, 0.500000, 0.18266125308224685664142384493330155315630876975024)] + [TestCase(1.500000, 1.500000, 0.800000, 0.17185785323404088913982425377565512294017306418953)] + [TestCase(1.500000, 2.500000, 0.100000, 0.50186885259059181992025035649158160252576845315332)] + [TestCase(1.500000, 2.500000, 0.500000, 0.21721369314437986034957451699565540205404697589349)] + [TestCase(1.500000, 2.500000, 0.800000, 0.15729636000661278918949298391170443742675565300598)] + [TestCase(2.500000, 0.100000, 0.100000, 5.6836826548848916385760779034504046896805825555997e-500)] + [TestCase(2.500000, 0.100000, 0.500000, 3.1225608678589488061206338085285607881363155340377e-221)] + [TestCase(2.500000, 0.100000, 0.800000, 4.6994713794671660918554320071312374073172560048297e-161)] + [TestCase(2.500000, 1.500000, 0.100000, 0.015806486291412916772431170442330946677601577502353)] + [TestCase(2.500000, 1.500000, 0.500000, 0.055184331257528847223852028950484131834529030116388)] + [TestCase(2.500000, 1.500000, 0.800000, 0.063982134749859504449658286955049840393511776984362)] + [TestCase(2.500000, 2.500000, 0.100000, 0.25212505662402617595900822552548977822542300480086)] + [TestCase(2.500000, 2.500000, 0.500000, 0.14117186955911792460646517002386088579088567275401)] + [TestCase(2.500000, 2.500000, 0.800000, 0.11021452580363707866161369621432656293405065561317)] + public void ValidateDensity(double mu, double sigma, double x, double p) { var n = new LogNormal(mu, sigma); AssertHelpers.AlmostEqual(p, n.Density(x), 14); @@ -241,12 +385,35 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Sigma value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(-0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000)] double mu, - [Values(0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000)] double sigma, - [Values(-0.100000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000)] double x, - [Values(Double.NegativeInfinity, -238.88282294119596467794686179588610665317241097599, -15.514385149961296196003163062199569075052113039686, 0.84857339958981283964373051826407417105725729082041, -0.099903235403144611051953094864849327288457482212211, -0.70943947804316122682964396008813828577195771418027, -1.1046299420497998262946038709903250420774183529995, 0.07924534056485078867266307735371665927517517183681, -1.1702279707433794860424967893989374511050637417043, -1.6132988605030400828957768752511536087538109996183, -719.29643782024317312262673764204041218720576249741, -238.41793403955250272430898754048547661932857086122, -146.85439481068371057247137024006716189469284256628, -2.2350748570877992856465076624973458117562108140674, -1.7001219175524556705452882616787223585705662860012, -1.7610875785399045023354101841009649273236721172008, -0.68941644324162489418137656699398207513321602763104, -1.5268736489667254857801287379715477173125628275598, -1.8496236096394777662704671479709839674424623547308, -1149.5549471196476523788026360929146688367845019398, -507.73265209554698134113704985174959301922196605736, -369.16874994210463740474549611573497379941224077335, -4.1473348984184862316495477617980296904955324113457, -2.8970762200235424747307247601045786110485663457169, -2.7491513791239977024488074547907467152956602019989, -1.3778300581206721947424710027422282714793718026513, -1.9577771978563167352868858774048559682046428490575, -2.2053265778497513183112901654193054111123780652581)] double p) + [TestCase(-0.100000, 0.100000, -0.100000, Double.NegativeInfinity)] + [TestCase(-0.100000, 0.100000, 0.100000, -238.88282294119596467794686179588610665317241097599)] + [TestCase(-0.100000, 0.100000, 0.500000, -15.514385149961296196003163062199569075052113039686)] + [TestCase(-0.100000, 0.100000, 0.800000, 0.84857339958981283964373051826407417105725729082041)] + [TestCase(-0.100000, 1.500000, 0.100000, -0.099903235403144611051953094864849327288457482212211)] + [TestCase(-0.100000, 1.500000, 0.500000, -0.70943947804316122682964396008813828577195771418027)] + [TestCase(-0.100000, 1.500000, 0.800000, -1.1046299420497998262946038709903250420774183529995)] + [TestCase(-0.100000, 2.500000, 0.100000, 0.07924534056485078867266307735371665927517517183681)] + [TestCase(-0.100000, 2.500000, 0.500000, -1.1702279707433794860424967893989374511050637417043)] + [TestCase(-0.100000, 2.500000, 0.800000, -1.6132988605030400828957768752511536087538109996183)] + [TestCase(1.500000, 0.100000, 0.100000, -719.29643782024317312262673764204041218720576249741)] + [TestCase(1.500000, 0.100000, 0.500000, -238.41793403955250272430898754048547661932857086122)] + [TestCase(1.500000, 0.100000, 0.800000, -146.85439481068371057247137024006716189469284256628)] + [TestCase(1.500000, 1.500000, 0.100000, -2.2350748570877992856465076624973458117562108140674)] + [TestCase(1.500000, 1.500000, 0.500000, -1.7001219175524556705452882616787223585705662860012)] + [TestCase(1.500000, 1.500000, 0.800000, -1.7610875785399045023354101841009649273236721172008)] + [TestCase(1.500000, 2.500000, 0.100000, -0.68941644324162489418137656699398207513321602763104)] + [TestCase(1.500000, 2.500000, 0.500000, -1.5268736489667254857801287379715477173125628275598)] + [TestCase(1.500000, 2.500000, 0.800000, -1.8496236096394777662704671479709839674424623547308)] + [TestCase(2.500000, 0.100000, 0.100000, -1149.5549471196476523788026360929146688367845019398)] + [TestCase(2.500000, 0.100000, 0.500000, -507.73265209554698134113704985174959301922196605736)] + [TestCase(2.500000, 0.100000, 0.800000, -369.16874994210463740474549611573497379941224077335)] + [TestCase(2.500000, 1.500000, 0.100000, -4.1473348984184862316495477617980296904955324113457)] + [TestCase(2.500000, 1.500000, 0.500000, -2.8970762200235424747307247601045786110485663457169)] + [TestCase(2.500000, 1.500000, 0.800000, -2.7491513791239977024488074547907467152956602019989)] + [TestCase(2.500000, 2.500000, 0.100000, -1.3778300581206721947424710027422282714793718026513)] + [TestCase(2.500000, 2.500000, 0.500000, -1.9577771978563167352868858774048559682046428490575)] + [TestCase(2.500000, 2.500000, 0.800000, -2.2053265778497513183112901654193054111123780652581)] + public void ValidateDensityLn(double mu, double sigma, double x, double p) { var n = new LogNormal(mu, sigma); AssertHelpers.AlmostEqual(p, n.DensityLn(x), 14); @@ -317,12 +484,35 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Sigma value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(-0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, -0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000)] double mu, - [Values(0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000)] double sigma, - [Values(-0.100000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000)] double x, - [Values(0.0, 0.0, 0.0000000015011556178148777579869633555518882664666520593658, 0.10908001076375810900224507908874442583171381706127, 0.070999149762464508991968731574953594549291668468349, 0.34626224992888089297789445771047690175505847991946, 0.46728530589487698517090261668589508746353129242404, 0.18914969879695093477606645992572208111152994999076, 0.40622798321378106125020505907901206714868922279347, 0.48035707589956665425068652807400957345208517749893, 0.0, 0.0, 0.0, 0.005621455876973168709588070988239748831823850202953, 0.07185716187918271235246980951571040808235628115265, 0.12532699044614938400496547188720940854423187977236, 0.064125647996943514411570834861724406903677144126117, 0.19017302281590810871719754032332631806011441356498, 0.24533064397555500690927047163085419096928289095201, 0.0, 0.0, 0.0, 0.00068304052220788502001572635016579586444611070077399, 0.016636862816580533038130583128179878924863968664206, 0.034729001282904174941366974418836262996834852343018, 0.027363708266690978870139978537188410215717307180775, 0.10075543423327634536450625420610429181921642201567, 0.13802019192453118732001307556787218421918336849121)] double f) + [TestCase(-0.100000, 0.100000, -0.100000, 0.0)] + [TestCase(-0.100000, 0.100000, 0.100000, 0.0)] + [TestCase(-0.100000, 0.100000, 0.500000, 0.0000000015011556178148777579869633555518882664666520593658)] + [TestCase(-0.100000, 0.100000, 0.800000, 0.10908001076375810900224507908874442583171381706127)] + [TestCase(-0.100000, 1.500000, 0.100000, 0.070999149762464508991968731574953594549291668468349)] + [TestCase(-0.100000, 1.500000, 0.500000, 0.34626224992888089297789445771047690175505847991946)] + [TestCase(-0.100000, 1.500000, 0.800000, 0.46728530589487698517090261668589508746353129242404)] + [TestCase(-0.100000, 2.500000, 0.100000, 0.18914969879695093477606645992572208111152994999076)] + [TestCase(-0.100000, 2.500000, 0.500000, 0.40622798321378106125020505907901206714868922279347)] + [TestCase(-0.100000, 2.500000, 0.800000, 0.48035707589956665425068652807400957345208517749893)] + [TestCase(1.500000, 0.100000, 0.100000, 0.0)] + [TestCase(1.500000, 0.100000, 0.500000, 0.0)] + [TestCase(1.500000, 0.100000, 0.800000, 0.0)] + [TestCase(1.500000, 1.500000, 0.100000, 0.005621455876973168709588070988239748831823850202953)] + [TestCase(1.500000, 1.500000, 0.500000, 0.07185716187918271235246980951571040808235628115265)] + [TestCase(1.500000, 1.500000, 0.800000, 0.12532699044614938400496547188720940854423187977236)] + [TestCase(1.500000, 2.500000, 0.100000, 0.064125647996943514411570834861724406903677144126117)] + [TestCase(1.500000, 2.500000, 0.500000, 0.19017302281590810871719754032332631806011441356498)] + [TestCase(1.500000, 2.500000, 0.800000, 0.24533064397555500690927047163085419096928289095201)] + [TestCase(2.500000, 0.100000, 0.100000, 0.0)] + [TestCase(2.500000, 0.100000, 0.500000, 0.0)] + [TestCase(2.500000, 0.100000, 0.800000, 0.0)] + [TestCase(2.500000, 1.500000, 0.100000, 0.00068304052220788502001572635016579586444611070077399)] + [TestCase(2.500000, 1.500000, 0.500000, 0.016636862816580533038130583128179878924863968664206)] + [TestCase(2.500000, 1.500000, 0.800000, 0.034729001282904174941366974418836262996834852343018)] + [TestCase(2.500000, 2.500000, 0.100000, 0.027363708266690978870139978537188410215717307180775)] + [TestCase(2.500000, 2.500000, 0.500000, 0.10075543423327634536450625420610429181921642201567)] + [TestCase(2.500000, 2.500000, 0.800000, 0.13802019192453118732001307556787218421918336849121)] + public void ValidateCumulativeDistribution(double mu, double sigma, double x, double f) { var n = new LogNormal(mu, sigma); AssertHelpers.AlmostEqual(f, n.CumulativeDistribution(x), 8); diff --git a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs index 453df298..6a5bb987 100644 --- a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -62,8 +62,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Standard deviation value. - [Test, Combinatorial] - public void CanCreateNormal([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sdev) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void CanCreateNormal(double mean, double sdev) { var n = new Normal(mean, sdev); Assert.AreEqual(mean, n.Mean); @@ -75,8 +80,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Standard deviation value. - [Test, Sequential] - public void NormalCreateFailsWithBadParameters([Values(Double.NaN, 1.0, Double.NaN, 1.0)] double mean, [Values(1.0, Double.NaN, Double.NaN, -1.0)] double sdev) + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + [TestCase(1.0, -1.0)] + public void NormalCreateFailsWithBadParameters(double mean, double sdev) { Assert.Throws(() => new Normal(mean, sdev)); } @@ -86,8 +94,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Standard deviation value. - [Test, Combinatorial] - public void CanCreateNormalFromMeanAndStdDev([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sdev) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void CanCreateNormalFromMeanAndStdDev(double mean, double sdev) { var n = Normal.WithMeanStdDev(mean, sdev); Assert.AreEqual(mean, n.Mean); @@ -99,8 +112,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Variance value. - [Test, Combinatorial] - public void CanCreateNormalFromMeanAndVariance([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double var) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void CanCreateNormalFromMeanAndVariance(double mean, double var) { var n = Normal.WithMeanVariance(mean, var); AssertHelpers.AlmostEqual(mean, n.Mean, 16); @@ -112,8 +130,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Precision value. - [Test, Combinatorial] - public void CanCreateNormalFromMeanAndPrecision([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double prec) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void CanCreateNormalFromMeanAndPrecision(double mean, double prec) { var n = Normal.WithMeanPrecision(mean, prec); AssertHelpers.AlmostEqual(mean, n.Mean, 15); @@ -134,8 +157,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set precision. /// /// Precision value. - [Test] - public void CanSetPrecision([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double prec) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetPrecision(double prec) { new Normal { @@ -157,8 +185,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set variance. /// /// Variance value. - [Test] - public void CanSetVariance([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double var) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetVariance(double var) { new Normal { @@ -180,8 +213,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set standard deviation. /// /// Standard deviation value. - [Test] - public void CanSetStdDev([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double sdev) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetStdDev(double sdev) { new Normal { @@ -203,8 +241,14 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set mean. /// /// Mean value. - [Test] - public void CanSetMean([Values(Double.NegativeInfinity, -0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double mean) + [TestCase(Double.NegativeInfinity)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetMean(double mean) { new Normal { @@ -216,8 +260,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate entropy. /// /// Standard deviation value. - [Test] - public void ValidateEntropy([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double sdev) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateEntropy(double sdev) { var n = new Normal(1.0, sdev); Assert.AreEqual(Constants.LogSqrt2PiE + Math.Log(n.StdDev), n.Entropy); @@ -227,8 +276,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate skewness. /// /// Standard deviation value. - [Test] - public void ValidateSkewness([Values(-0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double sdev) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateSkewness(double sdev) { var n = new Normal(1.0, sdev); Assert.AreEqual(0.0, n.Skewness); @@ -238,8 +292,14 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mean. /// /// Mean value. - [Test] - public void ValidateMode([Values(Double.NegativeInfinity, -0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double mean) + [TestCase(Double.NegativeInfinity)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMode(double mean) { var n = new Normal(mean, 1.0); Assert.AreEqual(mean, n.Mode); @@ -249,8 +309,14 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate median. /// /// Mean value. - [Test] - public void ValidateMedian([Values(Double.NegativeInfinity, -0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double mean) + [TestCase(Double.NegativeInfinity)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMedian(double mean) { var n = new Normal(mean, 1.0); Assert.AreEqual(mean, n.Median); @@ -281,8 +347,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Standard deviation value. - [Test, Combinatorial] - public void ValidateDensity([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sdev) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void ValidateDensity(double mean, double sdev) { var n = Normal.WithMeanStdDev(mean, sdev); for (var i = 0; i < 11; i++) @@ -299,8 +370,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Mean value. /// Standard deviation value. - [Test, Combinatorial] - public void ValidateDensityLn([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sdev) + [TestCase(0.0, 0.0)] + [TestCase(10.0, 0.1)] + [TestCase(-5.0, 1.0)] + [TestCase(0.0, 10.0)] + [TestCase(10.0, 100.0)] + [TestCase(-5.0, Double.PositiveInfinity)] + public void ValidateDensityLn(double mean, double sdev) { var n = Normal.WithMeanStdDev(mean, sdev); for (var i = 0; i < 11; i++) @@ -375,10 +451,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(Double.NegativeInfinity, -5.0, -2.0, -0.0, 0.0, 4.0, 5.0, 6.0, 10.0, Double.PositiveInfinity)] double x, - [Values(0.0, 0.00000028665157187919391167375233287464535385442301361187883, 0.0002326290790355250363499258867279847735487493358890356, 0.0062096653257761351669781045741922211278977469230927036, 0.0062096653257761351669781045741922211278977469230927036, 0.30853753872598689636229538939166226011639782444542207, 0.5, 0.69146246127401310363770461060833773988360217555457859, 0.9937903346742238648330218954258077788721022530769078, 1.0)] double f) + [TestCase(Double.NegativeInfinity, 0.0)] + [TestCase(-5.0, 0.00000028665157187919391167375233287464535385442301361187883)] + [TestCase(-2.0, 0.0002326290790355250363499258867279847735487493358890356)] + [TestCase(-0.0, 0.0062096653257761351669781045741922211278977469230927036)] + [TestCase(0.0, 0.0062096653257761351669781045741922211278977469230927036)] + [TestCase(4.0, 0.30853753872598689636229538939166226011639782444542207)] + [TestCase(5.0, 0.5)] + [TestCase(6.0, 0.69146246127401310363770461060833773988360217555457859)] + [TestCase(10.0, 0.9937903346742238648330218954258077788721022530769078)] + [TestCase(Double.PositiveInfinity, 1.0)] + public void ValidateCumulativeDistribution(double x, double f) { var n = Normal.WithMeanStdDev(5.0, 2.0); AssertHelpers.AlmostEqual(f, n.CumulativeDistribution(x), 10); @@ -389,10 +472,17 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateInverseCumulativeDistribution( - [Values(Double.NegativeInfinity, -5.0, -2.0, -0.0, 0.0, 4.0, 5.0, 6.0, 10.0, Double.PositiveInfinity)] double x, - [Values(0.0, 0.00000028665157187919391167375233287464535385442301361187883, 0.0002326290790355250363499258867279847735487493358890356, 0.0062096653257761351669781045741922211278977469230927036, .0062096653257761351669781045741922211278977469230927036, .30853753872598689636229538939166226011639782444542207, .5, .69146246127401310363770461060833773988360217555457859, 0.9937903346742238648330218954258077788721022530769078, 1.0)] double f) + [TestCase(Double.NegativeInfinity, 0.0)] + [TestCase(-5.0, 0.00000028665157187919391167375233287464535385442301361187883)] + [TestCase(-2.0, 0.0002326290790355250363499258867279847735487493358890356)] + [TestCase(-0.0, 0.0062096653257761351669781045741922211278977469230927036)] + [TestCase(0.0, .0062096653257761351669781045741922211278977469230927036)] + [TestCase(4.0, .30853753872598689636229538939166226011639782444542207)] + [TestCase(5.0, .5)] + [TestCase(6.0, .69146246127401310363770461060833773988360217555457859)] + [TestCase(10.0, 0.9937903346742238648330218954258077788721022530769078)] + [TestCase(Double.PositiveInfinity, 1.0)] + public void ValidateInverseCumulativeDistribution(double x, double f) { var n = Normal.WithMeanStdDev(5.0, 2.0); AssertHelpers.AlmostEqual(x, n.InverseCumulativeDistribution(f), 15); diff --git a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs index ba73779a..3ded5929 100644 --- a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void CanCreatePareto([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void CanCreatePareto(double scale, double shape) { var n = new Pareto(scale, shape); Assert.AreEqual(scale, n.Scale); @@ -64,10 +67,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Sequential] - public void ParetoCreateFailsWithBadParameters( - [Values(Double.NaN, 1.0, Double.NaN, 1.0, -1.0, -1.0, 0.0, 0.0, 1.0)] double scale, - [Values(1.0, Double.NaN, Double.NaN, -1.0, 1.0, -1.0, 0.0, 1.0, 0.0)] double shape) + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + [TestCase(1.0, -1.0)] + [TestCase(-1.0, 1.0)] + [TestCase(-1.0, -1.0)] + [TestCase(0.0, 0.0)] + [TestCase(0.0, 1.0)] + [TestCase(1.0, 0.0)] + public void ParetoCreateFailsWithBadParameters(double scale, double shape) { Assert.Throws(() => { var n = new Pareto(scale, shape); }); } @@ -86,8 +95,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Pareto(1.0, 1.0) { @@ -109,8 +121,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set shape. /// /// Shape value. - [Test] - public void CanSetShape([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetShape(double shape) { new Pareto(1.0, 1.0) { @@ -133,8 +148,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateMean([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMean(double scale, double shape) { var n = new Pareto(scale, shape); if (shape > 1) @@ -148,8 +166,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateVariance([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateVariance(double scale, double shape) { var n = new Pareto(scale, shape); if (shape <= 2.0) @@ -167,8 +188,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateStdDev([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateStdDev(double scale, double shape) { var n = new Pareto(scale, shape); Assert.AreEqual((scale * Math.Sqrt(shape)) / ((shape - 1.0) * Math.Sqrt(shape - 2.0)), n.StdDev); @@ -179,8 +203,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateEntropy([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateEntropy(double scale, double shape) { var n = new Pareto(scale, shape); Assert.AreEqual(Math.Log(shape / scale) - (1.0 / shape) - 1.0, n.Entropy); @@ -191,8 +218,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateSkewness([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateSkewness(double scale, double shape) { var n = new Pareto(scale, shape); Assert.AreEqual((2.0 * (shape + 1.0) / (shape - 3.0)) * Math.Sqrt((shape - 2.0) / shape), n.Skewness); @@ -203,8 +233,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateMode([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMode(double scale, double shape) { var n = new Pareto(scale, shape); Assert.AreEqual(scale, n.Mode); @@ -215,10 +248,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Shape value. - [Test, Combinatorial] - public void ValidateMedian( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateMedian(double scale, double shape) { var n = new Pareto(scale, shape); Assert.AreEqual(scale * Math.Pow(2.0, 1.0 / shape), n.Median); @@ -228,8 +262,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate minimum. /// /// Scale value. - [Test] - public void ValidateMinimum([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMinimum(double scale) { var n = new Pareto(scale, 1.0); Assert.AreEqual(scale, n.Minimum); @@ -251,11 +288,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Shape value. /// Input X value. - [Test, Combinatorial] - public void ValidateDensity( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape, - [Values(0.1, 1.0, 2.0, 2.1, 10.0, 12.0, Double.PositiveInfinity)] double x) + [TestCase(0.1, 0.1, 0.1)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(5.0, 5.0, 2.0)] + [TestCase(7.0, 7.0, 10.0)] + [TestCase(10.0, 10.0, 12.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensity(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual(shape * Math.Pow(scale, shape) / Math.Pow(x, shape + 1.0), n.Density(x)); @@ -267,11 +306,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Shape value. /// Input X value. - [Test, Combinatorial] - public void ValidateDensityLn( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape, - [Values(0.1, 1.0, 2.0, 2.1, 10.0, 12.0, Double.PositiveInfinity)] double x) + [TestCase(0.1, 0.1, 0.1)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(5.0, 5.0, 2.0)] + [TestCase(7.0, 7.0, 10.0)] + [TestCase(10.0, 10.0, 12.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensityLn(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual(Math.Log(n.Density(x)), n.DensityLn(x)); @@ -304,11 +345,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Shape value. /// Input X value. - [Test, Combinatorial] - public void ValidateCumulativeDistribution( - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, - [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape, - [Values(0.1, 1.0, 2.0, 2.1, 10.0, 12.0, Double.PositiveInfinity)] double x) + [TestCase(0.1, 0.1, 0.1)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(5.0, 5.0, 2.0)] + [TestCase(7.0, 7.0, 10.0)] + [TestCase(10.0, 10.0, 12.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual(1.0 - Math.Pow(scale / x, shape), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs index d0d1fcce..92ec996f 100644 --- a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can create Rayleigh /// /// Scale value. - [Test] - public void CanCreateRayleigh([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanCreateRayleigh(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(scale, n.Scale); @@ -61,8 +64,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Rayleigh create fails with bad parameters. /// /// Scale value. - [Test] - public void RayleighCreateFailsWithBadParameters([Values(Double.NaN, Double.NegativeInfinity, -1.0, 0.0)] double scale) + [TestCase(Double.NaN)] + [TestCase(Double.NegativeInfinity)] + [TestCase(-1.0)] + [TestCase(0.0)] + public void RayleighCreateFailsWithBadParameters(double scale) { Assert.Throws(() => new Rayleigh(scale)); } @@ -81,8 +87,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Rayleigh(1.0) { @@ -94,8 +103,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set scale fails with negative scale. /// /// Scale value. - [Test] - public void SetScaleFailsWithNegativeScale([Values(-0.0, 0.0, -1.0, Double.NegativeInfinity, Double.NaN)] double scale) + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(Double.NegativeInfinity)] + [TestCase(Double.NaN)] + public void SetScaleFailsWithNegativeScale(double scale) { var n = new Rayleigh(1.0); Assert.Throws(() => n.Scale = scale); @@ -105,8 +118,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mean. /// /// Scale value. - [Test] - public void ValidateMean([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMean(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(scale * Math.Sqrt(Constants.PiOver2), n.Mean); @@ -116,8 +132,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate variance. /// /// Scale value. - [Test] - public void ValidateVariance([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateVariance(double scale) { var n = new Rayleigh(scale); Assert.AreEqual((2.0 - Constants.PiOver2) * scale * scale, n.Variance); @@ -127,8 +146,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate standard deviation. /// /// Scale value. - [Test] - public void ValidateStdDev([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateStdDev(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(Math.Sqrt(2.0 - Constants.PiOver2) * scale, n.StdDev); @@ -138,8 +160,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate entropy. /// /// Scale value. - [Test] - public void ValidateEntropy([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateEntropy(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(1.0 + Math.Log(scale / Math.Sqrt(2)) + (Constants.EulerMascheroni / 2.0), n.Entropy); @@ -150,8 +175,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Expected value. - [Test, Combinatorial] - public void ValidateSkewness([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.63111065781893638)] double skn) + [TestCase(0.1, 0.63111065781893638)] + [TestCase(1.0, 0.63111065781893638)] + [TestCase(10.0, 0.63111065781893638)] + [TestCase(Double.PositiveInfinity, 0.63111065781893638)] + public void ValidateSkewness(double scale, double skn) { var n = new Rayleigh(scale); AssertHelpers.AlmostEqual(skn, n.Skewness, 17); @@ -161,8 +189,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mode. /// /// Scale value. - [Test] - public void ValidateMode([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMode(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(scale, n.Mode); @@ -172,8 +203,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate median. /// /// Scale value. - [Test] - public void ValidateMedian([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMedian(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(scale * Math.Sqrt(Math.Log(4.0)), n.Median); @@ -183,8 +217,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate minimum. /// /// Scale value. - [Test] - public void ValidateMinimum([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMinimum(double scale) { var n = new Rayleigh(scale); Assert.AreEqual(0.0, n.Minimum); @@ -194,8 +231,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate maximum. /// /// Scale value. - [Test] - public void ValidateMaximum([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMaximum(double scale) { var n = new Rayleigh(1.0); Assert.AreEqual(Double.PositiveInfinity, n.Maximum); @@ -206,8 +246,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Input X value. - [Test, Combinatorial] - public void ValidateDensity([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensity(double scale, double x) { var n = new Rayleigh(scale); Assert.AreEqual((x / (scale * scale)) * Math.Exp(-x * x / (2.0 * scale * scale)), n.Density(x)); @@ -218,8 +261,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Input X value. - [Test, Combinatorial] - public void ValidateDensityLn([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateDensityLn(double scale, double x) { var n = new Rayleigh(scale); Assert.AreEqual(Math.Log(x / (scale * scale)) - (x * (x / (2.0 * (scale * scale)))), n.DensityLn(x)); @@ -251,8 +297,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Scale value. /// Input X value. - [Test, Combinatorial] - public void ValidateCumulativeDistribution([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x) + [TestCase(0.1, 0.1)] + [TestCase(1.0, 1.0)] + [TestCase(10.0, 10.0)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void ValidateCumulativeDistribution(double scale, double x) { var n = new Rayleigh(scale); Assert.AreEqual(1.0 - Math.Exp(-x * x / (2.0 * scale * scale)), n.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Continuous/StableTests.cs b/src/UnitTests/DistributionTests/Continuous/StableTests.cs index e58ec4ba..07651bed 100644 --- a/src/UnitTests/DistributionTests/Continuous/StableTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/StableTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -53,8 +53,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Beta value. /// Scale value. /// Location value. - [Test, Combinatorial] - public void CanCreateStable([Values(0.1, 2.0)] double alpha, [Values(-1.0, 1.0)] double beta, [Values(0.1, Double.PositiveInfinity)] double scale, [Values(Double.NegativeInfinity, -1.0, 0.0, 1.0, Double.PositiveInfinity)] double location) + [TestCase(0.1, -1.0, 0.1, Double.NegativeInfinity)] + [TestCase(2.0, 1.0, Double.PositiveInfinity, -1.0)] + [TestCase(0.1, -1.0, 0.1, 0.0)] + [TestCase(2.0, 1.0, Double.PositiveInfinity, 1.0)] + [TestCase(0.1, -1.0, 0.1, Double.PositiveInfinity)] + public void CanCreateStable(double alpha, double beta, double scale, double location) { var n = new Stable(alpha, beta, scale, location); Assert.AreEqual(alpha, n.Alpha); @@ -70,12 +74,25 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Beta value. /// Location value. /// Scale value. - [Test, Sequential] - public void StableCreateFailsWithBadParameters( - [Values(Double.NaN, 1.0, Double.NaN, Double.NaN, Double.NaN, 1.0, 1.0, 1.0, Double.NaN, 1.0, 1.0, 1.0, Double.NaN, 1.0, 1.0, 1.0, 0.0, 2.1)] double alpha, - [Values(Double.NaN, Double.NaN, 1.0, Double.NaN, Double.NaN, 1.0, Double.NaN, Double.NaN, 1.0, 1.0, 1.0, Double.NaN, 1.0, 1.0, -1.1, 1.1, 1.0, 1.0)] double beta, - [Values(Double.NaN, Double.NaN, Double.NaN, 1.0, Double.NaN, Double.NaN, 1.0, Double.NaN, 1.0, 1.0, Double.NaN, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0)] double location, - [Values(Double.NaN, Double.NaN, Double.NaN, Double.NaN, 1.0, Double.NaN, Double.NaN, 1.0, Double.NaN, Double.NaN, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale) + [TestCase(Double.NaN, Double.NaN, Double.NaN, Double.NaN)] + [TestCase(1.0, Double.NaN, Double.NaN, Double.NaN)] + [TestCase(Double.NaN, 1.0, Double.NaN, Double.NaN)] + [TestCase(Double.NaN, Double.NaN, 1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN, Double.NaN, 1.0)] + [TestCase(1.0, 1.0, Double.NaN, Double.NaN)] + [TestCase(1.0, Double.NaN, 1.0, Double.NaN)] + [TestCase(1.0, Double.NaN, Double.NaN, 1.0)] + [TestCase(Double.NaN, 1.0, 1.0, Double.NaN)] + [TestCase(1.0, 1.0, 1.0, Double.NaN)] + [TestCase(1.0, 1.0, Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN, 1.0, 1.0)] + [TestCase(Double.NaN, 1.0, 1.0, 1.0)] + [TestCase(1.0, 1.0, 0.0, 1.0)] + [TestCase(1.0, -1.1, 1.0, 1.0)] + [TestCase(1.0, 1.1, 1.0, 1.0)] + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(2.1, 1.0, 1.0, 1.0)] + public void StableCreateFailsWithBadParameters(double alpha, double beta, double location, double scale) { Assert.Throws(() => new Stable(alpha, beta, location, scale)); } @@ -94,8 +111,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set alpha. /// /// Alpha value. - [Test] - public void CanSetAlpha([Values(0.1, 1.0, 2.0)] double alpha) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(2.0)] + public void CanSetAlpha(double alpha) { new Stable(1.0, 1.0, 1.0, 1.0) { @@ -107,8 +126,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set alpha fails with bad values. /// /// Alpha value. - [Test] - public void SetAlphaFail([Values(Double.NaN, -0.0, 0.0, 2.1, Double.NegativeInfinity, Double.PositiveInfinity)] double alpha) + [TestCase(Double.NaN)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(2.1)] + [TestCase(Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity)] + public void SetAlphaFail(double alpha) { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws(() => n.Alpha = alpha); @@ -118,8 +142,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set beta. /// /// Beta value. - [Test] - public void CanSetBeta([Values(-1.0, -0.1, -0.0, 0.0, 0.1, 1.0)] double beta) + [TestCase(-1.0)] + [TestCase(-0.1)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + public void CanSetBeta(double beta) { new Stable(1.0, 1.0, 1.0, 1.0) { @@ -131,8 +160,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set beta fails with bad values. /// /// Beta value. - [Test] - public void SetBetaFail([Values(Double.NaN, -1.1, 1.1, Double.NegativeInfinity, Double.PositiveInfinity)] double beta) + [TestCase(Double.NaN)] + [TestCase(-1.1)] + [TestCase(1.1)] + [TestCase(Double.NegativeInfinity)] + [TestCase(Double.PositiveInfinity)] + public void SetBetaFail(double beta) { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws(() => n.Beta = beta); @@ -142,8 +175,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Stable(1.0, 1.0, 1.0, 1.0) { @@ -155,8 +191,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set scale fails with bad values. /// /// Scale value. - [Test] - public void SetScaleFail([Values(Double.NaN, 0.0)] double scale) + [TestCase(Double.NaN)] + [TestCase(0.0)] + public void SetScaleFail(double scale) { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws(() => n.Scale = scale); @@ -166,8 +203,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set location. /// /// Location value. - [Test] - public void CanSetLocation([Values(Double.NegativeInfinity, -10.0, -1.0, -0.1, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double location) + [TestCase(Double.NegativeInfinity)] + [TestCase(-10.0)] + [TestCase(-1.0)] + [TestCase(-0.1)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetLocation(double location) { new Stable(1.0, 1.0, 1.0, 1.0) { @@ -212,8 +256,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mode. /// /// Location value. - [Test] - public void ValidateMode([Values(Double.NegativeInfinity, -10.0, -1.0, -0.1, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double location) + [TestCase(Double.NegativeInfinity)] + [TestCase(-10.0)] + [TestCase(-1.0)] + [TestCase(-0.1)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMode(double location) { var n = new Stable(1.0, 0.0, 1.0, location); if (n.Beta == 0) @@ -226,8 +277,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate mean. /// /// Location value. - [Test] - public void ValidateMedian([Values(Double.NegativeInfinity, -10.0, -1.0, -0.1, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double location) + [TestCase(Double.NegativeInfinity)] + [TestCase(-10.0)] + [TestCase(-1.0)] + [TestCase(-0.1)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void ValidateMedian(double location) { var n = new Stable(1.0, 0.0, 1.0, location); if (n.Beta == 0) @@ -240,8 +298,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Validate minimum. /// /// Beta value. - [Test] - public void ValidateMinimum([Values(-1.0, -0.1, -0.0, 0.0, 0.1, 1.0)] double beta) + [TestCase(-1.0)] + [TestCase(-0.1)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + public void ValidateMinimum(double beta) { var n = new Stable(1.0, beta, 1.0, 1.0); Assert.AreEqual(Math.Abs(beta) != 1 ? Double.NegativeInfinity : 0.0, n.Minimum); @@ -266,14 +329,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensity( - [Values(2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5)] double alpha, - [Values(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)] double beta, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.5, 3.0, 5.0, 1.5, 3.0, 5.0, 1.5, 3.0, 5.0)] double x, - [Values(0.16073276729880184, 0.029732572305907354, 0.00054457105758817781, 0.097941503441166353, 0.031830988618379068, 0.012242687930145794, 0.15559955475708653, 0.064989885240913717, 0.032286845174307237)] double d) + [TestCase(2.0, -1.0, 1.0, 0.0, 1.5, 0.16073276729880184)] + [TestCase(2.0, -1.0, 1.0, 0.0, 3.0, 0.029732572305907354)] + [TestCase(2.0, -1.0, 1.0, 0.0, 5.0, 0.00054457105758817781)] + [TestCase(1.0, 0.0, 1.0, 0.0, 1.5, 0.097941503441166353)] + [TestCase(1.0, 0.0, 1.0, 0.0, 3.0, 0.031830988618379068)] + [TestCase(1.0, 0.0, 1.0, 0.0, 5.0, 0.012242687930145794)] + [TestCase(0.5, 1.0, 1.0, 0.0, 1.5, 0.15559955475708653)] + [TestCase(0.5, 1.0, 1.0, 0.0, 3.0, 0.064989885240913717)] + [TestCase(0.5, 1.0, 1.0, 0.0, 5.0, 0.032286845174307237)] + public void ValidateDensity(double alpha, double beta, double scale, double location, double x, double d) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(d, n.Density(x), 15); @@ -288,14 +353,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5)] double alpha, - [Values(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)] double beta, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.5, 3.0, 5.0, 1.5, 3.0, 5.0, 1.5, 3.0, 5.0)] double x, - [Values(-1.8280121234846454, -3.5155121234846449, -7.5155121234846449, -2.3233848821910463, -3.4473149788434458, -4.4028264238708825, -1.8604695287002526, -2.7335236328735038, -3.4330954018558235)] double dln) + [TestCase(2.0, -1.0, 1.0, 0.0, 1.5, -1.8280121234846454)] + [TestCase(2.0, -1.0, 1.0, 0.0, 3.0, -3.5155121234846449)] + [TestCase(2.0, -1.0, 1.0, 0.0, 5.0, -7.5155121234846449)] + [TestCase(1.0, 0.0, 1.0, 0.0, 1.5, -2.3233848821910463)] + [TestCase(1.0, 0.0, 1.0, 0.0, 3.0, -3.4473149788434458)] + [TestCase(1.0, 0.0, 1.0, 0.0, 5.0, -4.4028264238708825)] + [TestCase(0.5, 1.0, 1.0, 0.0, 1.5, -1.8604695287002526)] + [TestCase(0.5, 1.0, 1.0, 0.0, 3.0, -2.7335236328735038)] + [TestCase(0.5, 1.0, 1.0, 0.0, 5.0, -3.4330954018558235)] + public void ValidateDensityLn(double alpha, double beta, double scale, double location, double x, double dln) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(dln, n.DensityLn(x), 15); @@ -331,14 +398,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5)] double alpha, - [Values(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)] double beta, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.5, 3.0, 5.0, 1.5, 3.0, 5.0, 1.5, 3.0, 5.0)] double x, - [Values(0.8555778168267576, 0.98305257323765538, 0.9997965239912775, 0.81283295818900125, 0.89758361765043326, 0.93716704181099886, 0.41421617824252516, 0.563702861650773, 0.65472084601857694)] double cdf) + [TestCase(2.0, -1.0, 1.0, 0.0, 1.5, 0.8555778168267576)] + [TestCase(2.0, -1.0, 1.0, 0.0, 3.0, 0.98305257323765538)] + [TestCase(2.0, -1.0, 1.0, 0.0, 5.0, 0.9997965239912775)] + [TestCase(1.0, 0.0, 1.0, 0.0, 1.5, 0.81283295818900125)] + [TestCase(1.0, 0.0, 1.0, 0.0, 3.0, 0.89758361765043326)] + [TestCase(1.0, 0.0, 1.0, 0.0, 5.0, 0.93716704181099886)] + [TestCase(0.5, 1.0, 1.0, 0.0, 1.5, 0.41421617824252516)] + [TestCase(0.5, 1.0, 1.0, 0.0, 3.0, 0.563702861650773)] + [TestCase(0.5, 1.0, 1.0, 0.0, 5.0, 0.65472084601857694)] + public void ValidateCumulativeDistribution(double alpha, double beta, double scale, double location, double x, double cdf) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 15); diff --git a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs index 9a62e22d..03c97796 100644 --- a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -64,8 +64,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Degrees of freedom. - [Test, Combinatorial] - public void CanCreateStudentT([Values(0.0, -5.0, 10.0)] double location, [Values(0.1, 1.0, 10.0)] double scale, [Values(1.0, 3.0, Double.PositiveInfinity)] double dof) + [TestCase(0.0, 0.1, 1.0)] + [TestCase(-5.0, 1.0, 3.0)] + [TestCase(10.0, 10.0, Double.PositiveInfinity)] + public void CanCreateStudentT(double location, double scale, double dof) { var n = new StudentT(location, scale, dof); Assert.AreEqual(location, n.Location); @@ -79,11 +81,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Degrees of freedom. - [Test, Sequential] - public void StudentTCreateFailsWithBadParameters( - [Values(Double.NaN, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.0, Double.NaN, 1.0, -10.0, 10.0)] double scale, - [Values(1.0, 1.0, Double.NaN, 1.0, -1.0)] double dof) + [TestCase(Double.NaN, 1.0, 1.0)] + [TestCase(0.0, Double.NaN, 1.0)] + [TestCase(0.0, 1.0, Double.NaN)] + [TestCase(0.0, -10.0, 1.0)] + [TestCase(0.0, 10.0, -1.0)] + public void StudentTCreateFailsWithBadParameters(double location, double scale, double dof) { Assert.Throws(() => new StudentT(location, scale, dof)); } @@ -102,8 +105,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set location. /// /// Location value. - [Test] - public void CanSetLocation([Values(Double.NegativeInfinity, -5.0, -0.0, 0.0, 0.1, 1.0, 10.0, Double.PositiveInfinity)] double loc) + [TestCase(Double.NegativeInfinity)] + [TestCase(-5.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetLocation(double loc) { new StudentT { @@ -115,8 +125,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new StudentT { @@ -128,8 +141,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set scale fails with non-positive scale. /// /// Scale value. - [Test] - public void SetScaleFailsWithNonPositiveScale([Values(-1.0, -0.0, 0.0)] double scale) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetScaleFailsWithNonPositiveScale(double scale) { var n = new StudentT(); Assert.Throws(() => n.Scale = scale); @@ -139,8 +154,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set degrees of freedom. /// /// Degrees of freedom. - [Test] - public void CanSetDoF([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double dof) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetDoF(double dof) { new StudentT { @@ -152,8 +170,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set degrees of freedom fails with non-positive value. /// /// Degrees of freedom. - [Test] - public void SetDofFailsWithNonPositiveDoF([Values(-1.0, -0.0, 0.0)] double dof) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetDofFailsWithNonPositiveDoF(double dof) { var n = new StudentT(); Assert.Throws(() => n.DegreesOfFreedom = dof); @@ -166,12 +186,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Degrees of freedom. /// Expected value. - [Test, Sequential] - public void ValidateMean( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, -5.0, 0.0)] double location, - [Values(1.0, 0.1, 1.0, 10.0, 10.0, 10.0, 1.0, 100.0, Double.PositiveInfinity)] double scale, - [Values(1.0, 1.0, 3.0, 1.0, 2.0, Double.PositiveInfinity, 1.0, 1.5, 1.0)] double dof, - [Values(Double.NaN, Double.NaN, 0.0, Double.NaN, 0.0, 0.0, Double.NaN, -5.0, Double.NaN)] double mean) + [TestCase(0.0, 1.0, 1.0, Double.NaN)] + [TestCase(0.0, 0.1, 1.0, Double.NaN)] + [TestCase(0.0, 1.0, 3.0, 0.0)] + [TestCase(0.0, 10.0, 1.0, Double.NaN)] + [TestCase(0.0, 10.0, 2.0, 0.0)] + [TestCase(0.0, 10.0, Double.PositiveInfinity, 0.0)] + [TestCase(10.0, 1.0, 1.0, Double.NaN)] + [TestCase(-5.0, 100.0, 1.5, -5.0)] + [TestCase(0.0, Double.PositiveInfinity, 1.0, Double.NaN)] + public void ValidateMean(double location, double scale, double dof, double mean) { var n = new StudentT(location, scale, dof); Assert.AreEqual(mean, n.Mean); @@ -184,12 +208,18 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Degrees of freedom. /// Expected value. - [Test, Sequential] - public void ValidateVariance( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, -5.0, 0.0)] double location, - [Values(1.0, 0.1, 1.0, 10.0, 10.0, 10.0, 10.0, 1.0, 1.0, 100.0, Double.PositiveInfinity)] double scale, - [Values(1.0, 1.0, 3.0, 1.0, 2.0, 2.5, Double.PositiveInfinity, 1.0, 2.5, 1.5, 1.0)] double dof, - [Values(Double.NaN, Double.NaN, 3.0, Double.NaN, Double.PositiveInfinity, 500.0, 100.0, Double.NaN, 5.0, Double.PositiveInfinity, Double.NaN)] double var) + [TestCase(0.0, 1.0, 1.0, Double.NaN)] + [TestCase(0.0, 0.1, 1.0, Double.NaN)] + [TestCase(0.0, 1.0, 3.0, 3.0)] + [TestCase(0.0, 10.0, 1.0, Double.NaN)] + [TestCase(0.0, 10.0, 2.0, Double.PositiveInfinity)] + [TestCase(0.0, 10.0, 2.5, 500.0)] + [TestCase(0.0, 10.0, Double.PositiveInfinity, 100.0)] + [TestCase(10.0, 1.0, 1.0, Double.NaN)] + [TestCase(10.0, 1.0, 2.5, 5.0)] + [TestCase(-5.0, 100.0, 1.5, Double.PositiveInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 1.0, Double.NaN)] + public void ValidateVariance(double location, double scale, double dof, double var) { var n = new StudentT(location, scale, dof); Assert.AreEqual(var, n.Variance); @@ -202,12 +232,18 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Degrees of freedom. /// Expected value. - [Test, Sequential] - public void ValidateStdDev( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, -5.0, 0.0)] double location, - [Values(1.0, 0.1, 1.0, 10.0, 10.0, 10.0, 10.0, 1.0, 1.0, 100.0, Double.PositiveInfinity)] double scale, - [Values(1.0, 1.0, 3.0, 1.0, 2.0, 2.5, Double.PositiveInfinity, 1.0, 2.5, 1.5, 1.0)] double dof, - [Values(Double.NaN, Double.NaN, 1.7320508075688772935274463415059, Double.NaN, Double.PositiveInfinity, 22.360679774997896964091736687313, 10.0, Double.NaN, 2.2360679774997896964091736687313, Double.PositiveInfinity, Double.NaN)] double sdev) + [TestCase(0.0, 1.0, 1.0, Double.NaN)] + [TestCase(0.0, 0.1, 1.0, Double.NaN)] + [TestCase(0.0, 1.0, 3.0, 1.7320508075688772935274463415059)] + [TestCase(0.0, 10.0, 1.0, Double.NaN)] + [TestCase(0.0, 10.0, 2.0, Double.PositiveInfinity)] + [TestCase(0.0, 10.0, 2.5, 22.360679774997896964091736687313)] + [TestCase(0.0, 10.0, Double.PositiveInfinity, 10.0)] + [TestCase(10.0, 1.0, 1.0, Double.NaN)] + [TestCase(10.0, 1.0, 2.5, 2.2360679774997896964091736687313)] + [TestCase(-5.0, 100.0, 1.5, Double.PositiveInfinity)] + [TestCase(0.0, Double.PositiveInfinity, 1.0, Double.NaN)] + public void ValidateStdDev(double location, double scale, double dof, double sdev) { var n = new StudentT(location, scale, dof); Assert.AreEqual(sdev, n.StdDev); @@ -219,11 +255,18 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Degrees of freedom. - [Test, Sequential] - public void ValidateMode( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, -5.0, 0.0)] double location, - [Values(1.0, 0.1, 1.0, 10.0, 10.0, 10.0, 10.0, 1.0, 1.0, 100.0, Double.PositiveInfinity)] double scale, - [Values(1.0, 1.0, 3.0, 1.0, 2.0, 2.5, Double.PositiveInfinity, 1.0, 2.5, 1.5, 1.0)] double dof) + [TestCase(0.0, 1.0, 1.0)] + [TestCase(0.0, 0.1, 1.0)] + [TestCase(0.0, 1.0, 3.0)] + [TestCase(0.0, 10.0, 1.0)] + [TestCase(0.0, 10.0, 2.0)] + [TestCase(0.0, 10.0, 2.5)] + [TestCase(0.0, 10.0, Double.PositiveInfinity)] + [TestCase(10.0, 1.0, 1.0)] + [TestCase(10.0, 1.0, 2.5)] + [TestCase(-5.0, 100.0, 1.5)] + [TestCase(0.0, Double.PositiveInfinity, 1.0)] + public void ValidateMode(double location, double scale, double dof) { var n = new StudentT(location, scale, dof); Assert.AreEqual(location, n.Mode); @@ -235,11 +278,18 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Location value. /// Scale value. /// Degrees of freedom. - [Test, Sequential] - public void ValidateMedian( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 10.0, -5.0, 0.0)] double location, - [Values(1.0, 0.1, 1.0, 10.0, 10.0, 10.0, 10.0, 1.0, 1.0, 100.0, Double.PositiveInfinity)] double scale, - [Values(1.0, 1.0, 3.0, 1.0, 2.0, 2.5, Double.PositiveInfinity, 1.0, 2.5, 1.5, 1.0)] double dof) + [TestCase(0.0, 1.0, 1.0)] + [TestCase(0.0, 0.1, 1.0)] + [TestCase(0.0, 1.0, 3.0)] + [TestCase(0.0, 10.0, 1.0)] + [TestCase(0.0, 10.0, 2.0)] + [TestCase(0.0, 10.0, 2.5)] + [TestCase(0.0, 10.0, Double.PositiveInfinity)] + [TestCase(10.0, 1.0, 1.0)] + [TestCase(10.0, 1.0, 2.5)] + [TestCase(-5.0, 100.0, 1.5)] + [TestCase(0.0, Double.PositiveInfinity, 1.0)] + public void ValidateMedian(double location, double scale, double dof) { var n = new StudentT(location, scale, dof); Assert.AreEqual(location, n.Median); @@ -273,13 +323,20 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Degrees of freedom. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensity( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 1.0, -1.0, 2.0, -2.0, 0.0, 1.0, -1.0, 2.0, -2.0, 0.0, 1.0, 2.0)] double x, - [Values(0.318309886183791, 0.159154943091895, 0.159154943091895, 0.063661977236758, 0.063661977236758, 0.353553390593274, 0.192450089729875, 0.192450089729875, 0.068041381743977, 0.068041381743977, 0.398942280401433, 0.241970724519143, 0.053990966513188)] double p) + [TestCase(0.0, 1.0, 1.0, 0.0, 0.318309886183791)] + [TestCase(0.0, 1.0, 1.0, 1.0, 0.159154943091895)] + [TestCase(0.0, 1.0, 1.0, -1.0, 0.159154943091895)] + [TestCase(0.0, 1.0, 1.0, 2.0, 0.063661977236758)] + [TestCase(0.0, 1.0, 1.0, -2.0, 0.063661977236758)] + [TestCase(0.0, 1.0, 2.0, 0.0, 0.353553390593274)] + [TestCase(0.0, 1.0, 2.0, 1.0, 0.192450089729875)] + [TestCase(0.0, 1.0, 2.0, -1.0, 0.192450089729875)] + [TestCase(0.0, 1.0, 2.0, 2.0, 0.068041381743977)] + [TestCase(0.0, 1.0, 2.0, -2.0, 0.068041381743977)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 0.0, 0.398942280401433)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 1.0, 0.241970724519143)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 2.0, 0.053990966513188)] + public void ValidateDensity(double location, double scale, double dof, double x, double p) { var n = new StudentT(location, scale, dof); AssertHelpers.AlmostEqual(p, n.Density(x), 13); @@ -293,13 +350,20 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Degrees of freedom. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 1.0, -1.0, 2.0, -2.0, 0.0, 1.0, -1.0, 2.0, -2.0, 0.0, 1.0, 2.0)] double x, - [Values(-1.144729885849399, -1.837877066409348, -1.837877066409348, -2.754167798283503, -2.754167798283503, -1.039720770839917, -1.647918433002166, -1.647918433002166, -2.687639203842085, -2.687639203842085, -0.918938533204672, -1.418938533204674, -2.918938533204674)] double p) + [TestCase(0.0, 1.0, 1.0, 0.0, -1.144729885849399)] + [TestCase(0.0, 1.0, 1.0, 1.0, -1.837877066409348)] + [TestCase(0.0, 1.0, 1.0, -1.0, -1.837877066409348)] + [TestCase(0.0, 1.0, 1.0, 2.0, -2.754167798283503)] + [TestCase(0.0, 1.0, 1.0, -2.0, -2.754167798283503)] + [TestCase(0.0, 1.0, 2.0, 0.0, -1.039720770839917)] + [TestCase(0.0, 1.0, 2.0, 1.0, -1.647918433002166)] + [TestCase(0.0, 1.0, 2.0, -1.0, -1.647918433002166)] + [TestCase(0.0, 1.0, 2.0, 2.0, -2.687639203842085)] + [TestCase(0.0, 1.0, 2.0, -2.0, -2.687639203842085)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 0.0, -0.918938533204672)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 1.0, -1.418938533204674)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 2.0, -2.918938533204674)] + public void ValidateDensityLn(double location, double scale, double dof, double x, double p) { var n = new StudentT(location, scale, dof); AssertHelpers.AlmostEqual(p, n.DensityLn(x), 13); @@ -372,13 +436,20 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Degrees of freedom. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, - [Values(0.0, 1.0, -1.0, 2.0, -2.0, 0.0, 1.0, -1.0, 2.0, -2.0, 0.0, 1.0, 2.0)] double x, - [Values(0.5, 0.75, 0.25, 0.852416382349567, 0.147583617650433, 0.5, 0.788675134594813, 0.211324865405187, 0.908248290463863, 0.091751709536137, 0.5, 0.841344746068543, 0.977249868051821)] double c) + [TestCase(0.0, 1.0, 1.0, 0.0, 0.5)] + [TestCase(0.0, 1.0, 1.0, 1.0, 0.75)] + [TestCase(0.0, 1.0, 1.0, -1.0, 0.25)] + [TestCase(0.0, 1.0, 1.0, 2.0, 0.852416382349567)] + [TestCase(0.0, 1.0, 1.0, -2.0, 0.147583617650433)] + [TestCase(0.0, 1.0, 2.0, 0.0, 0.5)] + [TestCase(0.0, 1.0, 2.0, 1.0, 0.788675134594813)] + [TestCase(0.0, 1.0, 2.0, -1.0, 0.211324865405187)] + [TestCase(0.0, 1.0, 2.0, 2.0, 0.908248290463863)] + [TestCase(0.0, 1.0, 2.0, -2.0, 0.091751709536137)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 0.0, 0.5)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 1.0, 0.841344746068543)] + [TestCase(0.0, 1.0, Double.PositiveInfinity, 2.0, 0.977249868051821)] + public void ValidateCumulativeDistribution(double location, double scale, double dof, double x, double c) { var n = new StudentT(location, scale, dof); AssertHelpers.AlmostEqual(c, n.CumulativeDistribution(x), 13); diff --git a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs index 26faf6ba..01963185 100644 --- a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs +++ b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Scale value. - [Test, Combinatorial] - public void CanCreateWeibull([Values(1.0, 10.0)] double shape, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(1.0, 0.1)] + [TestCase(10.0, 1.0)] + [TestCase(11.0, 10.0)] + [TestCase(12.0, Double.PositiveInfinity)] + public void CanCreateWeibull(double shape, double scale) { var n = new Weibull(shape, scale); Assert.AreEqual(shape, n.Shape); @@ -64,8 +67,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// /// Shape value. /// Scale value. - [Test, Sequential] - public void WeibullCreateFailsWithBadParameters([Values(Double.NaN, 1.0, Double.NaN, 1.0, -1.0, -1.0, 0.0, 0.0, 1.0)] double shape, [Values(1.0, Double.NaN, Double.NaN, -1.0, 1.0, -1.0, 0.0, 1.0, 0.0)] double scale) + [TestCase(Double.NaN, 1.0)] + [TestCase(1.0, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + [TestCase(1.0, -1.0)] + [TestCase(-1.0, 1.0)] + [TestCase(-1.0, -1.0)] + [TestCase(0.0, 0.0)] + [TestCase(0.0, 1.0)] + [TestCase(1.0, 0.0)] + public void WeibullCreateFailsWithBadParameters(double shape, double scale) { Assert.Throws(() => new Weibull(shape, scale)); } @@ -84,8 +95,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set shape. /// /// Shape value. - [Test] - public void CanSetShape([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetShape(double shape) { new Weibull(1.0, 1.0) { @@ -97,8 +111,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set shape fails with negative shape. /// /// Shape value. - [Test] - public void SetShapeFailsWithNegativeShape([Values(-1.0, -0.0, 0.0)] double shape) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetShapeFailsWithNegativeShape(double shape) { var n = new Weibull(1.0, 1.0); Assert.Throws(() => n.Shape = shape); @@ -108,8 +124,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Can set scale. /// /// Scale value. - [Test] - public void CanSetScale([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetScale(double scale) { new Weibull(1.0, 1.0) { @@ -121,8 +140,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Set scale fails with negative scale. /// /// Scale value. - [Test] - public void SetScaleFailsWithNegativeScale([Values(-1.0, -0.0, 0.0)] double scale) + [TestCase(-1.0)] + [TestCase(-0.0)] + [TestCase(0.0)] + public void SetScaleFailsWithNegativeScale(double scale) { var n = new Weibull(1.0, 1.0); Assert.Throws(() => n.Scale = scale); @@ -134,11 +155,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Scale value. /// Expected value. - [Test, Sequential] - public void ValidateMean( - [Values(1.0, 1.0, 10.0, 10.0)] double shape, - [Values(0.1, 1.0, 10.0, 1.0)] double scale, - [Values(0.1, 1.0, 9.5135076986687318362924871772654021925505786260884, 0.95135076986687318362924871772654021925505786260884)] double mean) + [TestCase(1.0, 0.1, 0.1)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 9.5135076986687318362924871772654021925505786260884)] + [TestCase(10.0, 1.0, 0.95135076986687318362924871772654021925505786260884)] + public void ValidateMean(double shape, double scale, double mean) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(mean, n.Mean, 13); @@ -150,11 +171,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Scale value. /// Expected value. - [Test, Sequential] - public void ValidateVariance( - [Values(1.0, 1.0, 10.0, 10.0)] double shape, - [Values(0.1, 1.0, 10.0, 1.0)] double scale, - [Values(0.01, 1.0, 1.3100455073468309147154581687505295026863354547057, 0.013100455073468309147154581687505295026863354547057)] double var) + [TestCase(1.0, 0.1, 0.01)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 1.3100455073468309147154581687505295026863354547057)] + [TestCase(10.0, 1.0, 0.013100455073468309147154581687505295026863354547057)] + public void ValidateVariance(double shape, double scale, double var) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(var, n.Variance, 13); @@ -166,11 +187,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Scale value. /// Expected value. - [Test, Sequential] - public void ValidateStdDev( - [Values(1.0, 1.0, 10.0, 10.0)] double shape, - [Values(0.1, 1.0, 10.0, 1.0)] double scale, - [Values(0.1, 1.0, 1.1445721940300799194124723631014002560036613065794, 0.11445721940300799194124723631014002560036613065794)] double sdev) + [TestCase(1.0, 0.1, 0.1)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(10.0, 10.0, 1.1445721940300799194124723631014002560036613065794)] + [TestCase(10.0, 1.0, 0.11445721940300799194124723631014002560036613065794)] + public void ValidateStdDev(double shape, double scale, double sdev) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(sdev, n.StdDev, 13); @@ -182,11 +203,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Scale value. /// Expected value. - [Test, Sequential] - public void ValidateSkewness( - [Values(1.0, 1.0, 10.0, 10.0)] double shape, - [Values(0.1, 1.0, 10.0, 1.0)] double scale, - [Values(2.0, 2.0, -0.63763713390314440916597757156663888653981696212127, -0.63763713390314440916597757156663888653981696212127)] double skewness) + [TestCase(1.0, 0.1, 2.0)] + [TestCase(1.0, 1.0, 2.0)] + [TestCase(10.0, 10.0, -0.63763713390314440916597757156663888653981696212127)] + [TestCase(10.0, 1.0, -0.63763713390314440916597757156663888653981696212127)] + public void ValidateSkewness(double shape, double scale, double skewness) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(skewness, n.Skewness, 11); @@ -198,11 +219,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Scale value. /// Expected value. - [Test, Sequential] - public void ValidateMode( - [Values(1.0, 1.0, 10.0, 10.0)] double shape, - [Values(0.1, 1.0, 10.0, 1.0)] double scale, - [Values(0.0, 0.0, 9.8951925820621439264623017041980483215553841533709, 0.98951925820621439264623017041980483215553841533709)] double mode) + [TestCase(1.0, 0.1, 0.0)] + [TestCase(1.0, 1.0, 0.0)] + [TestCase(10.0, 10.0, 9.8951925820621439264623017041980483215553841533709)] + [TestCase(10.0, 1.0, 0.98951925820621439264623017041980483215553841533709)] + public void ValidateMode(double shape, double scale, double mode) { var n = new Weibull(shape, scale); Assert.AreEqual(mode, n.Mode); @@ -214,11 +235,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Shape value. /// Scale value. /// Expected value. - [Test, Sequential] - public void ValidateMedian( - [Values(1.0, 1.0, 10.0, 10.0)] double shape, - [Values(0.1, 1.0, 10.0, 1.0)] double scale, - [Values(0.069314718055994530941723212145817656807550013436026, 0.69314718055994530941723212145817656807550013436026, 9.6401223546778973665856033763604752124634905617583, 0.96401223546778973665856033763604752124634905617583)] double median) + [TestCase(1.0, 0.1, 0.069314718055994530941723212145817656807550013436026)] + [TestCase(1.0, 1.0, 0.69314718055994530941723212145817656807550013436026)] + [TestCase(10.0, 10.0, 9.6401223546778973665856033763604752124634905617583)] + [TestCase(10.0, 1.0, 0.96401223546778973665856033763604752124634905617583)] + public void ValidateMedian(double shape, double scale, double median) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(median, n.Median, 13); @@ -251,12 +272,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensity( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0)] double shape, - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0)] double scale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(10.0, 0.00045399929762484851535591515560550610237918088866565, 3.7200759760208359629596958038631183373588922923768e-43, 1.0, 0.36787944117144232159552377016146086744581113103177, 0.000045399929762484851535591515560550610237918088866565, 0.0, 9.9999999990000000000499999999983333333333750000000e-10, 0.36787944117144232159552377016146086744581113103177, 0.0, 3.6787944117144232159552377016146086744581113103177, 0.0)] double pdf) + [TestCase(1.0, 0.1, 0.0, 10.0)] + [TestCase(1.0, 0.1, 1.0, 0.00045399929762484851535591515560550610237918088866565)] + [TestCase(1.0, 0.1, 10.0, 3.7200759760208359629596958038631183373588922923768e-43)] + [TestCase(1.0, 1.0, 0.0, 1.0)] + [TestCase(1.0, 1.0, 1.0, 0.36787944117144232159552377016146086744581113103177)] + [TestCase(1.0, 1.0, 10.0, 0.000045399929762484851535591515560550610237918088866565)] + [TestCase(10.0, 10.0, 0.0, 0.0)] + [TestCase(10.0, 10.0, 1.0, 9.9999999990000000000499999999983333333333750000000e-10)] + [TestCase(10.0, 10.0, 10.0, 0.36787944117144232159552377016146086744581113103177)] + [TestCase(10.0, 1.0, 0.0, 0.0)] + [TestCase(10.0, 1.0, 1.0, 3.6787944117144232159552377016146086744581113103177)] + [TestCase(10.0, 1.0, 10.0, 0.0)] + public void ValidateDensity(double shape, double scale, double x, double pdf) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(pdf, n.Density(x), 14); @@ -269,12 +297,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateDensityLn( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0)] double shape, - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0)] double scale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(2.3025850929940456840179914546843642076011014886288, -7.6974149070059543159820085453156357923988985113712, -97.697414907005954315982008545315635792398898511371, 0.0, -1.0, -10.0, Double.NegativeInfinity, -20.723265837046411156161923092159277868409913397659, -1.0, Double.NegativeInfinity, 1.3025850929940456840179914546843642076011014886288, -9.999999976974149070059543159820085453156357923988985113712e9)] double pdfln) + [TestCase(1.0, 0.1, 0.0, 2.3025850929940456840179914546843642076011014886288)] + [TestCase(1.0, 0.1, 1.0, -7.6974149070059543159820085453156357923988985113712)] + [TestCase(1.0, 0.1, 10.0, -97.697414907005954315982008545315635792398898511371)] + [TestCase(1.0, 1.0, 0.0, 0.0)] + [TestCase(1.0, 1.0, 1.0, -1.0)] + [TestCase(1.0, 1.0, 10.0, -10.0)] + [TestCase(10.0, 10.0, 0.0, Double.NegativeInfinity)] + [TestCase(10.0, 10.0, 1.0, -20.723265837046411156161923092159277868409913397659)] + [TestCase(10.0, 10.0, 10.0, -1.0)] + [TestCase(10.0, 1.0, 0.0, Double.NegativeInfinity)] + [TestCase(10.0, 1.0, 1.0, 1.3025850929940456840179914546843642076011014886288)] + [TestCase(10.0, 1.0, 10.0, -9.999999976974149070059543159820085453156357923988985113712e9)] + public void ValidateDensityLn(double shape, double scale, double x, double pdfln) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(pdfln, n.DensityLn(x), 14); @@ -345,12 +380,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous /// Scale value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0)] double shape, - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0)] double scale, - [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, - [Values(0.0, 0.99995460007023751514846440848443944938976208191113, 0.99999999999999999999999999999999999999999996279924, 0.0, 0.63212055882855767840447622983853913255418886896823, 0.99995460007023751514846440848443944938976208191113, 0.0, 9.9999999995000000000166666666662500000000083333333e-11, 0.63212055882855767840447622983853913255418886896823, 0.0, 0.63212055882855767840447622983853913255418886896823, 1.0)] double cdf) + [TestCase(1.0, 0.1, 0.0, 0.0)] + [TestCase(1.0, 0.1, 1.0, 0.99995460007023751514846440848443944938976208191113)] + [TestCase(1.0, 0.1, 10.0, 0.99999999999999999999999999999999999999999996279924)] + [TestCase(1.0, 1.0, 0.0, 0.0)] + [TestCase(1.0, 1.0, 1.0, 0.63212055882855767840447622983853913255418886896823)] + [TestCase(1.0, 1.0, 10.0, 0.99995460007023751514846440848443944938976208191113)] + [TestCase(10.0, 10.0, 0.0, 0.0)] + [TestCase(10.0, 10.0, 1.0, 9.9999999995000000000166666666662500000000083333333e-11)] + [TestCase(10.0, 10.0, 10.0, 0.63212055882855767840447622983853913255418886896823)] + [TestCase(10.0, 1.0, 0.0, 0.0)] + [TestCase(10.0, 1.0, 1.0, 0.63212055882855767840447622983853913255418886896823)] + [TestCase(10.0, 1.0, 10.0, 1.0)] + public void ValidateCumulativeDistribution(double shape, double scale, double x, double cdf) { var n = new Weibull(shape, scale); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 15); diff --git a/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs b/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs index a9252ed0..d37f1874 100644 --- a/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can create Bernoulli. /// /// Probability of one. - [Test] - public void CanCreateBernoulli([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void CanCreateBernoulli(double p) { var bernoulli = new Bernoulli(p); Assert.AreEqual(p, bernoulli.P); @@ -61,8 +63,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Bernoulli create fails with bad parameters. /// /// Probability of one. - [Test] - public void BernoulliCreateFailsWithBadParameters([Values(Double.NaN, -1.0, 2.0)] double p) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(2.0)] + public void BernoulliCreateFailsWithBadParameters(double p) { Assert.Throws(() => new Bernoulli(p)); } @@ -81,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set probability of one. /// /// Probability of one. - [Test] - public void CanSetProbabilityOfOne([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void CanSetProbabilityOfOne(double p) { new Bernoulli(0.3) { @@ -94,8 +100,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set probability of one fails with bad values. /// /// Probability of one. - [Test] - public void SetProbabilityOfOneFails([Values(Double.NaN, -1.0, 2.0)] double p) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(2.0)] + public void SetProbabilityOfOneFails(double p) { var b = new Bernoulli(0.3); Assert.Throws(() => b.P = p); @@ -105,8 +113,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate entropy. /// /// Probability of one. - [Test] - public void ValidateEntropy([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void ValidateEntropy(double p) { var b = new Bernoulli(p); AssertHelpers.AlmostEqual(-((1.0 - p) * Math.Log(1.0 - p)) - (p * Math.Log(p)), b.Entropy, 14); @@ -116,8 +126,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate skewness. /// /// Probability of one. - [Test] - public void ValidateSkewness([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void ValidateSkewness(double p) { var b = new Bernoulli(p); Assert.AreEqual((1.0 - (2.0 * p)) / Math.Sqrt(p * (1.0 - p)), b.Skewness); @@ -128,8 +140,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Probability of one. /// Expected value. - [Test, Sequential] - public void ValidateMode([Values(0.0, 0.3, 1.0)] double p, [Values(0.0, 0.0, 1.0)] double m) + [TestCase(0.0, 0.0)] + [TestCase(0.3, 0.0)] + [TestCase(1.0, 1.0)] + public void ValidateMode(double p, double m) { var b = new Bernoulli(p); Assert.AreEqual(m, b.Mode); @@ -171,11 +185,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Probability of one. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbability( - [Values(0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.3, 1.0, 1.0, 1.0, 1.0)] double p, - [Values(-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2)] int x, - [Values(0.0, 1.0, 0.0, 0.0, 0.0, 0.7, 0.3, 0.0, 0.0, 0.0, 1.0, 0.0)] double d) + [TestCase(0.0, -1, 0.0)] + [TestCase(0.0, 0, 1.0)] + [TestCase(0.0, 1, 0.0)] + [TestCase(0.0, 2, 0.0)] + [TestCase(0.3, -1, 0.0)] + [TestCase(0.3, 0, 0.7)] + [TestCase(0.3, 1, 0.3)] + [TestCase(0.3, 2, 0.0)] + [TestCase(1.0, -1, 0.0)] + [TestCase(1.0, 0, 0.0)] + [TestCase(1.0, 1, 1.0)] + [TestCase(1.0, 2, 0.0)] + public void ValidateProbability(double p, int x, double d) { var b = new Bernoulli(p); Assert.AreEqual(d, b.Probability(x)); @@ -187,11 +209,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Probability of one. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.3, 1.0, 1.0, 1.0, 1.0)] double p, - [Values(-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2)] int x, - [Values(Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -0.35667494393873244235395440410727451457180907089949815, -1.2039728043259360296301803719337238685164245381839102, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, 0.0, Double.NegativeInfinity)] double dln) + [TestCase(0.0, -1, Double.NegativeInfinity)] + [TestCase(0.0, 0, 0.0)] + [TestCase(0.0, 1, Double.NegativeInfinity)] + [TestCase(0.0, 2, Double.NegativeInfinity)] + [TestCase(0.3, -1, Double.NegativeInfinity)] + [TestCase(0.3, 0, -0.35667494393873244235395440410727451457180907089949815)] + [TestCase(0.3, 1, -1.2039728043259360296301803719337238685164245381839102)] + [TestCase(0.3, 2, Double.NegativeInfinity)] + [TestCase(1.0, -1, Double.NegativeInfinity)] + [TestCase(1.0, 0, Double.NegativeInfinity)] + [TestCase(1.0, 1, 0.0)] + [TestCase(1.0, 2, Double.NegativeInfinity)] + public void ValidateProbabilityLn(double p, int x, double dln) { var b = new Bernoulli(p); Assert.AreEqual(dln, b.ProbabilityLn(x)); @@ -261,11 +291,22 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Probability of one. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.3, 0.3, 1.0, 1.0, 1.0, 1.0, 1.0)] double p, - [Values(-1.0, 0.0, 0.5, 1.0, 2.0, -1.0, 0.0, 0.5, 1.0, 2.0, -1.0, 0.0, 0.5, 1.0, 2.0)] double x, - [Values(0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.7, 0.7, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0)] double cdf) + [TestCase(0.0, -1.0, 0.0)] + [TestCase(0.0, 0.0, 1.0)] + [TestCase(0.0, 0.5, 1.0)] + [TestCase(0.0, 1.0, 1.0)] + [TestCase(0.0, 2.0, 1.0)] + [TestCase(0.3, -1.0, 0.0)] + [TestCase(0.3, 0.0, 0.7)] + [TestCase(0.3, 0.5, 0.7)] + [TestCase(0.3, 1.0, 1.0)] + [TestCase(0.3, 2.0, 1.0)] + [TestCase(1.0, -1.0, 0.0)] + [TestCase(1.0, 0.0, 0.0)] + [TestCase(1.0, 0.5, 0.0)] + [TestCase(1.0, 1.0, 1.0)] + [TestCase(1.0, 2.0, 1.0)] + public void ValidateCumulativeDistribution(double p, double x, double cdf) { var b = new Bernoulli(p); Assert.AreEqual(cdf, b.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs b/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs index 5c08e4fb..61b4302b 100644 --- a/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Success probability. /// Number of trials. - [Test, Sequential] - public void CanCreateBinomial([Values(0.0, 0.3, 1.0)] double p, [Values(4, 3, 2)] int n) + [TestCase(0.0, 4)] + [TestCase(0.3, 3)] + [TestCase(1.0, 2)] + public void CanCreateBinomial(double p, int n) { var bernoulli = new Binomial(p, n); Assert.AreEqual(p, bernoulli.P); @@ -63,8 +65,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Success probability. /// Number of trials. - [Test, Sequential] - public void BinomialCreateFailsWithBadParameters([Values(Double.NaN, -1.0, 2.0, 0.3)] double p, [Values(1, 1, 1, -2)] int n) + [TestCase(Double.NaN, 1)] + [TestCase(-1.0, 1)] + [TestCase(2.0, 1)] + [TestCase(0.3, -2)] + public void BinomialCreateFailsWithBadParameters(double p, int n) { Assert.Throws(() => new Binomial(p, n)); } @@ -84,8 +89,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Success probability. /// Number of trials. - [Test, Sequential] - public void CanSetSuccessProbability([Values(0.0, 0.3, 1.0)] double p, [Values(4, 3, 2)] int n) + [TestCase(0.0, 4)] + [TestCase(0.3, 3)] + [TestCase(1.0, 2)] + public void CanSetSuccessProbability(double p, int n) { new Binomial(0.3, n) { @@ -97,8 +104,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set success probability fails with bad values. /// /// Success probability. - [Test] - public void SetProbabilityOfOneFails([Values(Double.NaN, -1.0, 2.0)] double p) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(2.0)] + public void SetProbabilityOfOneFails(double p) { var b = new Binomial(0.3, 1); Assert.Throws(() => b.P = p); @@ -110,8 +119,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Success probability. /// Number of trials. /// Expected value. - [Test, Sequential] - public void ValidateEntropy([Values(0.0, 0.3, 1.0)] double p, [Values(4, 3, 2)] int n, [Values(0.0, 1.1404671643037712668976423399228972051669206536461, 0.0)] double e) + [TestCase(0.0, 4, 0.0)] + [TestCase(0.3, 3, 1.1404671643037712668976423399228972051669206536461)] + [TestCase(1.0, 2, 0.0)] + public void ValidateEntropy(double p, int n, double e) { var b = new Binomial(p, n); AssertHelpers.AlmostEqual(e, b.Entropy, 14); @@ -122,8 +133,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Success probability. /// Number of trials. - [Test, Sequential] - public void ValidateSkewness([Values(0.0, 0.3, 1.0)] double p, [Values(4, 3, 2)] int n) + [TestCase(0.0, 4)] + [TestCase(0.3, 3)] + [TestCase(1.0, 2)] + public void ValidateSkewness(double p, int n) { var b = new Binomial(p, n); Assert.AreEqual((1.0 - (2.0 * p)) / Math.Sqrt(n * p * (1.0 - p)), b.Skewness); @@ -135,8 +148,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Success probability. /// Number of trials. /// Expected value. - [Test, Sequential] - public void ValidateMode([Values(0.0, 0.3, 1.0)] double p, [Values(4, 3, 2)] int n, [Values(0, 1, 2)] int m) + [TestCase(0.0, 4, 0)] + [TestCase(0.3, 3, 1)] + [TestCase(1.0, 2, 2)] + public void ValidateMode(double p, int n, int m) { var b = new Binomial(p, n); Assert.AreEqual(m, b.Mode); @@ -169,12 +184,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Number of trials. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbability( - [Values(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000)] double p, - [Values(1, 1, 3, 3, 3, 10, 10, 10, 1, 1, 3, 3, 3, 10, 10, 10, 1, 1, 3, 3, 3, 10, 10, 10)] int n, - [Values(0, 1, 0, 1, 3, 0, 1, 10, 0, 1, 0, 1, 3, 0, 1, 10, 0, 1, 0, 1, 3, 0, 1, 10)] int x, - [Values(1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.69999999999999995559107901499373838305473327636719, 0.2999999999999999888977697537484345957636833190918, 0.34299999999999993471888615204079956461021032657166, 0.44099999999999992772448109690231306411849135972008, 0.026999999999999997002397833512077451789759292859569, 0.02824752489999998207939855277004937778546385011091, 0.12106082099999992639752977030555903089040470780077, 0.0000059048999999999978147480206303047454017251032868501, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0)] double d) + [TestCase(0.000000, 1, 0, 1.0)] + [TestCase(0.000000, 1, 1, 0.0)] + [TestCase(0.000000, 3, 0, 1.0)] + [TestCase(0.000000, 3, 1, 0.0)] + [TestCase(0.000000, 3, 3, 0.0)] + [TestCase(0.000000, 10, 0, 1.0)] + [TestCase(0.000000, 10, 1, 0.0)] + [TestCase(0.000000, 10, 10, 0.0)] + [TestCase(0.300000, 1, 0, 0.69999999999999995559107901499373838305473327636719)] + [TestCase(0.300000, 1, 1, 0.2999999999999999888977697537484345957636833190918)] + [TestCase(0.300000, 3, 0, 0.34299999999999993471888615204079956461021032657166)] + [TestCase(0.300000, 3, 1, 0.44099999999999992772448109690231306411849135972008)] + [TestCase(0.300000, 3, 3, 0.026999999999999997002397833512077451789759292859569)] + [TestCase(0.300000, 10, 0, 0.02824752489999998207939855277004937778546385011091)] + [TestCase(0.300000, 10, 1, 0.12106082099999992639752977030555903089040470780077)] + [TestCase(0.300000, 10, 10, 0.0000059048999999999978147480206303047454017251032868501)] + [TestCase(1.000000, 1, 0, 0.0)] + [TestCase(1.000000, 1, 1, 1.0)] + [TestCase(1.000000, 3, 0, 0.0)] + [TestCase(1.000000, 3, 1, 0.0)] + [TestCase(1.000000, 3, 3, 1.0)] + [TestCase(1.000000, 10, 0, 0.0)] + [TestCase(1.000000, 10, 1, 0.0)] + [TestCase(1.000000, 10, 10, 1.0)] + public void ValidateProbability(double p, int n, int x, double d) { var b = new Binomial(p, n); AssertHelpers.AlmostEqual(d, b.Probability(x), 14); @@ -187,12 +221,31 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Number of trials. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 0.300000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000)] double p, - [Values(1, 1, 3, 3, 3, 10, 10, 10, 1, 1, 3, 3, 3, 10, 10, 10, 1, 1, 3, 3, 3, 10, 10, 10)] int n, - [Values(0, 1, 0, 1, 3, 0, 1, 10, 0, 1, 0, 1, 3, 0, 1, 10, 0, 1, 0, 1, 3, 0, 1, 10)] int x, - [Values(0.0, Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, -0.3566749439387324423539544041072745145718090708995, -1.2039728043259360296301803719337238685164245381839, -1.0700248318161973270618632123218235437154272126985, -0.81871040353529122294284394322574719301255212216016, -3.6119184129778080888905411158011716055492736145517, -3.566749439387324423539544041072745145718090708995, -2.1114622067804823267977785542148302920616046876506, -12.039728043259360296301803719337238685164245381839, Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, 0.0)] double dln) + [TestCase(0.000000, 1, 0, 0.0)] + [TestCase(0.000000, 1, 1, Double.NegativeInfinity)] + [TestCase(0.000000, 3, 0, 0.0)] + [TestCase(0.000000, 3, 1, Double.NegativeInfinity)] + [TestCase(0.000000, 3, 3, Double.NegativeInfinity)] + [TestCase(0.000000, 10, 0, 0.0)] + [TestCase(0.000000, 10, 1, Double.NegativeInfinity)] + [TestCase(0.000000, 10, 10, Double.NegativeInfinity)] + [TestCase(0.300000, 1, 0, -0.3566749439387324423539544041072745145718090708995)] + [TestCase(0.300000, 1, 1, -1.2039728043259360296301803719337238685164245381839)] + [TestCase(0.300000, 3, 0, -1.0700248318161973270618632123218235437154272126985)] + [TestCase(0.300000, 3, 1, -0.81871040353529122294284394322574719301255212216016)] + [TestCase(0.300000, 3, 3, -3.6119184129778080888905411158011716055492736145517)] + [TestCase(0.300000, 10, 0, -3.566749439387324423539544041072745145718090708995)] + [TestCase(0.300000, 10, 1, -2.1114622067804823267977785542148302920616046876506)] + [TestCase(0.300000, 10, 10, -12.039728043259360296301803719337238685164245381839)] + [TestCase(1.000000, 1, 0, Double.NegativeInfinity)] + [TestCase(1.000000, 1, 1, 0.0)] + [TestCase(1.000000, 3, 0, Double.NegativeInfinity)] + [TestCase(1.000000, 3, 1, Double.NegativeInfinity)] + [TestCase(1.000000, 3, 3, 0.0)] + [TestCase(1.000000, 10, 0, Double.NegativeInfinity)] + [TestCase(1.000000, 10, 1, Double.NegativeInfinity)] + [TestCase(1.000000, 10, 10, 0.0)] + public void ValidateProbabilityLn(double p, int n, int x, double dln) { var b = new Binomial(p, n); AssertHelpers.AlmostEqual(dln, b.ProbabilityLn(x), 14); diff --git a/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs b/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs index 8dd88df9..64f1d60e 100644 --- a/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Lambda value. /// Nu parameter. - [Test, Combinatorial] - public void CanCreateConwayMaxwellPoisson([Values(0.1, 1.0, 2.5, 10.0, Double.PositiveInfinity)] double lambda, [Values(0.0, 2.5, Double.PositiveInfinity)] double nu) + [TestCase(0.1, 0.0)] + [TestCase(1.0, 2.5)] + [TestCase(2.5, 3.0)] + [TestCase(10.0, 3.5)] + [TestCase(Double.PositiveInfinity, Double.PositiveInfinity)] + public void CanCreateConwayMaxwellPoisson(double lambda, double nu) { var d = new ConwayMaxwellPoisson(lambda, nu); Assert.AreEqual(lambda, d.Lambda); @@ -82,8 +86,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set lambda. /// /// Lambda value. - [Test] - public void CanSetLambda([Values(0.1, 3.0, 10.0, Double.PositiveInfinity)] double lambda) + [TestCase(0.1)] + [TestCase(3.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetLambda(double lambda) { new ConwayMaxwellPoisson(1.0, 2.0) { @@ -95,8 +102,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set Nu. /// /// Nu parameter. - [Test] - public void CanSetNu([Values(0.0, 3.0, 10.0, Double.PositiveInfinity)] double nu) + [TestCase(0.0)] + [TestCase(3.0)] + [TestCase(10.0)] + [TestCase(Double.PositiveInfinity)] + public void CanSetNu(double nu) { new ConwayMaxwellPoisson(1.0, 2.0) { @@ -108,8 +118,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set lambda with bad values fails. /// /// Lambda value. - [Test] - public void SetLambdaFails([Values(0.0, -0.0, -1.0, Double.NegativeInfinity)] double lambda) + [TestCase(0.0)] + [TestCase(-0.0)] + [TestCase(-1.0)] + [TestCase(Double.NegativeInfinity)] + public void SetLambdaFails(double lambda) { var d = new ConwayMaxwellPoisson(1.0, 2.0); Assert.Throws(() => d.Lambda = lambda); @@ -119,8 +132,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set Nu with bad values fails. /// /// Nu parameter. - [Test] - public void SetNuFails([Values(-0.1, -1.0, -10.0, Double.NegativeInfinity)] double nu) + [TestCase(-0.1)] + [TestCase(-1.0)] + [TestCase(-10.0)] + [TestCase(Double.NegativeInfinity)] + public void SetNuFails(double nu) { var d = new ConwayMaxwellPoisson(1.0, 2.0); Assert.Throws(() => d.Nu = nu); @@ -172,11 +188,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lambda value. /// Nu parameter. /// Expected value. - [Test, Sequential] - public void ValidateMean( - [Values(1, 2, 10, 20, 1, 2)] int lambda, - [Values(1, 1, 1, 1, 2, 2)] int nu, - [Values(1.0, 2.0, 10.0, 20.0, 0.697774657964008, 1.12635723962342)] double mean) + [TestCase(1, 1, 1.0)] + [TestCase(2, 1, 2.0)] + [TestCase(10, 1, 10.0)] + [TestCase(20, 1, 20.0)] + [TestCase(1, 2, 0.697774657964008)] + [TestCase(2, 2, 1.12635723962342)] + public void ValidateMean(int lambda, int nu, double mean) { var d = new ConwayMaxwellPoisson(lambda, nu); AssertHelpers.AlmostEqual(mean, d.Mean, 10); @@ -209,12 +227,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Nu parameter. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbability( - [Values(1.0, 1.0, 2.0, 2.0, 2.0, 2.0)] double lambda, - [Values(1.0, 1.0, 1.0, 1.0, 2.0, 2.0)] double nu, - [Values(1, 2, 1, 2, 1, 3)] int x, - [Values(0.367879441171442, 0.183939720585721, 0.270670566473225, 0.270670566473225, 0.470328074204904, 0.052258674911656)] double p) + [TestCase(1.0, 1.0, 1, 0.367879441171442)] + [TestCase(1.0, 1.0, 2, 0.183939720585721)] + [TestCase(2.0, 1.0, 1, 0.270670566473225)] + [TestCase(2.0, 1.0, 2, 0.270670566473225)] + [TestCase(2.0, 2.0, 1, 0.470328074204904)] + [TestCase(2.0, 2.0, 3, 0.052258674911656)] + public void ValidateProbability(double lambda, double nu, int x, double p) { var d = new ConwayMaxwellPoisson(lambda, nu); AssertHelpers.AlmostEqual(p, d.Probability(x), 13); @@ -227,12 +246,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Nu parameter. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(1.0, 1.0, 2.0, 2.0, 2.0, 2.0)] double lambda, - [Values(1.0, 1.0, 1.0, 1.0, 2.0, 2.0)] double nu, - [Values(1, 2, 1, 2, 1, 3)] int x, - [Values(-1.0, -1.69314718055995, -1.30685281944005, -1.30685281944005, -0.754324797564617, -2.95154937490084)] double pln) + [TestCase(1.0, 1.0, 1, -1.0)] + [TestCase(1.0, 1.0, 2, -1.69314718055995)] + [TestCase(2.0, 1.0, 1, -1.30685281944005)] + [TestCase(2.0, 1.0, 2, -1.30685281944005)] + [TestCase(2.0, 2.0, 1, -0.754324797564617)] + [TestCase(2.0, 2.0, 3, -2.95154937490084)] + public void ValidateProbabilityLn(double lambda, double nu, int x, double pln) { var d = new ConwayMaxwellPoisson(lambda, nu); AssertHelpers.AlmostEqual(pln, d.ProbabilityLn(x), 13); @@ -266,12 +286,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Nu parameter. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(1.0, 1.0, 2.0, 2.0, 2.0, 2.0)] double lambda, - [Values(1.0, 1.0, 1.0, 1.0, 2.0, 2.0)] double nu, - [Values(1, 2, 1, 2, 1, 3)] int x, - [Values(0.735758882342885, 0.919698602928606, 0.406005849709838, 0.676676416183064, 0.705492111307356, 0.992914823321464)] double cdf) + [TestCase(1.0, 1.0, 1, 0.735758882342885)] + [TestCase(1.0, 1.0, 2, 0.919698602928606)] + [TestCase(2.0, 1.0, 1, 0.406005849709838)] + [TestCase(2.0, 1.0, 2, 0.676676416183064)] + [TestCase(2.0, 2.0, 1, 0.705492111307356)] + [TestCase(2.0, 2.0, 3, 0.992914823321464)] + public void ValidateCumulativeDistribution(double lambda, double nu, int x, double cdf) { var d = new ConwayMaxwellPoisson(lambda, nu); AssertHelpers.AlmostEqual(cdf, d.CumulativeDistribution(x), 13); diff --git a/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs b/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs index f94cdfb1..cf740cb4 100644 --- a/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs @@ -51,8 +51,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void CanCreateDiscreteUniform([Values(-10, 0, 10, 20)] int l, [Values(10, 4, 20, 20)] int u) + [TestCase(-10, 10)] + [TestCase(0, 4)] + [TestCase(10, 20)] + [TestCase(20, 20)] + public void CanCreateDiscreteUniform(int l, int u) { var du = new DiscreteUniform(l, u); Assert.AreEqual(l, du.LowerBound); @@ -64,8 +67,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void DiscreteUniformCreateFailsWithBadParameters([Values(-1, 6)] int l, [Values(-2, 5)] int u) + [TestCase(-1, -2)] + [TestCase(6, 5)] + public void DiscreteUniformCreateFailsWithBadParameters(int l, int u) { Assert.Throws(() => new DiscreteUniform(l, u)); } @@ -84,8 +88,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set lower bound. /// /// Lower bound. - [Test] - public void CanSetLowerBound([Values(0, 3, 10)] int p) + [TestCase(0)] + [TestCase(3)] + [TestCase(10)] + public void CanSetLowerBound(int p) { new DiscreteUniform(0, 10) { @@ -97,8 +103,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set upper bound. /// /// Upper bound. - [Test] - public void CanSetUpperBound([Values(0, 3, 10)] int p) + [TestCase(0)] + [TestCase(3)] + [TestCase(10)] + public void CanSetUpperBound(int p) { new DiscreteUniform(0, 10) { @@ -110,8 +118,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set lower bound with bad values fails. /// /// Lower bound. - [Test] - public void SetLowerBoundFails([Values(11, 20)] int p) + [TestCase(11)] + [TestCase(20)] + public void SetLowerBoundFails(int p) { var b = new DiscreteUniform(0, 10); Assert.Throws(() => b.LowerBound = p); @@ -121,8 +130,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set upper bound with bad values fails /// /// Upper bound. - [Test] - public void SetUpperBoundFails([Values(-11, -20)] int p) + [TestCase(-11)] + [TestCase(-20)] + public void SetUpperBoundFails(int p) { var b = new DiscreteUniform(0, 10); Assert.Throws(() => b.UpperBound = p); @@ -134,8 +144,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lower bound. /// Upper bound. /// Expceted value. - [Test, Sequential] - public void ValidateEntropy([Values(-10, 0, 10, 20)] int l, [Values(10, 4, 20, 20)] int u, [Values(3.0445224377234229965005979803657054342845752874046093, 1.6094379124341003746007593332261876395256013542685181, 2.3978952727983705440619435779651292998217068539374197, 0.0)] double e) + [TestCase(-10, 10, 3.0445224377234229965005979803657054342845752874046093)] + [TestCase(0, 4, 1.6094379124341003746007593332261876395256013542685181)] + [TestCase(10, 20, 2.3978952727983705440619435779651292998217068539374197)] + [TestCase(20, 20, 0.0)] + public void ValidateEntropy(int l, int u, double e) { var du = new DiscreteUniform(l, u); AssertHelpers.AlmostEqual(e, du.Entropy, 14); @@ -146,8 +159,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Lower bound. /// Upper bound. - [Test, Sequential] - public void ValidateSkewness([Values(-10, 0, 10, 20)] int l, [Values(10, 4, 20, 20)] int u) + [TestCase(-10, 10)] + [TestCase(0, 4)] + [TestCase(10, 20)] + [TestCase(20, 20)] + public void ValidateSkewness(int l, int u) { var du = new DiscreteUniform(l, u); Assert.AreEqual(0.0, du.Skewness); @@ -159,8 +175,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lower bound. /// Upper bound. /// Expceted value. - [Test, Sequential] - public void ValidateMode([Values(-10, 0, 10, 20)] int l, [Values(10, 4, 20, 20)] int u, [Values(0, 2, 15, 20)] int m) + [TestCase(-10, 10, 0)] + [TestCase(0, 4, 2)] + [TestCase(10, 20, 15)] + [TestCase(20, 20, 20)] + public void ValidateMode(int l, int u, int m) { var du = new DiscreteUniform(l, u); Assert.AreEqual(m, du.Mode); @@ -172,8 +191,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lower bound. /// Upper bound. /// Expceted value. - [Test, Sequential] - public void ValidateMedian([Values(-10, 0, 10, 20)] int l, [Values(10, 4, 20, 20)] int u, [Values(0, 2, 15, 20)] int m) + [TestCase(-10, 10, 0)] + [TestCase(0, 4, 2)] + [TestCase(10, 20, 15)] + [TestCase(20, 20, 20)] + public void ValidateMedian(int l, int u, int m) { var du = new DiscreteUniform(l, u); Assert.AreEqual(m, du.Median); @@ -185,8 +207,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lower bound. /// Upper bound. /// Expceted value. - [Test, Sequential] - public void ValidateMean([Values(-10, 0, 10, 20)] int l, [Values(10, 4, 20, 20)] int u, [Values(0, 2, 15, 20)] int m) + [TestCase(-10, 10, 0)] + [TestCase(0, 4, 2)] + [TestCase(10, 20, 15)] + [TestCase(20, 20, 20)] + public void ValidateMean(int l, int u, int m) { var du = new DiscreteUniform(l, u); Assert.AreEqual(m, du.Mean); @@ -219,8 +244,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Upper bound. /// Input X value. /// Expceted value. - [Test, Sequential] - public void ValidateProbability([Values(-10, -10, -10, -10, -10)] int l, [Values(10, 10, 10, -10, -10)] int u, [Values(-5, 1, 10, 0, -10)] int x, [Values(1 / 21.0, 1 / 21.0, 1 / 21.0, 0.0, 1.0)] double p) + [TestCase(-10, 10, -5, 1 / 21.0)] + [TestCase(-10, 10, 1, 1 / 21.0)] + [TestCase(-10, 10, 10, 1 / 21.0)] + [TestCase(-10, -10, 0, 0.0)] + [TestCase(-10, -10, -10, 1.0)] + public void ValidateProbability(int l, int u, int x, double p) { var b = new DiscreteUniform(l, u); Assert.AreEqual(p, b.Probability(x)); @@ -233,12 +262,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Upper bound. /// Input X value. /// Expceted value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(-10, -10, -10, -10, -10)] int l, - [Values(10, 10, 10, -10, -10)] int u, - [Values(-5, 1, 10, 0, -10)] int x, - [Values(-3.0445224377234229965005979803657054342845752874046093, -3.0445224377234229965005979803657054342845752874046093, -3.0445224377234229965005979803657054342845752874046093, Double.NegativeInfinity, 0.0)] double dln) + [TestCase(-10, 10, -5, -3.0445224377234229965005979803657054342845752874046093)] + [TestCase(-10, 10, 1, -3.0445224377234229965005979803657054342845752874046093)] + [TestCase(-10, 10, 10, -3.0445224377234229965005979803657054342845752874046093)] + [TestCase(-10, -10, 0, Double.NegativeInfinity)] + [TestCase(-10, -10, -10, 0.0)] + public void ValidateProbabilityLn(int l, int u, int x, double dln) { var b = new DiscreteUniform(l, u); Assert.AreEqual(dln, b.ProbabilityLn(x)); @@ -309,12 +338,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Upper bound. /// Input X value. /// Expceted value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(-10, -10, -10, -10, -10, -10)] int l, - [Values(10, 10, 10, -10, -10, -10)] int u, - [Values(-5, 1, 10, 0, -10, -11)] double x, - [Values(6.0 / 21.0, 12.0 / 21.0, 1.0, 1.0, 1.0, 0.0)] double cdf) + [TestCase(-10, 10, -5, 6.0 / 21.0)] + [TestCase(-10, 10, 1, 12.0 / 21.0)] + [TestCase(-10, 10, 10, 1.0)] + [TestCase(-10, -10, 0, 1.0)] + [TestCase(-10, -10, -10, 1.0)] + [TestCase(-10, -10, -11, 0.0)] + public void ValidateCumulativeDistribution(int l, int u, double x, double cdf) { var b = new DiscreteUniform(l, u); Assert.AreEqual(cdf, b.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs b/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs index 40e33eae..97a75579 100644 --- a/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can create Geometric. /// /// Probability of generating a one. - [Test] - public void CanCreateGeometric([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void CanCreateGeometric(double p) { var d = new Geometric(p); Assert.AreEqual(p, d.P); @@ -61,8 +63,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Geometric create fails with bad parameters. /// /// Probability of generating a one. - [Test] - public void GeometricCreateFailsWithBadParameters([Values(Double.NaN, -1.0, 2.0)] double p) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(2.0)] + public void GeometricCreateFailsWithBadParameters(double p) { Assert.Throws(() => new Geometric(p)); } @@ -81,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set probability of one. /// /// Probability of generating a one. - [Test] - public void CanSetProbabilityOfOne([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void CanSetProbabilityOfOne(double p) { new Geometric(0.3) { @@ -94,8 +100,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set probability of one with a bad value fails. /// /// Probability of generating a one. - [Test] - public void SetProbabilityOfOneFails([Values(Double.NaN, -1.0, 2.0)] double p) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(2.0)] + public void SetProbabilityOfOneFails(double p) { var d = new Geometric(0.3); Assert.Throws(() => d.P = p); @@ -105,8 +113,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate entropy. /// /// Probability of generating a one. - [Test] - public void ValidateEntropy([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void ValidateEntropy(double p) { var d = new Geometric(p); Assert.AreEqual(((-p * Math.Log(p, 2.0)) - ((1.0 - p) * Math.Log(1.0 - p, 2.0))) / p, d.Entropy); @@ -116,8 +126,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate skewness. /// /// Probability of generating a one. - [Test] - public void ValidateSkewness([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void ValidateSkewness(double p) { var d = new Geometric(p); Assert.AreEqual((2.0 - p) / Math.Sqrt(1.0 - p), d.Skewness); @@ -127,8 +139,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate mode. /// /// Probability of generating a one. - [Test] - public void ValidateMode([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void ValidateMode(double p) { var d = new Geometric(p); Assert.AreEqual(1, d.Mode); @@ -138,8 +152,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate median. /// /// Probability of generating a one. - [Test] - public void ValidateMedian([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void ValidateMedian(double p) { var d = new Geometric(p); Assert.AreEqual((int)Math.Ceiling(-Math.Log(2.0) / Math.Log(1 - p)), d.Median); @@ -170,8 +186,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Probability of generating a one. /// Input X value. - [Test, Combinatorial] - public void ValidateProbability([Values(0.0, 0.3, 1.0)] double p, [Values(-1, 0, 1, 2)] int x) + [TestCase(0.0, -1)] + [TestCase(0.3, 0)] + [TestCase(1.0, 1)] + [TestCase(1.0, 2)] + public void ValidateProbability(double p, int x) { var d = new Geometric(p); if (x > 0) @@ -190,11 +209,19 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Probability of generating a one. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.3, 1.0, 1.0, 1.0, 1.0)] double p, - [Values(-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2)] int x, - [Values(Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -0.35667494393873244235395440410727451457180907089949815, -1.2039728043259360296301803719337238685164245381839102, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, 0.0, Double.NegativeInfinity)] double pln) + [TestCase(0.0, -1, Double.NegativeInfinity)] + [TestCase(0.0, 0, 0.0)] + [TestCase(0.0, 1, Double.NegativeInfinity)] + [TestCase(0.0, 2, Double.NegativeInfinity)] + [TestCase(0.3, -1, Double.NegativeInfinity)] + [TestCase(0.3, 0, -0.35667494393873244235395440410727451457180907089949815)] + [TestCase(0.3, 1, -1.2039728043259360296301803719337238685164245381839102)] + [TestCase(0.3, 2, Double.NegativeInfinity)] + [TestCase(1.0, -1, Double.NegativeInfinity)] + [TestCase(1.0, 0, Double.NegativeInfinity)] + [TestCase(1.0, 1, 0.0)] + [TestCase(1.0, 2, Double.NegativeInfinity)] + public void ValidateProbabilityLn(double p, int x, double pln) { var d = new Geometric(p); if (x > 0) @@ -233,8 +260,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Probability of generating a one. /// Input X value. - [Test, Combinatorial] - public void ValidateCumulativeDistribution([Values(0.0, 0.3, 1.0)] double p, [Values(-1, 0, 1, 2)] int x) + [TestCase(0.0, -1)] + [TestCase(0.3, 0)] + [TestCase(1.0, 1)] + [TestCase(1.0, 2)] + public void ValidateCumulativeDistribution(double p, int x) { var d = new Geometric(p); Assert.AreEqual(1.0 - Math.Pow(1.0 - p, x), d.CumulativeDistribution(x)); diff --git a/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs b/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs index dcdb4d1f..966f610f 100644 --- a/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -52,8 +52,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Population size. /// M parameter. /// N parameter. - [Test, Sequential] - public void CanCreateHypergeometric([Values(0, 1, 2, 2, 10, 10)] int size, [Values(0, 1, 1, 2, 1, 5)] int m, [Values(0, 1, 1, 2, 1, 3)] int n) + [TestCase(0, 0, 0)] + [TestCase(1, 1, 1)] + [TestCase(2, 1, 1)] + [TestCase(2, 2, 2)] + [TestCase(10, 1, 1)] + [TestCase(10, 5, 3)] + public void CanCreateHypergeometric(int size, int m, int n) { var d = new Hypergeometric(size, m, n); Assert.AreEqual(size, d.PopulationSize); @@ -67,8 +72,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Population size. /// M parameter. /// N parameter. - [Test, Sequential] - public void HypergeometricCreateFailsWithBadParameters([Values(2, 10, -2, 0)] int size, [Values(3, 5, 1, 1)] int m, [Values(2, 20, 1, 1)] int n) + [TestCase(2, 3, 2)] + [TestCase(10, 5, 20)] + [TestCase(-2, 1, 1)] + [TestCase(0, 1, 1)] + public void HypergeometricCreateFailsWithBadParameters(int size, int m, int n) { Assert.Throws(() => new Hypergeometric(size, m, n)); } @@ -87,8 +95,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set size. /// /// Population size. - [Test] - public void CanSetSize([Values(5, 10, 20)] int size) + [TestCase(5)] + [TestCase(10)] + [TestCase(20)] + public void CanSetSize(int size) { new Hypergeometric(10, 1, 1) { @@ -100,8 +110,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set size fails with bad values. /// /// Population size. - [Test] - public void SetSizeFails([Values(-1, 0)] int size) + [TestCase(-1)] + [TestCase(0)] + public void SetSizeFails(int size) { var d = new Hypergeometric(10, 1, 1); Assert.Throws(() => d.PopulationSize = size); @@ -111,8 +122,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set M. /// /// M parameter. - [Test] - public void CanSetm([Values(0, 1, 2, 5)] int m) + [TestCase(0)] + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + public void CanSetm(int m) { new Hypergeometric(10, 1, 1) { @@ -124,8 +138,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set M fails with bad values. /// /// M parameter. - [Test] - public void SetmFails([Values(11, -1)] int m) + [TestCase(11)] + [TestCase(-1)] + public void SetmFails(int m) { var d = new Hypergeometric(10, 1, 1); Assert.Throws(() => d.M = m); @@ -135,8 +150,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set N. /// /// N parameter. - [Test] - public void CanSetn([Values(0, 1, 2, 5)] int n) + [TestCase(0)] + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + public void CanSetn(int n) { new Hypergeometric(10, 1, 1) { @@ -148,8 +166,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set N fails with bad values. /// /// N parameter. - [Test] - public void SetnFails([Values(11, -1)] int n) + [TestCase(11)] + [TestCase(-1)] + public void SetnFails(int n) { var d = new Hypergeometric(10, 1, 1); Assert.Throws(() => d.N = n); @@ -171,8 +190,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Population size. /// M parameter. /// N parameter. - [Test, Sequential] - public void ValidateSkewness([Values(0, 1, 2, 2, 10, 10)] int size, [Values(0, 1, 1, 2, 1, 5)] int m, [Values(0, 1, 1, 2, 1, 3)] int n) + [TestCase(0, 0, 0)] + [TestCase(1, 1, 1)] + [TestCase(2, 1, 1)] + [TestCase(2, 2, 2)] + [TestCase(10, 1, 1)] + [TestCase(10, 5, 3)] + public void ValidateSkewness(int size, int m, int n) { var d = new Hypergeometric(size, m, n); Assert.AreEqual((Math.Sqrt(size - 1.0) * (size - (2 * n)) * (size - (2 * m))) / (Math.Sqrt(n * m * (size - m) * (size - n)) * (size - 2.0)), d.Skewness); @@ -184,8 +208,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Population size. /// M parameter. /// N parameter. - [Test, Sequential] - public void ValidateMode([Values(0, 1, 2, 2, 10, 10)] int size, [Values(0, 1, 1, 2, 1, 5)] int m, [Values(0, 1, 1, 2, 1, 3)] int n) + [TestCase(0, 0, 0)] + [TestCase(1, 1, 1)] + [TestCase(2, 1, 1)] + [TestCase(2, 2, 2)] + [TestCase(10, 1, 1)] + [TestCase(10, 5, 3)] + public void ValidateMode(int size, int m, int n) { var d = new Hypergeometric(size, m, n); Assert.AreEqual((n + 1) * (m + 1) / (size + 2), d.Mode); @@ -207,8 +236,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Population size. /// M parameter. /// N parameter. - [Test, Sequential] - public void ValidateMinimum([Values(0, 1, 2, 2, 10, 10)] int size, [Values(0, 1, 1, 2, 1, 5)] int m, [Values(0, 1, 1, 2, 1, 3)] int n) + [TestCase(0, 0, 0)] + [TestCase(1, 1, 1)] + [TestCase(2, 1, 1)] + [TestCase(2, 2, 2)] + [TestCase(10, 1, 1)] + [TestCase(10, 5, 3)] + public void ValidateMinimum(int size, int m, int n) { var d = new Hypergeometric(size, m, n); Assert.AreEqual(Math.Max(0, n + m - size), d.Minimum); @@ -220,8 +254,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Population size. /// M parameter. /// N parameter. - [Test, Sequential] - public void ValidateMaximum([Values(0, 1, 2, 2, 10, 10)] int size, [Values(0, 1, 1, 2, 1, 5)] int m, [Values(0, 1, 1, 2, 1, 3)] int n) + [TestCase(0, 0, 0)] + [TestCase(1, 1, 1)] + [TestCase(2, 1, 1)] + [TestCase(2, 2, 2)] + [TestCase(10, 1, 1)] + [TestCase(10, 5, 3)] + public void ValidateMaximum(int size, int m, int n) { var d = new Hypergeometric(size, m, n); Assert.AreEqual(Math.Min(m, n), d.Maximum); @@ -234,12 +273,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// M parameter. /// N parameter. /// Input X value. - [Test, Sequential] - public void ValidateProbability( - [Values(0, 1, 2, 2, 2, 10, 10, 10, 10)] int size, - [Values(0, 1, 1, 1, 2, 1, 1, 5, 5)] int m, - [Values(0, 1, 1, 1, 2, 1, 1, 3, 3)] int n, - [Values(0, 1, 0, 1, 2, 0, 1, 1, 3)] int x) + [TestCase(0, 0, 0, 0)] + [TestCase(1, 1, 1, 1)] + [TestCase(2, 1, 1, 0)] + [TestCase(2, 1, 1, 1)] + [TestCase(2, 2, 2, 2)] + [TestCase(10, 1, 1, 0)] + [TestCase(10, 1, 1, 1)] + [TestCase(10, 5, 3, 1)] + [TestCase(10, 5, 3, 3)] + public void ValidateProbability(int size, int m, int n, int x) { var d = new Hypergeometric(size, m, n); Assert.AreEqual(SpecialFunctions.Binomial(m, x) * SpecialFunctions.Binomial(size - m, n - x) / SpecialFunctions.Binomial(size, n), d.Probability(x)); @@ -252,12 +295,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// M parameter. /// N parameter. /// Input X value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(0, 1, 2, 2, 2, 10, 10, 10, 10)] int size, - [Values(0, 1, 1, 1, 2, 1, 1, 5, 5)] int m, - [Values(0, 1, 1, 1, 2, 1, 1, 3, 3)] int n, - [Values(0, 1, 0, 1, 2, 0, 1, 1, 3)] int x) + [TestCase(0, 0, 0, 0)] + [TestCase(1, 1, 1, 1)] + [TestCase(2, 1, 1, 0)] + [TestCase(2, 1, 1, 1)] + [TestCase(2, 2, 2, 2)] + [TestCase(10, 1, 1, 0)] + [TestCase(10, 1, 1, 1)] + [TestCase(10, 5, 3, 1)] + [TestCase(10, 5, 3, 3)] + public void ValidateProbabilityLn(int size, int m, int n, int x) { var d = new Hypergeometric(size, m, n); Assert.AreEqual(Math.Log(d.Probability(x)), d.ProbabilityLn(x)); @@ -292,13 +339,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// N parameter. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(0, 1, 2, 2, 2, 10, 10, 10, 10)] int size, - [Values(0, 1, 1, 1, 2, 1, 1, 5, 5)] int m, - [Values(0, 1, 1, 1, 2, 1, 1, 3, 3)] int n, - [Values(0.5, 1.1, 0.3, 1.2, 2.4, 0.3, 1.2, 1.1, 3.0)] double x, - [Values(1.0, 1.0, 0.5, 1.0, 1.0, 0.9, 1.0, 0.5, 0.916666666666667)] double cdf) + [TestCase(0, 0, 0, 0.5, 1.0)] + [TestCase(1, 1, 1, 1.1, 1.0)] + [TestCase(2, 1, 1, 0.3, 0.5)] + [TestCase(2, 1, 1, 1.2, 1.0)] + [TestCase(2, 2, 2, 2.4, 1.0)] + [TestCase(10, 1, 1, 0.3, 0.9)] + [TestCase(10, 1, 1, 1.2, 1.0)] + [TestCase(10, 5, 3, 1.1, 0.5)] + [TestCase(10, 5, 3, 3.0, 0.916666666666667)] + public void ValidateCumulativeDistribution(int size, int m, int n, double x, double cdf) { var d = new Hypergeometric(size, m, n); AssertHelpers.AlmostEqual(cdf, d.CumulativeDistribution(x), 14); diff --git a/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs b/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs index c7120f01..3ff80070 100644 --- a/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Number of trials. /// Probability of success. - [Test, Combinatorial] - public void CanCreateNegativeBinomial([Values(0.0, 0.1, 1.0)] double r, [Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0, 0.0)] + [TestCase(0.1, 0.3)] + [TestCase(1.0, 1.0)] + public void CanCreateNegativeBinomial(double r, double p) { var d = new NegativeBinomial(r, p); Assert.AreEqual(r, d.R); @@ -64,8 +66,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Number of trials. /// Probability of success. - [Test, Sequential] - public void NegativeBinomialCreateFailsWithBadParameters([Values(0.0, 0.0, 0.0, Double.NegativeInfinity, -1.0, Double.NaN, Double.NegativeInfinity, Double.NaN)] double r, [Values(Double.NaN, -1.0, 2.0, 0.0, 0.3, 1.0, Double.NaN, Double.NaN)] double p) + [TestCase(0.0, Double.NaN)] + [TestCase(0.0, -1.0)] + [TestCase(0.0, 2.0)] + [TestCase(Double.NegativeInfinity, 0.0)] + [TestCase(-1.0, 0.3)] + [TestCase(Double.NaN, 1.0)] + [TestCase(Double.NegativeInfinity, Double.NaN)] + [TestCase(Double.NaN, Double.NaN)] + public void NegativeBinomialCreateFailsWithBadParameters(double r, double p) { Assert.Throws(() => new NegativeBinomial(r, p)); } @@ -84,8 +93,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set R. /// /// Number of trials. - [Test] - public void CanSetR([Values(0.0, 0.1, 1.0)] double r) + [TestCase(0.0)] + [TestCase(0.1)] + [TestCase(1.0)] + public void CanSetR(double r) { new NegativeBinomial(1.0, 0.5) { @@ -97,8 +108,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set R fails with bad values. /// /// Number of trials. - [Test] - public void SetRFails([Values(Double.NaN, -1.0, Double.NegativeInfinity)] double r) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(Double.NegativeInfinity)] + public void SetRFails(double r) { var d = new NegativeBinomial(1.0, 0.5); Assert.Throws(() => d.R = r); @@ -108,8 +121,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set probability of one. /// /// Probability of success. - [Test] - public void CanSetProbabilityOfOne([Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0)] + [TestCase(0.3)] + [TestCase(1.0)] + public void CanSetProbabilityOfOne(double p) { new NegativeBinomial(1.0, 0.5) { @@ -121,8 +136,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set probability of one fails with bad values. /// /// Probability of success. - [Test] - public void SetProbabilityOfOneFails([Values(Double.NaN, -1.0, 2.0)] double p) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(2.0)] + public void SetProbabilityOfOneFails(double p) { var d = new NegativeBinomial(1.0, 0.5); Assert.Throws(() => d.P = p); @@ -143,8 +160,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Number of trials. /// Probability of success. - [Test, Combinatorial] - public void ValidateSkewness([Values(0.0, 0.1, 1.0)] double r, [Values(0.0, 0.3, 1.0)] double p) + [TestCase(0.0, 0.0)] + [TestCase(0.1, 0.3)] + [TestCase(1.0, 1.0)] + public void ValidateSkewness(double r, double p) { var b = new NegativeBinomial(r, p); Assert.AreEqual((2.0 - p) / Math.Sqrt(r * (1.0 - p)), b.Skewness); @@ -155,8 +174,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// Number of trials. /// Probability of success. - [Test, Sequential] - public void ValidateMode([Values(0.0, 0.3, 1.0)] double r, [Values(0.0, 0.0, 1.0)] double p) + [TestCase(0.0, 0.0)] + [TestCase(0.3, 0.0)] + [TestCase(1.0, 1.0)] + public void ValidateMode(double r, double p) { var d = new NegativeBinomial(r, p); if (r > 1) @@ -205,8 +226,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Number of trials. /// Probability of success. /// Input X value. - [Test, Combinatorial] - public void ValidateProbability([Values(0.0, 0.1, 1.0)] double r, [Values(0.0, 0.3, 1.0)] double p, [Values(0, 1, 2, 3, 5)] int x) + [TestCase(0.0, 0.0, 0)] + [TestCase(0.1, 0.3, 1)] + [TestCase(1.0, 1.0, 2)] + [TestCase(1.0, 1.0, 3)] + [TestCase(1.0, 1.0, 5)] + public void ValidateProbability(double r, double p, int x) { var d = new NegativeBinomial(r, p); Assert.AreEqual(Math.Exp(SpecialFunctions.GammaLn(r + x) - SpecialFunctions.GammaLn(r) - SpecialFunctions.GammaLn(x + 1.0) + (r * Math.Log(p)) + (x * Math.Log(1.0 - p))), d.Probability(x)); @@ -218,8 +243,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Number of trials. /// Probability of success. /// Input X value. - [Test, Combinatorial] - public void ValidateProbabilityLn([Values(0.0, 0.1, 1.0)] double r, [Values(0.0, 0.3, 1.0)] double p, [Values(0, 1, 2, 3, 5)] int x) + [TestCase(0.0, 0.0, 0)] + [TestCase(0.1, 0.3, 1)] + [TestCase(1.0, 1.0, 2)] + [TestCase(1.0, 1.0, 3)] + [TestCase(1.0, 1.0, 5)] + public void ValidateProbabilityLn(double r, double p, int x) { var d = new NegativeBinomial(r, p); Assert.AreEqual(SpecialFunctions.GammaLn(r + x) - SpecialFunctions.GammaLn(r) - SpecialFunctions.GammaLn(x + 1.0) + (r * Math.Log(p)) + (x * Math.Log(1.0 - p)), d.ProbabilityLn(x)); @@ -231,8 +260,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Number of trials. /// Probability of success. /// Input X value. - [Test, Combinatorial] - public void ValidateCumulativeDistribution([Values(0.0, 0.1, 1.0)] double r, [Values(0.0, 0.3, 1.0)] double p, [Values(0, 1, 2, 3, 5)] int x) + [TestCase(0.0, 0.0, 0)] + [TestCase(0.1, 0.3, 1)] + [TestCase(1.0, 1.0, 2)] + [TestCase(1.0, 1.0, 3)] + [TestCase(1.0, 1.0, 5)] + public void ValidateCumulativeDistribution(double r, double p, int x) { var d = new NegativeBinomial(r, p); Assert.AreEqual(SpecialFunctions.BetaRegularized(r, x + 1.0, p), d.CumulativeDistribution(x), 1e-12); diff --git a/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs b/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs index 9b60e273..862c5b51 100644 --- a/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can create Poisson. /// /// Lambda value. - [Test] - public void CanCreatePoisson([Values(1.5, 5.4, 10.8)] double lambda) + [TestCase(1.5)] + [TestCase(5.4)] + [TestCase(10.8)] + public void CanCreatePoisson(double lambda) { var d = new Poisson(lambda); Assert.AreEqual(lambda, d.Lambda); @@ -61,8 +63,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Poisson create fails with bad parameters. /// /// Lambda value. - [Test] - public void PoissonCreateFailsWithBadParameters([Values(Double.NaN, -1.5, 0.0)] double lambda) + [TestCase(Double.NaN)] + [TestCase(-1.5)] + [TestCase(0.0)] + public void PoissonCreateFailsWithBadParameters(double lambda) { Assert.Throws(() => new Poisson(lambda)); } @@ -81,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set probability of one. /// /// Lambda value. - [Test] - public void CanSetProbabilityOfOne([Values(1.5, 5.4, 10.8)] double lambda) + [TestCase(1.5)] + [TestCase(5.4)] + [TestCase(10.8)] + public void CanSetProbabilityOfOne(double lambda) { new Poisson(0.3) { @@ -94,8 +100,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set probability of one fails with bad value. /// /// Lambda value. - [Test] - public void SetProbabilityOfOneFails([Values(Double.NaN, -1.5, 0.0)] double lambda) + [TestCase(Double.NaN)] + [TestCase(-1.5)] + [TestCase(0.0)] + public void SetProbabilityOfOneFails(double lambda) { var d = new Poisson(0.3); Assert.Throws(() => d.Lambda = lambda); @@ -105,8 +113,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate entropy. /// /// Lambda value. - [Test] - public void ValidateEntropy([Values(1.5, 5.4, 10.8)] double lambda) + [TestCase(1.5)] + [TestCase(5.4)] + [TestCase(10.8)] + public void ValidateEntropy(double lambda) { var d = new Poisson(lambda); Assert.AreEqual((0.5 * Math.Log(2 * Math.PI * Math.E * lambda)) - (1.0 / (12.0 * lambda)) - (1.0 / (24.0 * lambda * lambda)) - (19.0 / (360.0 * lambda * lambda * lambda)), d.Entropy); @@ -116,8 +126,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate skewness. /// /// Lambda value. - [Test] - public void ValidateSkewness([Values(1.5, 5.4, 10.8)] double lambda) + [TestCase(1.5)] + [TestCase(5.4)] + [TestCase(10.8)] + public void ValidateSkewness(double lambda) { var d = new Poisson(lambda); Assert.AreEqual(1.0 / Math.Sqrt(lambda), d.Skewness); @@ -127,8 +139,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate mode. /// /// Lambda value. - [Test] - public void ValidateMode([Values(1.5, 5.4, 10.8)] double lambda) + [TestCase(1.5)] + [TestCase(5.4)] + [TestCase(10.8)] + public void ValidateMode(double lambda) { var d = new Poisson(lambda); Assert.AreEqual((int)Math.Floor(lambda), d.Mode); @@ -138,8 +152,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Validate median. /// /// Lambda value. - [Test] - public void ValidateMedian([Values(1.5, 5.4, 10.8)] double lambda) + [TestCase(1.5)] + [TestCase(5.4)] + [TestCase(10.8)] + public void ValidateMedian(double lambda) { var d = new Poisson(lambda); Assert.AreEqual((int)Math.Floor(lambda + (1.0 / 3.0) - (0.02 / lambda)), d.Median); @@ -171,11 +187,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lambda value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbability( - [Values(1.5, 1.5, 1.5, 5.4, 5.4, 5.4, 10.8, 10.8, 10.8)] double lambda, - [Values(1, 10, 20, 1, 10, 20, 1, 10, 20)] int x, - [Values(0.334695240222645000000000000000, 0.000003545747740570180000000000, 0.000000000000000304971208961018, 0.024389537090108400000000000000, 0.026241240591792300000000000000, 0.000000825202200316548000000000, 0.000220314636840657000000000000, 0.121365183659420000000000000000, 0.003908139778574110000000000000)] double result) + [TestCase(1.5, 1, 0.334695240222645000000000000000)] + [TestCase(1.5, 10, 0.000003545747740570180000000000)] + [TestCase(1.5, 20, 0.000000000000000304971208961018)] + [TestCase(5.4, 1, 0.024389537090108400000000000000)] + [TestCase(5.4, 10, 0.026241240591792300000000000000)] + [TestCase(5.4, 20, 0.000000825202200316548000000000)] + [TestCase(10.8, 1, 0.000220314636840657000000000000)] + [TestCase(10.8, 10, 0.121365183659420000000000000000)] + [TestCase(10.8, 20, 0.003908139778574110000000000000)] + public void ValidateProbability(double lambda, int x, double result) { var d = new Poisson(lambda); Assert.AreEqual(d.Probability(x), result, 1e-12); @@ -187,11 +208,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lambda value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbabilityLn( - [Values(1.5, 1.5, 1.5, 5.4, 5.4, 5.4, 10.8, 10.8, 10.8)] double lambda, - [Values(1, 10, 20, 1, 10, 20, 1, 10, 20)] int x, - [Values(0.334695240222645000000000000000, 0.000003545747740570180000000000, 0.000000000000000304971208961018, 0.024389537090108400000000000000, 0.026241240591792300000000000000, 0.000000825202200316548000000000, 0.000220314636840657000000000000, 0.121365183659420000000000000000, 0.003908139778574110000000000000)] double result) + [TestCase(1.5, 1, 0.334695240222645000000000000000)] + [TestCase(1.5, 10, 0.000003545747740570180000000000)] + [TestCase(1.5, 20, 0.000000000000000304971208961018)] + [TestCase(5.4, 1, 0.024389537090108400000000000000)] + [TestCase(5.4, 10, 0.026241240591792300000000000000)] + [TestCase(5.4, 20, 0.000000825202200316548000000000)] + [TestCase(10.8, 1, 0.000220314636840657000000000000)] + [TestCase(10.8, 10, 0.121365183659420000000000000000)] + [TestCase(10.8, 20, 0.003908139778574110000000000000)] + public void ValidateProbabilityLn(double lambda, int x, double result) { var d = new Poisson(lambda); Assert.AreEqual(d.ProbabilityLn(x), Math.Log(result), 1e-12); @@ -224,11 +250,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Lambda value. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateCumulativeDistribution( - [Values(1.5, 1.5, 1.5, 5.4, 5.4, 5.4, 10.8, 10.8, 10.8)] double lambda, - [Values(1, 10, 20, 1, 10, 20, 1, 10, 20)] int x, - [Values(0.5578254003710750000000, 0.9999994482467640000000, 1.0000000000000000000000, 0.0289061180327211000000, 0.9774863006897650000000, 0.9999997199928290000000, 0.0002407141402518290000, 0.4839692359955690000000, 0.9961800769608090000000)] double result) + [TestCase(1.5, 1, 0.5578254003710750000000)] + [TestCase(1.5, 10, 0.9999994482467640000000)] + [TestCase(1.5, 20, 1.0000000000000000000000)] + [TestCase(5.4, 1, 0.0289061180327211000000)] + [TestCase(5.4, 10, 0.9774863006897650000000)] + [TestCase(5.4, 20, 0.9999997199928290000000)] + [TestCase(10.8, 1, 0.0002407141402518290000)] + [TestCase(10.8, 10, 0.4839692359955690000000)] + [TestCase(10.8, 20, 0.9961800769608090000000)] + public void ValidateCumulativeDistribution(double lambda, int x, double result) { var d = new Poisson(lambda); Assert.AreEqual(d.CumulativeDistribution(x), result, 1e-12); diff --git a/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs b/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs index 29246c3b..de92ba6a 100644 --- a/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs +++ b/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// S parameter. /// N parameter. - [Test, Combinatorial] - public void CanCreateZipf([Values(0.1, 1)] double s, [Values(1, 20, 50)] int n) + [TestCase(0.1, 1)] + [TestCase(1, 20)] + [TestCase(1, 50)] + public void CanCreateZipf(double s, int n) { var d = new Zipf(s, n); Assert.AreEqual(s, d.S); @@ -64,8 +66,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// S parameter. /// N parameter. - [Test, Combinatorial] - public void ZipfCreateFailsWithBadParameters([Values(0.0)] double s, [Values(-10, 0)] int n) + [TestCase(0.0, -10)] + [TestCase(0.0, 0)] + public void ZipfCreateFailsWithBadParameters(double s, int n) { Assert.Throws(() => new Zipf(s, n)); } @@ -84,8 +87,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set S. /// /// S parameter. - [Test] - public void CanSetS([Values(0.1, 1.0, 5.0)] double s) + [TestCase(0.1)] + [TestCase(1.0)] + [TestCase(5.0)] + public void CanSetS(double s) { new Zipf(1.0, 5) { @@ -97,8 +102,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set S fails with bad values. /// /// S parameter. - [Test] - public void SetSFails([Values(Double.NaN, -1.0, Double.NegativeInfinity)] double s) + [TestCase(Double.NaN)] + [TestCase(-1.0)] + [TestCase(Double.NegativeInfinity)] + public void SetSFails(double s) { var d = new Zipf(1.0, 5); Assert.Throws(() => d.S = s); @@ -108,8 +115,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Can set N. /// /// N parameter. - [Test] - public void CanSetN([Values(1, 20, 50)] int n) + [TestCase(1)] + [TestCase(20)] + [TestCase(50)] + public void CanSetN(int n) { new Zipf(1.0, 5) { @@ -121,8 +130,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Set N fails with bad values. /// /// N parameter. - [Test] - public void SetNFails([Values(-1, 0)] int n) + [TestCase(-1)] + [TestCase(0)] + public void SetNFails(int n) { var d = new Zipf(1.0, 5); Assert.Throws(() => d.N = n); @@ -134,11 +144,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// S parameter. /// N parameter. /// Expected value. - [Test, Sequential] - public void ValidateEntropy( - [Values(0.1, 0.1, 0.1, 1.0, 1.0, 1.0)] double s, - [Values(1, 20, 50, 1, 20, 50)] int n, - [Values(0.0, 2.9924075515295949, 3.9078245132371388, 0.0, 2.5279968533953743, 3.1971263138845916)] double e) + [TestCase(0.1, 1, 0.0)] + [TestCase(0.1, 20, 2.9924075515295949)] + [TestCase(0.1, 50, 3.9078245132371388)] + [TestCase(1.0, 1, 0.0)] + [TestCase(1.0, 20, 2.5279968533953743)] + [TestCase(1.0, 50, 3.1971263138845916)] + public void ValidateEntropy(double s, int n, double e) { var d = new Zipf(s, n); AssertHelpers.AlmostEqual(e, d.Entropy, 15); @@ -149,10 +161,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// S parameter. /// N parameter. - [Test, Combinatorial] - public void ValidateSkewness( - [Values(5.0, 10.0)] double s, - [Values(1, 20, 50)] int n) + [TestCase(5.0, 1)] + [TestCase(10.0, 20)] + [TestCase(10.0, 50)] + public void ValidateSkewness(double s, int n) { var d = new Zipf(s, n); if (s > 4) @@ -166,8 +178,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// S parameter. /// N parameter. - [Test, Combinatorial] - public void ValidateMode([Values(0.1, 1)] double s, [Values(1, 20, 50)] int n) + [TestCase(0.1, 1)] + [TestCase(1, 20)] + [TestCase(1, 50)] + public void ValidateMode(double s, int n) { var d = new Zipf(s, n); Assert.AreEqual(1, d.Mode); @@ -198,8 +212,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// /// S parameter. /// N parameter. - [Test, Combinatorial] - public void ValidateMaximum([Values(0.1, 1)] double s, [Values(1, 20, 50)] int n) + [TestCase(0.1, 1)] + [TestCase(1, 20)] + [TestCase(1, 50)] + public void ValidateMaximum(double s, int n) { var d = new Zipf(s, n); Assert.AreEqual(n, d.Maximum); @@ -211,8 +227,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// S parameter. /// N parameter. /// Input X value. - [Test, Combinatorial] - public void ValidateProbability([Values(0.1, 1)] double s, [Values(1, 20, 50)] int n, [Values(1, 15)] int x) + [TestCase(0.1, 1, 1)] + [TestCase(1, 20, 15)] + [TestCase(1, 50, 20)] + public void ValidateProbability(double s, int n, int x) { var d = new Zipf(s, n); Assert.AreEqual((1.0 / Math.Pow(x, s)) / SpecialFunctions.GeneralHarmonic(n, s), d.Probability(x)); @@ -224,8 +242,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// S parameter. /// N parameter. /// Input X value. - [Test, Combinatorial] - public void ValidateProbabilityLn([Values(0.1, 1)] double s, [Values(1, 20, 50)] int n, [Values(1, 15)] int x) + [TestCase(0.1, 1, 1)] + [TestCase(1, 20, 15)] + [TestCase(1, 50, 20)] + public void ValidateProbabilityLn(double s, int n, int x) { var d = new Zipf(s, n); Assert.AreEqual(Math.Log(d.Probability(x)), d.ProbabilityLn(x)); @@ -265,8 +285,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// S parameter. /// N parameter. /// Input X value. - [Test, Combinatorial] - public void ValidateCumulativeDistribution([Values(0.1, 1)] double s, [Values(1, 20, 50)] int n, [Values(2, 15)] int x) + [TestCase(0.1, 1, 2)] + [TestCase(1, 20, 15)] + [TestCase(1, 50, 20)] + public void ValidateCumulativeDistribution(double s, int n, int x) { var d = new Zipf(s, n); var cdf = SpecialFunctions.GeneralHarmonic(x, s) / SpecialFunctions.GeneralHarmonic(n, s); diff --git a/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs b/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs index 0aaea97a..2662c1a1 100644 --- a/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs @@ -202,8 +202,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Alphas array. /// Expected value. - [Test, Sequential] - public void ValidateDensity([Values(new[] { 0.01, 0.03, 0.5 }, new[] { 0.1, 0.2, 0.3, 0.4 })] double[] x, [Values(1335.32600710379, 59.1446044600076)] double res) + [TestCase(new[] { 0.01, 0.03, 0.5 }, 1335.32600710379)] + [TestCase(new[] { 0.1, 0.2, 0.3, 0.4 }, 59.1446044600076)] + public void ValidateDensity(double[] x, double res) { var d = new Dirichlet(new[] { 0.1, 0.3, 0.5, 0.8 }); AssertHelpers.AlmostEqual(res, d.Density(x), 12); @@ -213,8 +214,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Validate density log. /// /// Alpha array. - [Test] - public void ValidateDensityLn([Values(new[] { 0.01, 0.03, 0.5 }, new[] { 0.1, 0.2, 0.3, 0.4 })] double[] x) + [TestCase(new[] { 0.01, 0.03, 0.5, 0.5 })] + [TestCase(new[] { 0.1, 0.2, 0.3, 0.4 })] + public void ValidateDensityLn(double[] x) { var d = new Dirichlet(new[] { 0.1, 0.3, 0.5, 0.8 }); AssertHelpers.AlmostEqual(d.DensityLn(x), Math.Log(d.Density(x)), 12); @@ -224,8 +226,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Validate entropy. /// /// Alpha array. - [Test] - public void ValidateEntropy([Values(new[] { 0.1, 0.3, 0.5, 0.8 }, new[] { 0.1, 0.2, 0.3, 0.4 })] double[] x) + [TestCase(new[] { 0.1, 0.3, 0.5, 0.8 })] + [TestCase(new[] { 0.1, 0.2, 0.3, 0.4 })] + public void ValidateEntropy(double[] x) { var d = new Dirichlet(x); diff --git a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs index 7a5c98f0..5725ee11 100644 --- a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -52,8 +52,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void CanCreateInverseWishart([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void CanCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var d = new InverseWishart(nu, matrix); @@ -73,8 +75,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void FailSCreateInverseWishart([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void FailSCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); matrix[0, 0] = 0.0; @@ -87,8 +91,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void FailNuCreateInverseWishart([Values(-1.0, Double.NaN)] double nu, [Values(2, 5)] int order) + [TestCase(-1.0, 2)] + [TestCase(Double.NaN, 5)] + public void FailNuCreateInverseWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); Assert.Throws(() => new InverseWishart(nu, matrix)); @@ -140,8 +145,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Can get Nu. /// /// Nu parameter. - [Test] - public void CanGetNu([Values(1.0, 2.0, 5.0)] double nu) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(5.0)] + public void CanGetNu(double nu) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.AreEqual(nu, d.Nu); @@ -151,8 +158,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Can set Nu. /// /// Nu parameter. - [Test] - public void CanSetNu([Values(1.0, 2.0, 5.0)] double nu) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(5.0)] + public void CanSetNu(double nu) { new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)) { @@ -196,8 +205,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void ValidateMean([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void ValidateMean(double nu, int order) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); @@ -216,8 +227,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void ValidateMode([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void ValidateMode(double nu, int order) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); @@ -236,8 +249,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void ValidateVariance([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void ValidateVariance(double nu, int order) { var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); @@ -258,8 +273,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Expected value. - [Test, Sequential] - public void ValidateDensity([Values(1.0, 2.0, 5.0)] double nu, [Values(0.03228684517430723, 0.018096748360719193, 0.00043049126899076171)] double density) + [TestCase(1.0, 0.03228684517430723)] + [TestCase(2.0, 0.018096748360719193)] + [TestCase(5.0, 0.00043049126899076171)] + public void ValidateDensity(double nu, double density) { const int Order = 1; var matrix = new DenseMatrix(Order); diff --git a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs index 060b4c26..f8145ebe 100644 --- a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -43,8 +43,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanCreateMatrixNormal([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanCreateMatrixNormal(int n, int p) { var matrixM = MatrixLoader.GenerateRandomDenseMatrix(n, p); var matrixV = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n); @@ -85,14 +87,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Covariance matrix columns. /// Covariance matrix rows (for columns) /// Covariance matrix columns (for columns) - [Test, Sequential] - public void FailCreateMatrixNormal( - [Values(2, 2, 2, 2, 5, 5, 5, 5)] int rowsOfM, - [Values(2, 2, 2, 2, 2, 2, 2, 2)] int columnsOfM, - [Values(3, 2, 2, 2, 6, 5, 5, 5)] int rowsOfV, - [Values(2, 3, 2, 2, 5, 6, 5, 5)] int columnsOfV, - [Values(2, 2, 3, 2, 2, 2, 3, 2)] int rowsOfK, - [Values(2, 2, 2, 3, 2, 2, 2, 3)] int columnsOfK) + [TestCase(2, 2, 3, 2, 2, 2)] + [TestCase(2, 2, 2, 3, 2, 2)] + [TestCase(2, 2, 2, 2, 3, 2)] + [TestCase(2, 2, 2, 2, 2, 3)] + [TestCase(5, 2, 6, 5, 2, 2)] + [TestCase(5, 2, 5, 6, 2, 2)] + [TestCase(5, 2, 5, 5, 3, 2)] + [TestCase(5, 2, 5, 5, 2, 3)] + public void FailCreateMatrixNormal(int rowsOfM, int columnsOfM, int rowsOfV, int columnsOfV, int rowsOfK, int columnsOfK) { var matrixM = MatrixLoader.GenerateRandomDenseMatrix(rowsOfM, columnsOfM); var matrixV = MatrixLoader.GenerateRandomDenseMatrix(rowsOfV, columnsOfV); @@ -156,8 +159,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanGetM([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanGetM(int n, int p) { var matrixM = MatrixLoader.GenerateRandomDenseMatrix(n, p); var d = new MatrixNormal(matrixM, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)); @@ -175,8 +180,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanSetM([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanSetM(int n, int p) { new MatrixNormal(MatrixLoader.GenerateRandomDenseMatrix(n, p), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)) { @@ -189,8 +196,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanGetV([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanGetV(int n, int p) { var matrixV = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n); var d = new MatrixNormal(MatrixLoader.GenerateRandomDenseMatrix(n, p), matrixV, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)); @@ -208,8 +217,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanSetV([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanSetV(int n, int p) { new MatrixNormal(MatrixLoader.GenerateRandomDenseMatrix(n, p), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)) { @@ -222,8 +233,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanGetK([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanGetK(int n, int p) { var matrixK = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p); var d = new MatrixNormal(MatrixLoader.GenerateRandomDenseMatrix(n, p), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), matrixK); @@ -241,8 +254,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Combinatorial] - public void CanSetK([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanSetK(int n, int p) { new MatrixNormal(MatrixLoader.GenerateRandomDenseMatrix(n, p), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)) { @@ -289,8 +304,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Sequential] - public void CanSample([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanSample(int n, int p) { var d = new MatrixNormal(MatrixLoader.GenerateRandomDenseMatrix(n, p), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)); d.Sample(); @@ -301,8 +318,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Matrix rows count. /// Matrix columns count. - [Test, Sequential] - public void CanSampleStatic([Values(1, 3, 10)] int n, [Values(1, 3, 10)] int p) + [TestCase(1, 1)] + [TestCase(3, 3)] + [TestCase(10, 10)] + public void CanSampleStatic(int n, int p) { MatrixNormal.Sample(new Random(), MatrixLoader.GenerateRandomDenseMatrix(n, p), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(n), MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(p)); } @@ -316,14 +335,15 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Covariance matrix columns. /// Covariance matrix rows (for columns) /// Covariance matrix columns (for columns) - [Test, Sequential] - public void FailSampleStatic( - [Values(2, 2, 2, 2, 5, 5, 5, 5)] int rowsOfM, - [Values(2, 2, 2, 2, 2, 2, 2, 2)] int columnsOfM, - [Values(3, 2, 2, 2, 6, 5, 5, 5)] int rowsOfV, - [Values(2, 3, 2, 2, 5, 6, 5, 5)] int columnsOfV, - [Values(2, 2, 3, 2, 2, 2, 3, 2)] int rowsOfK, - [Values(2, 2, 2, 3, 2, 2, 2, 3)] int columnsOfK) + [TestCase(2, 2, 3, 2, 2, 2)] + [TestCase(2, 2, 2, 3, 2, 2)] + [TestCase(2, 2, 2, 2, 3, 2)] + [TestCase(2, 2, 2, 2, 2, 3)] + [TestCase(5, 2, 6, 5, 2, 2)] + [TestCase(5, 2, 5, 6, 2, 2)] + [TestCase(5, 2, 5, 5, 3, 2)] + [TestCase(5, 2, 5, 5, 2, 3)] + public void FailSampleStatic(int rowsOfM, int columnsOfM, int rowsOfV, int columnsOfV, int rowsOfK, int columnsOfK) { Assert.Throws(() => MatrixNormal.Sample(new Random(), MatrixLoader.GenerateRandomDenseMatrix(rowsOfM, columnsOfM), MatrixLoader.GenerateRandomDenseMatrix(rowsOfV, columnsOfV), MatrixLoader.GenerateRandomDenseMatrix(rowsOfK, columnsOfK))); } diff --git a/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs b/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs index a0a9177a..8c3b27a1 100644 --- a/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs @@ -141,11 +141,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Proportion of ratios. /// Number of trials. /// Expected value. - [Test, Sequential] - public void ValidateSkewness( - [Values(new[] { 0.3, 0.7 }, new[] { 0.1, 0.3, 0.6 }, new[] { 0.15, 0.35, 0.3, 0.2 })] double[] p, - [Values(5, 10, 20)] int n, - [Values(new[] { 0.390360029179413, -0.390360029179413 }, new[] { 0.843274042711568, 0.276026223736942, -0.129099444873581 }, new[] { 0.438357003759605, 0.140642169281549, 0.195180014589707, 0.335410196624968 })] double[] res) + [TestCase(new[] { 0.3, 0.7 }, 5, new[] { 0.390360029179413, -0.390360029179413 })] + [TestCase(new[] { 0.1, 0.3, 0.6 }, 10, new[] { 0.843274042711568, 0.276026223736942, -0.129099444873581 })] + [TestCase(new[] { 0.15, 0.35, 0.3, 0.2 }, 20, new[] { 0.438357003759605, 0.140642169281549, 0.195180014589707, 0.335410196624968 })] + public void ValidateSkewness(double[] p, int n, double[] res) { var b = new Multinomial(p, n); for (var i = 0; i < b.P.Length; i++) @@ -160,11 +159,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Proportion of ratios. /// Number of trials. /// Expected value. - [Test, Sequential] - public void ValidateVariance( - [Values(new[] { 0.3, 0.7 }, new[] { 0.1, 0.3, 0.6 }, new[] { 0.15, 0.35, 0.3, 0.2 })] double[] p, - [Values(5, 10, 20)] int n, - [Values(new[] { 1.05, 1.05 }, new[] { 0.9, 2.1, 2.4 }, new[] { 2.55, 4.55, 4.2, 3.2 })] double[] res) + [TestCase(new[] { 0.3, 0.7 }, 5, new[] { 1.05, 1.05 })] + [TestCase(new[] { 0.1, 0.3, 0.6 }, 10, new[] { 0.9, 2.1, 2.4 })] + [TestCase(new[] { 0.15, 0.35, 0.3, 0.2 }, 20, new[] { 2.55, 4.55, 4.2, 3.2 })] + public void ValidateVariance(double[] p, int n, double[] res) { var b = new Multinomial(p, n); for (var i = 0; i < b.P.Length; i++) @@ -179,11 +177,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Proportion of ratios. /// Number of trials. /// Expected value. - [Test, Sequential] - public void ValidateMean( - [Values(new[] { 0.3, 0.7 }, new[] { 0.1, 0.3, 0.6 }, new[] { 0.15, 0.35, 0.3, 0.2 })] double[] p, - [Values(5, 10, 20)] int n, - [Values(new[] { 1.5, 3.5 }, new[] { 1.0, 3.0, 6.0 }, new[] { 3.0, 7.0, 6.0, 4.0 })] double[] res) + [TestCase(new[] { 0.3, 0.7 }, 5, new[] { 1.5, 3.5 })] + [TestCase(new[] { 0.1, 0.3, 0.6 }, 10, new[] { 1.0, 3.0, 6.0 })] + [TestCase(new[] { 0.15, 0.35, 0.3, 0.2 }, 20, new[] { 3.0, 7.0, 6.0, 4.0 })] + public void ValidateMean(double[] p, int n, double[] res) { var b = new Multinomial(p, n); for (var i = 0; i < b.P.Length; i++) @@ -198,11 +195,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Proportion of ratios. /// Input X value. /// Expected value. - [Test, Sequential] - public void ValidateProbability( - [Values(new[] { 0.3, 0.7 }, new[] { 0.1, 0.3, 0.6 }, new[] { 0.15, 0.35, 0.3, 0.2 })] double[] p, - [Values(new[] { 1, 9 }, new[] { 1, 3, 6 }, new[] { 1, 1, 1, 7 })] int[] x, - [Values(0.121060821, 0.105815808, 0.000145152)] double res) + [TestCase(new[] { 0.3, 0.7 }, new[] { 1, 9 }, 0.121060821)] + [TestCase(new[] { 0.1, 0.3, 0.6 }, new[] { 1, 3, 6 }, 0.105815808)] + [TestCase(new[] { 0.15, 0.35, 0.3, 0.2 }, new[] { 1, 1, 1, 7 }, 0.000145152)] + public void ValidateProbability(double[] p, int[] x, double res) { var b = new Multinomial(p, x.Sum()); AssertHelpers.AlmostEqual(b.Probability(x), res, 12); @@ -212,8 +208,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Validate probability log. /// /// Input X value. - [Test, Sequential] - public void ValidateProbabilityLn([Values(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, new[] { 1, 1, 1, 2, 2, 2, 3, 3, 3 }, new[] { 5, 6, 7, 8, 7, 6, 5, 4, 3 })] int[] x) + [TestCase(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 })] + [TestCase(new[] { 1, 1, 1, 2, 2, 2, 3, 3, 3 })] + [TestCase(new[] { 5, 6, 7, 8, 7, 6, 5, 4, 3 })] + public void ValidateProbabilityLn(int[] x) { var b = new Multinomial(_largeP, x.Sum()); AssertHelpers.AlmostEqual(b.ProbabilityLn(x), Math.Log(b.Probability(x)), 12); diff --git a/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs b/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs index e7c06e59..1275c68e 100644 --- a/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs @@ -44,8 +44,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanCreateNormalGamma([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanCreateNormalGamma(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); @@ -62,8 +63,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Sequential] - public void CanGetDensityAndDensityLn([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 1.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 1.0, 2.0, 2.0)] + public void CanGetDensityAndDensityLn(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); Assert.AreEqual(ng.DensityLn(meanLocation, precShape), Math.Log(ng.Density(meanLocation, precShape)), 1e-14); @@ -87,8 +89,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanGetMeanLocation([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanGetMeanLocation(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); Assert.AreEqual(meanLocation, ng.MeanLocation); @@ -101,8 +104,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanSetMeanLocation([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanSetMeanLocation(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale) { @@ -122,8 +126,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanGetMeanScale([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanGetMeanScale(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); Assert.AreEqual(meanScale, ng.MeanScale); @@ -136,8 +141,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanSetMeanScale([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanSetMeanScale(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale) { @@ -156,8 +162,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanGetPrecisionShape([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanGetPrecisionShape(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); Assert.AreEqual(precShape, ng.PrecisionShape); @@ -170,8 +177,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanSetPrecisionShape([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanSetPrecisionShape(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale) { @@ -190,8 +198,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanGetPrecisionInverseScale([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanGetPrecisionInverseScale(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); Assert.AreEqual(precInvScale, ng.PrecisionInverseScale); @@ -204,8 +213,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanSetPrecisionPrecisionInverseScale([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + public void CanSetPrecisionPrecisionInverseScale(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale) { @@ -227,8 +237,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean marginal mean. /// Mean marginal scale. /// Mean marginal degrees of freedom. - [Test, Sequential] - public void CanGetMeanMarginal([Values(0.0, 10.0, 10.0)] double meanLocation, [Values(1.0, 1.0, 1.0)] double meanScale, [Values(1.0, 2.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale, [Values(0.0, 10.0, 10.0)] double meanMarginalMean, [Values(1.0, 1.0, 0.5)] double meanMarginalScale, [Values(2.0, 4.0, Double.PositiveInfinity)] double meanMarginalDoF) + [TestCase(0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 2.0)] + [TestCase(10.0, 1.0, 2.0, 2.0, 10.0, 1.0, 4.0)] + [TestCase(10.0, 1.0, 2.0, Double.PositiveInfinity, 10.0, 0.5, Double.PositiveInfinity)] + public void CanGetMeanMarginal(double meanLocation, double meanScale, double precShape, double precInvScale, double meanMarginalMean, double meanMarginalScale, double meanMarginalDoF) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); var mm = ng.MeanMarginal(); @@ -244,8 +256,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void CanGetPrecisionMarginal([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + [TestCase(10.0, 2.0, 2.0, Double.PositiveInfinity)] + public void CanGetPrecisionMarginal(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); var pm = ng.PrecisionMarginal(); @@ -262,8 +276,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Precision inverse scale. /// Mean value. /// Mean precision. - [Test, Sequential] - public void CanGetMean([Values(0.0, 10.0, 10.0)] double meanLocation, [Values(1.0, 1.0, 1.0)] double meanScale, [Values(1.0, 2.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale, [Values(0.0, 10.0, 10.0)] double meanMean, [Values(1.0, 1.0, 2.0)] double meanPrecision) + [TestCase(0.0, 1.0, 1.0, 1.0, 0.0, 1.0)] + [TestCase(10.0, 1.0, 2.0, 2.0, 10.0, 1.0)] + [TestCase(10.0, 1.0, 2.0, Double.PositiveInfinity, 10.0, 2.0)] + public void CanGetMean(double meanLocation, double meanScale, double precShape, double precInvScale, double meanMean, double meanPrecision) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); Assert.AreEqual(meanMean, ng.Mean.Mean); @@ -299,8 +315,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Mean scale. /// Precision shape. /// Precision inverse scale. - [Test, Combinatorial] - public void ValidateVariance([Values(0.0, 10.0)] double meanLocation, [Values(1.0, 2.0)] double meanScale, [Values(1.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale) + [TestCase(0.0, 1.0, 1.0, 1.0)] + [TestCase(10.0, 2.0, 2.0, 2.0)] + [TestCase(10.9, 2.0, 2.0, Double.PositiveInfinity)] + public void ValidateVariance(double meanLocation, double meanScale, double precShape, double precInvScale) { var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale); var x = precInvScale / (meanScale * (precShape - 1)); @@ -332,16 +350,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate // Check the precision distribution. CommonDistributionTests.VapnikChervonenkisTest( - CommonDistributionTests.Error, - CommonDistributionTests.ErrorProbability, - precs, + CommonDistributionTests.Error, + CommonDistributionTests.ErrorProbability, + precs, precMarginal); // Check the mean distribution. CommonDistributionTests.VapnikChervonenkisTest( - CommonDistributionTests.Error, - CommonDistributionTests.ErrorProbability, - means, + CommonDistributionTests.Error, + CommonDistributionTests.ErrorProbability, + means, meanMarginal); } @@ -364,16 +382,16 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate // Check the precision distribution. CommonDistributionTests.VapnikChervonenkisTest( - CommonDistributionTests.Error, - CommonDistributionTests.ErrorProbability, - precs, + CommonDistributionTests.Error, + CommonDistributionTests.ErrorProbability, + precs, precMarginal); - + // Check the mean distribution. CommonDistributionTests.VapnikChervonenkisTest( - CommonDistributionTests.Error, - CommonDistributionTests.ErrorProbability, - means, + CommonDistributionTests.Error, + CommonDistributionTests.ErrorProbability, + means, meanMarginal); } } diff --git a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs index d8213c87..5b12c4c7 100644 --- a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs +++ b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -52,8 +52,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void CanCreateWishart([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void CanCreateWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); @@ -74,8 +76,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void FailSCreateWishart([Values(0.0, 0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.0, 2)] + [TestCase(0.1, 5)] + [TestCase(1.0, 2)] + [TestCase(5.0, 5)] + public void FailSCreateWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); matrix[0, 0] = 0.0; @@ -88,8 +93,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void FailNuCreateWishart([Values(-1.0, Double.NaN)] double nu, [Values(2, 5)] int order) + [TestCase(-1.0, 2)] + [TestCase(Double.NaN, 5)] + public void FailNuCreateWishart(double nu, int order) { var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); Assert.Throws(() => new InverseWishart(nu, matrix)); @@ -141,8 +147,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Can get Nu. /// /// Nu parameter. - [Test] - public void CanGetNu([Values(1.0, 2.0, 5.0)] double nu) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(5.0)] + public void CanGetNu(double nu) { var d = new Wishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)); Assert.AreEqual(nu, d.Nu); @@ -152,8 +160,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// Can set Nu. /// /// Nu parameter. - [Test] - public void CanSetNu([Values(1.0, 2.0, 5.0)] double nu) + [TestCase(1.0)] + [TestCase(2.0)] + [TestCase(5.0)] + public void CanSetNu(double nu) { new Wishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2)) { @@ -197,8 +207,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void ValidateMean([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void ValidateMean(double nu, int order) { var d = new Wishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); @@ -217,8 +229,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void ValidateMode([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void ValidateMode(double nu, int order) { var d = new Wishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); @@ -237,8 +251,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Scale matrix order. - [Test, Combinatorial] - public void ValidateVariance([Values(0.1, 1.0, 5.0)] double nu, [Values(2, 5)] int order) + [TestCase(0.1, 2)] + [TestCase(1.0, 5)] + [TestCase(5.0, 5)] + public void ValidateVariance(double nu, int order) { var d = new Wishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order)); @@ -257,8 +273,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate /// /// Nu parameter. /// Expected value. - [Test, Sequential] - public void ValidateDensity([Values(1.0, 2.0, 5.0)] double nu, [Values(0.014644982561926487, 0.041042499311949421, 0.12204152134938706)] double density) + [TestCase(1.0, 0.014644982561926487)] + [TestCase(2.0, 0.041042499311949421)] + [TestCase(5.0, 0.12204152134938706)] + public void ValidateDensity(double nu, double density) { const int Order = 1; var matrix = new DenseMatrix(Order); diff --git a/src/UnitTests/IntegralTransformsTests/FourierTest.cs b/src/UnitTests/IntegralTransformsTests/FourierTest.cs index 416bd6fc..e628f971 100644 --- a/src/UnitTests/IntegralTransformsTests/FourierTest.cs +++ b/src/UnitTests/IntegralTransformsTests/FourierTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -92,18 +92,18 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests var dft = new DiscreteFourierTransform(); Assert.Throws( - typeof(ArgumentException), + typeof(ArgumentException), () => dft.Radix2Forward(samples, FourierOptions.Default)); Assert.Throws( - typeof(ArgumentException), + typeof(ArgumentException), () => dft.Radix2Inverse(samples, FourierOptions.Default)); Assert.Throws( - typeof(ArgumentException), + typeof(ArgumentException), () => DiscreteFourierTransform.Radix2(samples, -1)); Assert.Throws( - typeof(ArgumentException), + typeof(ArgumentException), () => DiscreteFourierTransform.Radix2Parallel(samples, -1)); } } diff --git a/src/UnitTests/IntegralTransformsTests/HartleyTest.cs b/src/UnitTests/IntegralTransformsTests/HartleyTest.cs index ce336ede..7a1b571f 100644 --- a/src/UnitTests/IntegralTransformsTests/HartleyTest.cs +++ b/src/UnitTests/IntegralTransformsTests/HartleyTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -54,17 +54,17 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// DFT function delegate. /// Hartley transform delegate. private static void VerifyMatchesDft( - double[] samples, - double maximumError, - bool inverse, - Action dft, + double[] samples, + double maximumError, + bool inverse, + Action dft, Func hartley) { var hartleyReal = hartley(samples); - var fourierComplex = Array.ConvertAll(samples, s => new Complex(s, inverse ? -s : s)); + var fourierComplex = ArrayHelpers.ConvertAll(samples, s => new Complex(s, inverse ? -s : s)); dft(fourierComplex); - var fourierReal = Array.ConvertAll(fourierComplex, s => s.Real); + var fourierReal = ArrayHelpers.ConvertAll(fourierComplex, s => s.Real); AssertHelpers.AlmostEqualList(fourierReal, hartleyReal, maximumError); } @@ -74,23 +74,25 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// /// Hartley transformation options. /// Fourier transformation options. - [Test, Sequential] - public void NaiveMatchesDft([Values(HartleyOptions.Default, HartleyOptions.AsymmetricScaling, HartleyOptions.NoScaling)] HartleyOptions hartleyOptions, [Values(FourierOptions.Default, FourierOptions.AsymmetricScaling, FourierOptions.NoScaling)] FourierOptions fourierOptions) + [TestCase(HartleyOptions.Default, FourierOptions.Default)] + [TestCase(HartleyOptions.AsymmetricScaling, FourierOptions.AsymmetricScaling)] + [TestCase(HartleyOptions.NoScaling, FourierOptions.NoScaling)] + public void NaiveMatchesDft(HartleyOptions hartleyOptions, FourierOptions fourierOptions) { var dht = new DiscreteHartleyTransform(); var samples = SignalGenerator.Random(x => x, _uniform, 0x80); VerifyMatchesDft( - samples, - 1e-5, - false, - s => Transform.FourierForward(s, fourierOptions), + samples, + 1e-5, + false, + s => Transform.FourierForward(s, fourierOptions), s => dht.NaiveForward(s, hartleyOptions)); VerifyMatchesDft( - samples, - 1e-5, - true, - s => Transform.FourierInverse(s, fourierOptions), + samples, + 1e-5, + true, + s => Transform.FourierInverse(s, fourierOptions), s => dht.NaiveInverse(s, hartleyOptions)); } } diff --git a/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs b/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs index dfda2531..54970389 100644 --- a/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs +++ b/src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -53,9 +53,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Forward delegate. /// Inverse delegate. private void VerifyIsReversibleComplex( - int count, - double maximumError, - Func forward, + int count, + double maximumError, + Func forward, Func inverse) { var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, count); @@ -79,9 +79,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Forward delegate. /// Inverse delegate. private void VerifyIsReversibleReal( - int count, - double maximumError, - Func forward, + int count, + double maximumError, + Func forward, Func inverse) { var samples = SignalGenerator.Random(x => x, _uniform, count); @@ -101,15 +101,16 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier naive is reversible. /// /// Fourier options. - [Test] - public void FourierNaiveIsReversible([Values(FourierOptions.Default, FourierOptions.Matlab)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + public void FourierNaiveIsReversible(FourierOptions options) { var dft = new DiscreteFourierTransform(); VerifyIsReversibleComplex( - 0x80, - 1e-12, - s => dft.NaiveForward(s, options), + 0x80, + 1e-12, + s => dft.NaiveForward(s, options), s => dft.NaiveInverse(s, options)); } @@ -117,19 +118,20 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier radix2xx is reversible. /// /// Fourier options. - [Test] - public void FourierRadix2IsReversible([Values(FourierOptions.Default, FourierOptions.Matlab)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + public void FourierRadix2IsReversible(FourierOptions options) { var dft = new DiscreteFourierTransform(); VerifyIsReversibleComplex( - 0x8000, - 1e-12, + 0x8000, + 1e-12, s => { dft.Radix2Forward(s, options); return s; - }, + }, s => { dft.Radix2Inverse(s, options); @@ -141,19 +143,20 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier bluestein is reversible. /// /// Fourier options. - [Test] - public void FourierBluesteinIsReversible([Values(FourierOptions.Default, FourierOptions.Matlab)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + public void FourierBluesteinIsReversible(FourierOptions options) { var dft = new DiscreteFourierTransform(); VerifyIsReversibleComplex( - 0x7FFF, - 1e-12, + 0x7FFF, + 1e-12, s => { dft.BluesteinForward(s, options); return s; - }, + }, s => { dft.BluesteinInverse(s, options); @@ -165,15 +168,16 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Hartley naive is reversible. /// /// Hartley options. - [Test] - public void HartleyNaiveIsReversible([Values(HartleyOptions.Default, HartleyOptions.AsymmetricScaling)] HartleyOptions options) + [TestCase(HartleyOptions.Default)] + [TestCase(HartleyOptions.AsymmetricScaling)] + public void HartleyNaiveIsReversible(HartleyOptions options) { var dht = new DiscreteHartleyTransform(); VerifyIsReversibleReal( - 0x80, - 1e-9, - s => dht.NaiveForward(s, options), + 0x80, + 1e-9, + s => dht.NaiveForward(s, options), s => dht.NaiveInverse(s, options)); } diff --git a/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs b/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs index 4f475bc9..bb943024 100644 --- a/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs +++ b/src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -53,9 +53,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Naive transform. /// Fast delegate. private static void VerifyMatchesNaiveComplex( - Complex[] samples, - double maximumError, - Func naive, + Complex[] samples, + double maximumError, + Func naive, Action fast) { var spectrumNaive = naive(samples); @@ -71,22 +71,24 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier Radix2XX matches naive on real sine. /// /// Fourier options. - [Test] - public void FourierRadix2MatchesNaiveOnRealSine([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + [TestCase(FourierOptions.NumericalRecipes)] + public void FourierRadix2MatchesNaiveOnRealSine(FourierOptions options) { var dft = new DiscreteFourierTransform(); var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 16); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveForward(s, options), + samples, + 1e-12, + s => dft.NaiveForward(s, options), s => dft.Radix2Forward(s, options)); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveInverse(s, options), + samples, + 1e-12, + s => dft.NaiveInverse(s, options), s => dft.Radix2Inverse(s, options)); } @@ -94,22 +96,24 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier Radix2XX matches naive on random. /// /// Fourier options. - [Test] - public void FourierRadix2MatchesNaiveOnRandom([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + [TestCase(FourierOptions.NumericalRecipes)] + public void FourierRadix2MatchesNaiveOnRandom(FourierOptions options) { var dft = new DiscreteFourierTransform(); var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x80); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveForward(s, options), + samples, + 1e-12, + s => dft.NaiveForward(s, options), s => dft.Radix2Forward(s, options)); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveInverse(s, options), + samples, + 1e-12, + s => dft.NaiveInverse(s, options), s => dft.Radix2Inverse(s, options)); } @@ -117,22 +121,24 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier bluestein matches naive on real sine non-power of two. /// /// Fourier options. - [Test] - public void FourierBluesteinMatchesNaiveOnRealSineNonPowerOfTwo([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + [TestCase(FourierOptions.NumericalRecipes)] + public void FourierBluesteinMatchesNaiveOnRealSineNonPowerOfTwo(FourierOptions options) { var dft = new DiscreteFourierTransform(); var samples = SignalGenerator.EquidistantPeriodic(w => new Complex(Math.Sin(w), 0), Constants.Pi2, 0, 14); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveForward(s, options), + samples, + 1e-12, + s => dft.NaiveForward(s, options), s => dft.BluesteinForward(s, options)); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveInverse(s, options), + samples, + 1e-12, + s => dft.NaiveInverse(s, options), s => dft.BluesteinInverse(s, options)); } @@ -140,22 +146,24 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier bluestein matches naive on random power of two. /// /// Fourier options. - [Test] - public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + [TestCase(FourierOptions.NumericalRecipes)] + public void FourierBluesteinMatchesNaiveOnRandomPowerOfTwo(FourierOptions options) { var dft = new DiscreteFourierTransform(); var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x80); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveForward(s, options), + samples, + 1e-12, + s => dft.NaiveForward(s, options), s => dft.BluesteinForward(s, options)); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveInverse(s, options), + samples, + 1e-12, + s => dft.NaiveInverse(s, options), s => dft.BluesteinInverse(s, options)); } @@ -163,21 +171,23 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier bluestein matches naive on random non-power of two. /// /// Fourier options. - [Test] - public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo([Values(FourierOptions.Default, FourierOptions.Matlab, FourierOptions.NumericalRecipes)] FourierOptions options) + [TestCase(FourierOptions.Default)] + [TestCase(FourierOptions.Matlab)] + [TestCase(FourierOptions.NumericalRecipes)] + public void FourierBluesteinMatchesNaiveOnRandomNonPowerOfTwo(FourierOptions options) { var dft = new DiscreteFourierTransform(); var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, 0x7F); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveForward(s, options), + samples, + 1e-12, + s => dft.NaiveForward(s, options), s => dft.BluesteinForward(s, options)); VerifyMatchesNaiveComplex( - samples, - 1e-12, - s => dft.NaiveInverse(s, options), + samples, + 1e-12, + s => dft.NaiveInverse(s, options), s => dft.BluesteinInverse(s, options)); } } diff --git a/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs b/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs index 94a249c3..6f6ca0ac 100644 --- a/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs +++ b/src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Fourier default transform satisfies parsevals theorem. /// /// Samples count. - [Test] - public void FourierDefaultTransformSatisfiesParsevalsTheorem([Values(0x1000, 0x7FF)] int count) + [TestCase(0x1000)] + [TestCase(0x7FF)] + public void FourierDefaultTransformSatisfiesParsevalsTheorem(int count) { var samples = SignalGenerator.Random((u, v) => new Complex(u, v), _uniform, count); @@ -72,8 +73,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests /// Hartley default naive satisfies parsevals theorem. /// /// Samples count. - [Test] - public void HartleyDefaultNaiveSatisfiesParsevalsTheorem([Values(0x40, 0x1F)] int count) + [TestCase(0x40)] + [TestCase(0x1F)] + public void HartleyDefaultNaiveSatisfiesParsevalsTheorem(int count) { var samples = SignalGenerator.Random(x => x, _uniform, count); diff --git a/src/UnitTests/IntegrationTests/IntegrationTest.cs b/src/UnitTests/IntegrationTests/IntegrationTest.cs index 09531b89..e006c095 100644 --- a/src/UnitTests/IntegrationTests/IntegrationTest.cs +++ b/src/UnitTests/IntegrationTests/IntegrationTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -69,15 +69,15 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests public void TestIntegratePortal() { Assert.AreEqual( - TargetAreaA, - Integrate.OnClosedInterval(TargetFunctionA, StartA, StopA), - 1e-5, + TargetAreaA, + Integrate.OnClosedInterval(TargetFunctionA, StartA, StopA), + 1e-5, "Basic"); Assert.AreEqual( - TargetAreaA, - Integrate.OnClosedInterval(TargetFunctionA, StartA, StopA, 1e-10), - 1e-10, + TargetAreaA, + Integrate.OnClosedInterval(TargetFunctionA, StartA, StopA, 1e-10), + 1e-10, "Basic Target 1e-10"); } @@ -85,16 +85,17 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests /// Test double exponential transformation algorithm. /// /// Relative error. - [Test] - public void TestDoubleExponentialTransformationAlgorithm([Values(1e-5, 1e-13)] double targetRelativeError) + [TestCase(1e-5)] + [TestCase(1e-13)] + public void TestDoubleExponentialTransformationAlgorithm(double targetRelativeError) { var algorithm = new DoubleExponentialTransformation(); Assert.AreEqual( - TargetAreaA, - algorithm.Integrate(TargetFunctionA, StartA, StopA, targetRelativeError), - targetRelativeError * TargetAreaA, - "DET Adaptive {0}", + TargetAreaA, + algorithm.Integrate(TargetFunctionA, StartA, StopA, targetRelativeError), + targetRelativeError * TargetAreaA, + "DET Adaptive {0}", targetRelativeError); } @@ -105,9 +106,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests public void TrapeziumRuleSupportsTwoPointIntegration() { Assert.AreEqual( - TargetAreaA, - NewtonCotesTrapeziumRule.IntegrateTwoPoint(TargetFunctionA, StartA, StopA), - 0.4 * TargetAreaA, + TargetAreaA, + NewtonCotesTrapeziumRule.IntegrateTwoPoint(TargetFunctionA, StartA, StopA), + 0.4 * TargetAreaA, "Direct (1 Partition)"); } @@ -116,14 +117,18 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests /// /// Partitions count. /// Maximum relative error. - [Test, Sequential] - public void TrapeziumRuleSupportsCompositeIntegration([Values(1, 5, 10, 50, 1000)] int partitions, [Values(3.5e-1, 1e-1, 2e-2, 6e-4, 1.5e-6)] double maxRelativeError) + [TestCase(1, 3.5e-1)] + [TestCase(5, 1e-1)] + [TestCase(10, 2e-2)] + [TestCase(50, 6e-4)] + [TestCase(1000, 1.5e-6)] + public void TrapeziumRuleSupportsCompositeIntegration(int partitions, double maxRelativeError) { Assert.AreEqual( - TargetAreaA, - NewtonCotesTrapeziumRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions), - maxRelativeError * TargetAreaA, - "Composite {0} Partitions", + TargetAreaA, + NewtonCotesTrapeziumRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions), + maxRelativeError * TargetAreaA, + "Composite {0} Partitions", partitions); } @@ -131,14 +136,16 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests /// Trapezium rule supports adaptive integration. /// /// Relative error - [Test] - public void TrapeziumRuleSupportsAdaptiveIntegration([Values(1e-1, 1e-5, 1e-10)] double targetRelativeError) + [TestCase(1e-1)] + [TestCase(1e-5)] + [TestCase(1e-10)] + public void TrapeziumRuleSupportsAdaptiveIntegration(double targetRelativeError) { Assert.AreEqual( - TargetAreaA, - NewtonCotesTrapeziumRule.IntegrateAdaptive(TargetFunctionA, StartA, StopA, targetRelativeError), - targetRelativeError * TargetAreaA, - "Adaptive {0}", + TargetAreaA, + NewtonCotesTrapeziumRule.IntegrateAdaptive(TargetFunctionA, StartA, StopA, targetRelativeError), + targetRelativeError * TargetAreaA, + "Adaptive {0}", targetRelativeError); } @@ -149,9 +156,9 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests public void SimpsonRuleSupportsThreePointIntegration() { Assert.AreEqual( - TargetAreaA, - SimpsonRule.IntegrateThreePoint(TargetFunctionA, StartA, StopA), - 0.2 * TargetAreaA, + TargetAreaA, + SimpsonRule.IntegrateThreePoint(TargetFunctionA, StartA, StopA), + 0.2 * TargetAreaA, "Direct (2 Partitions)"); } @@ -160,14 +167,18 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests /// /// Partitions count. /// Maximum relative error. - [Test, Sequential] - public void SimpsonRuleSupportsCompositeIntegration([Values(2, 6, 10, 50, 1000)] int partitions, [Values(1.7e-1, 1.2e-1, 8e-3, 8e-6, 5e-11)] double maxRelativeError) + [TestCase(2, 1.7e-1)] + [TestCase(6, 1.2e-1)] + [TestCase(10, 8e-3)] + [TestCase(50, 8e-6)] + [TestCase(1000, 5e-11)] + public void SimpsonRuleSupportsCompositeIntegration(int partitions, double maxRelativeError) { Assert.AreEqual( - TargetAreaA, - SimpsonRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions), - maxRelativeError * TargetAreaA, - "Composite {0} Partitions", + TargetAreaA, + SimpsonRule.IntegrateComposite(TargetFunctionA, StartA, StopA, partitions), + maxRelativeError * TargetAreaA, + "Composite {0} Partitions", partitions); } } diff --git a/src/UnitTests/InterpolationTests/AkimaSplineTest.cs b/src/UnitTests/InterpolationTests/AkimaSplineTest.cs index 0d820b52..127dc2c5 100644 --- a/src/UnitTests/InterpolationTests/AkimaSplineTest.cs +++ b/src/UnitTests/InterpolationTests/AkimaSplineTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,21 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// AkimaSpline test case. + /// [TestFixture] public class AkimaSplineTest { - readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; - readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; + /// + /// Sample points. + /// + private readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; /// /// Verifies that the interpolation matches the given value at all the provided sample points. @@ -62,11 +72,19 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// - [Test, Sequential] - public void FitsAtArbitraryPointsWithMaple( - [Values(-2.4, -0.9, -0.5, -0.1, 0.1, 0.4, 1.2, 10.0, -10.0)] double t, - [Values(-0.52, 1.826, 0.25, -1.006, -0.9, -0.6, 0.2, 9, -151)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15)] double maxAbsoluteError) + /// Sample point. + /// Sample value. + /// Maximum absolute error. + [TestCase(-2.4, -0.52, 1e-15)] + [TestCase(-0.9, 1.826, 1e-15)] + [TestCase(-0.5, 0.25, 1e-15)] + [TestCase(-0.1, -1.006, 1e-15)] + [TestCase(0.1, -0.9, 1e-15)] + [TestCase(0.4, -0.6, 1e-15)] + [TestCase(1.2, 0.2, 1e-15)] + [TestCase(10.0, 9, 1e-15)] + [TestCase(-10.0, -151, 1e-15)] + public void FitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new AkimaSplineInterpolation(_t, _x); @@ -82,8 +100,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that the interpolation supports the linear case appropriately /// - [Test] - public void SupportsLinearCase([Values(5, 7, 15)] int samples) + /// Samples array. + [TestCase(5)] + [TestCase(7)] + [TestCase(15)] + public void SupportsLinearCase(int samples) { double[] x, y, xtest, ytest; LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples); diff --git a/src/UnitTests/InterpolationTests/BulirschStoerRationalTest.cs b/src/UnitTests/InterpolationTests/BulirschStoerRationalTest.cs index 9a0a7e04..1d8c0a6d 100644 --- a/src/UnitTests/InterpolationTests/BulirschStoerRationalTest.cs +++ b/src/UnitTests/InterpolationTests/BulirschStoerRationalTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,21 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// BulirschStoerRational test case. + /// [TestFixture] public class BulirschStoerRationalTest { - readonly double[] _t = new[] { 0d, 1, 3, 4, 5 }; - readonly double[] _x = new[] { 0d, 3, 1000, -1000, 3 }; + /// + /// Sample points. + /// + private readonly double[] _t = new[] { 0d, 1, 3, 4, 5 }; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 0d, 3, 1000, -1000, 3 }; /// /// Verifies that the interpolation matches the given value at all the provided sample points. @@ -57,16 +67,26 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// evalf(subs({x=0.1},RationalInterpolation([[0,0],[1,3],[3,1000],[4,-1000], [5,3]], x)),20); /// - [Test, Sequential] - public void FitsAtArbitraryPointsWithMaple( - [Values(0.1, 0.4, 1.1, 3.01, 3.02, 3.03, 3.1, 3.2, 4.5, 10.0, -10.0)] double t, - [Values(.19389203383553566255, .88132900698869875369, 3.5057665681580626913, 1548.7666642693586902, 3362.2564334253633516, -22332.603641443806014, -440.30323769822443789, -202.42421196280566349, 21.208249625210155439, -4.8936986959784751517, -3.6017584308603731307)] double x, - [Values(1e-14, 1e-14, 1e-15, 1e-10, 1e-10, 1e-8, 1e-11, 1e-12, 1e-12, 1e-13, 1e-13)] double maxAbsoluteError) + [TestCase(0.1, .19389203383553566255, 1e-14)] + [TestCase(0.4, .88132900698869875369, 1e-14)] + [TestCase(1.1, 3.5057665681580626913, 1e-15)] + [TestCase(3.01, 1548.7666642693586902, 1e-10)] + [TestCase(3.02, 3362.2564334253633516, 1e-10)] + [TestCase(3.03, -22332.603641443806014, 1e-8)] + [TestCase(3.1, -440.30323769822443789, 1e-11)] + [TestCase(3.2, -202.42421196280566349, 1e-12)] + [TestCase(4.5, 21.208249625210155439, 1e-12)] + [TestCase(10.0, -4.8936986959784751517, 1e-13)] + [TestCase(-10.0, -3.6017584308603731307, 1e-13)] + public void FitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new BulirschStoerRationalInterpolation(_t, _x); diff --git a/src/UnitTests/InterpolationTests/CubicSplineTest.cs b/src/UnitTests/InterpolationTests/CubicSplineTest.cs index d10412ff..4b249274 100644 --- a/src/UnitTests/InterpolationTests/CubicSplineTest.cs +++ b/src/UnitTests/InterpolationTests/CubicSplineTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,21 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// CubicSpline Test case. + /// [TestFixture] public class CubicSplineTest { - readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; - readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; + /// + /// Sample points. + /// + private readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; /// /// Verifies that the interpolation matches the given value at all the provided sample points. @@ -62,16 +72,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// evalf(subs({x=-2.4},Spline([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x, degree=3, endpoints='natural')),20); /// - [Test, Sequential] - public void NaturalFitsAtArbitraryPointsWithMaple( - [Values(-2.4, -0.9, -0.5, -0.1, 0.1, 0.4, 1.2, 10.0, -10.0)] double t, - [Values(.144, 1.7906428571428571429, .47321428571428571431, -.80992857142857142857, -1.1089285714285714286, -1.0285714285714285714, .30285714285714285716, 189, 677)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-12)] double maxAbsoluteError) + [TestCase(-2.4, .144, 1e-15)] + [TestCase(-0.9, 1.7906428571428571429, 1e-15)] + [TestCase(-0.5, .47321428571428571431, 1e-15)] + [TestCase(-0.1, -.80992857142857142857, 1e-15)] + [TestCase(0.1, -1.1089285714285714286, 1e-15)] + [TestCase(0.4, -1.0285714285714285714, 1e-15)] + [TestCase(1.2, .30285714285714285716, 1e-15)] + [TestCase(10.0, 189, 1e-15)] + [TestCase(-10.0, 677, 1e-12)] + public void NaturalFitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new CubicSplineInterpolation(_t, _x); @@ -105,16 +123,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// evalf(subs({x=-2.4},Spline([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x, degree=3, endpoints=[1,-1])),20); /// - [Test, Sequential] - public void FixedFirstDerivativeFitsAtArbitraryPointsWithMaple( - [Values(-2.4, -0.9, -0.5, -0.1, 0.1, 0.4, 1.2, 10.0, -10.0)] double t, - [Values(1.12, 1.8243928571428571428, .54910714285714285715, -.78903571428571428572, -1.1304642857142857143, -1.1040000000000000000, .4148571428571428571, -608.14285714285714286, 1330.1428571428571429)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-12, 1e-12)] double maxAbsoluteError) + [TestCase(-2.4, 1.12, 1e-15)] + [TestCase(-0.9, 1.8243928571428571428, 1e-15)] + [TestCase(-0.5, .54910714285714285715, 1e-15)] + [TestCase(-0.1, -.78903571428571428572, 1e-15)] + [TestCase(0.1, -1.1304642857142857143, 1e-15)] + [TestCase(0.4, -1.1040000000000000000, 1e-15)] + [TestCase(1.2, .4148571428571428571, 1e-15)] + [TestCase(10.0, -608.14285714285714286, 1e-12)] + [TestCase(-10.0, 1330.1428571428571429, 1e-12)] + public void FixedFirstDerivativeFitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new CubicSplineInterpolation(_t, _x, SplineBoundaryCondition.FirstDerivative, 1.0, SplineBoundaryCondition.FirstDerivative, -1.0); @@ -148,16 +174,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// evalf(subs({x=-2.4},Spline([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x, degree=3, endpoints=Matrix(2,13,{(1,3)=1,(1,13)=-5,(2,10)=1,(2,13)=-1}))),20); /// - [Test, Sequential] - public void FixedSecondDerivativeFitsAtArbitraryPointsWithMaple( - [Values(-2.4, -0.9, -0.5, -0.1, 0.1, 0.4, 1.2, 10.0, -10.0)] double t, - [Values(-.8999999999999999993, 1.7590357142857142857, .41517857142857142854, -.82010714285714285714, -1.1026071428571428572, -1.0211428571428571429, .31771428571428571421, 39, -37)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-13, 1e-12)] double maxAbsoluteError) + [TestCase(-2.4, -.8999999999999999993, 1e-15)] + [TestCase(-0.9, 1.7590357142857142857, 1e-15)] + [TestCase(-0.5, .41517857142857142854, 1e-15)] + [TestCase(-0.1, -.82010714285714285714, 1e-15)] + [TestCase(0.1, -1.1026071428571428572, 1e-15)] + [TestCase(0.4, -1.0211428571428571429, 1e-15)] + [TestCase(1.2, .31771428571428571421, 1e-15)] + [TestCase(10.0, 39, 1e-13)] + [TestCase(-10.0, -37, 1e-12)] + public void FixedSecondDerivativeFitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new CubicSplineInterpolation(_t, _x, SplineBoundaryCondition.SecondDerivative, -5.0, SplineBoundaryCondition.SecondDerivative, -1.0); @@ -172,8 +206,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that the interpolation supports the linear case appropriately /// - [Test] - public void NaturalSupportsLinearCase([Values(2, 4, 12)] int samples) + /// Samples array. + [TestCase(2)] + [TestCase(4)] + [TestCase(12)] + public void NaturalSupportsLinearCase(int samples) { double[] x, y, xtest, ytest; LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples); diff --git a/src/UnitTests/InterpolationTests/EquidistantPolynomialTest.cs b/src/UnitTests/InterpolationTests/EquidistantPolynomialTest.cs index 226c1874..d4ff51ea 100644 --- a/src/UnitTests/InterpolationTests/EquidistantPolynomialTest.cs +++ b/src/UnitTests/InterpolationTests/EquidistantPolynomialTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,26 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// EquidistantPolynomial Test case. + /// [TestFixture] public class EquidistantPolynomialTest { - const double _tmin = 0.0, _tmax = 4.0; - readonly double[] _x = new[] { 0.0, 3.0, 2.5, 1.0, 3.0 }; + /// + /// Left bound; + /// + private const double Tmin = 0.0; + + /// + /// Right bound. + /// + private const double Tmax = 4.0; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 0.0, 3.0, 2.5, 1.0, 3.0 }; /// /// Verifies that the interpolation matches the given value at all the provided sample points. @@ -46,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests [Test] public void FitsAtSamplePoints() { - IInterpolation interpolation = new EquidistantPolynomialInterpolation(_tmin, _tmax, _x); + IInterpolation interpolation = new EquidistantPolynomialInterpolation(Tmin, Tmax, _x); for (int i = 0; i < _x.Length; i++) { @@ -57,18 +72,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// evalf(subs({x=0.1},PolynomialInterpolation([[0,0],[1,3],[2,2.5],[3,1],[4,3]], x)),20); /// - [Test, Sequential] - public void FitsAtArbitraryPointsWithMaple( - [Values(0.1, 0.4, 1.1, 3.2, 4.5, 10.0, -10.0)] double t, - [Values(.487425, 1.6968, 3.081925, .9408, 7.265625, 592.5, 657.5)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-14, 1e-10, 1e-9)] double maxAbsoluteError) + [TestCase(0.1, .487425, 1e-15)] + [TestCase(0.4, 1.6968, 1e-15)] + [TestCase(1.1, 3.081925, 1e-15)] + [TestCase(3.2, .9408, 1e-15)] + [TestCase(4.5, 7.265625, 1e-14)] + [TestCase(10.0, 592.5, 1e-10)] + [TestCase(-10.0, 657.5, 1e-9)] + public void FitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { - IInterpolation interpolation = new EquidistantPolynomialInterpolation(_tmin, _tmax, _x); + IInterpolation interpolation = new EquidistantPolynomialInterpolation(Tmin, Tmax, _x); Assert.AreEqual(x, interpolation.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t); } @@ -76,8 +97,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that the interpolation supports the linear case appropriately /// - [Test] - public void SupportsLinearCase([Values(2, 4, 12)] int samples) + /// Samples array. + [TestCase(2)] + [TestCase(4)] + [TestCase(12)] + public void SupportsLinearCase(int samples) { double[] x, y, xtest, ytest; LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples); diff --git a/src/UnitTests/InterpolationTests/FloaterHormannRationalTest.cs b/src/UnitTests/InterpolationTests/FloaterHormannRationalTest.cs index 9bb785b4..7681e926 100644 --- a/src/UnitTests/InterpolationTests/FloaterHormannRationalTest.cs +++ b/src/UnitTests/InterpolationTests/FloaterHormannRationalTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,21 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// FloaterHormannRational test case. + /// [TestFixture] public class FloaterHormannRationalTest { - readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; - readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; + /// + /// Sample points. + /// + private readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; /// /// Verifies that the interpolation matches the given value at all the provided polynomial sample points. @@ -57,16 +67,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided polynomial sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// PolynomialInterpolation([[-2,1],[-1,2],[0,-1],[1,0],[2,1]], x); /// - [Test, Sequential] - public void PolynomialFitsAtArbitraryPointsWithMaple( - [Values(-2.4, -0.9, -0.5, -0.1, 0.1, 0.4, 1.2, 10.0, -10.0)] double t, - [Values(-4.5968, 1.65395, 0.21875, -0.84205, -1.10805, -1.1248, 0.5392, -4431.0, -5071.0)] double x, - [Values(1e-14, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-9, 1e-9)] double maxAbsoluteError) + [TestCase(-2.4, -4.5968, 1e-14)] + [TestCase(-0.9, 1.65395, 1e-15)] + [TestCase(-0.5, 0.21875, 1e-15)] + [TestCase(-0.1, -0.84205, 1e-15)] + [TestCase(0.1, -1.10805, 1e-15)] + [TestCase(0.4, -1.1248, 1e-15)] + [TestCase(1.2, 0.5392, 1e-15)] + [TestCase(10.0, -4431.0, 1e-9)] + [TestCase(-10.0, -5071.0, 1e-9)] + public void PolynomialFitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new EquidistantPolynomialInterpolation(_t, _x); @@ -82,10 +100,10 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests var t = new double[40]; var x = new double[40]; - const double step = 10.0 / 39.0; + const double Step = 10.0 / 39.0; for (int i = 0; i < t.Length; i++) { - double tt = -5 + (i * step); + double tt = -5 + (i * Step); t[i] = tt; x[i] = 1.0 / (1.0 + (tt * tt)); } @@ -101,8 +119,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that the interpolation supports the linear case appropriately /// - [Test] - public void SupportsLinearCase([Values(2, 4, 12)] int samples) + /// Samples array. + [TestCase(2)] + [TestCase(4)] + [TestCase(12)] + public void SupportsLinearCase(int samples) { double[] x, y, xtest, ytest; LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples); diff --git a/src/UnitTests/InterpolationTests/LinearInterpolationCase.cs b/src/UnitTests/InterpolationTests/LinearInterpolationCase.cs index 37bbcda2..568be8b1 100644 --- a/src/UnitTests/InterpolationTests/LinearInterpolationCase.cs +++ b/src/UnitTests/InterpolationTests/LinearInterpolationCase.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -33,15 +33,29 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Distributions; using Numerics.Random; + /// + /// LinearInterpolation test case. + /// internal static class LinearInterpolationCase { + /// + /// Build linear samples. + /// + /// X sample values. + /// Y samples values. + /// X test values. + /// Y test values. + /// Sample values. + /// Sample offset. + /// Slope number. + /// Intercept criteria. public static void Build(out double[] x, out double[] y, out double[] xtest, out double[] ytest, int samples = 3, double sampleOffset = -0.5, double slope = 2.0, double intercept = -1.0) { // Fixed-seed "random" distribution to ensure we always test with the same data var uniform = new ContinuousUniform - { - RandomSource = new MersenneTwister(42) - }; + { + RandomSource = new MersenneTwister(42) + }; // build linear samples x = new double[samples]; @@ -49,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests for (int i = 0; i < x.Length; i++) { x[i] = i + sampleOffset; - y[i] = x[i] * slope + intercept; + y[i] = (x[i] * slope) + intercept; } // build linear test vectors randomly between the sample points @@ -60,14 +74,14 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests // y = const xtest[0] = sampleOffset - uniform.Sample(); xtest[1] = sampleOffset + uniform.Sample(); - ytest[0] = ytest[1] = sampleOffset * slope + intercept; + ytest[0] = ytest[1] = (sampleOffset * slope) + intercept; } else { for (int i = 0; i < xtest.Length; i++) { xtest[i] = (i - 1) + sampleOffset + uniform.Sample(); - ytest[i] = xtest[i] * slope + intercept; + ytest[i] = (xtest[i] * slope) + intercept; } } } diff --git a/src/UnitTests/InterpolationTests/LinearSplineTest.cs b/src/UnitTests/InterpolationTests/LinearSplineTest.cs index 239ffe4f..5fee9710 100644 --- a/src/UnitTests/InterpolationTests/LinearSplineTest.cs +++ b/src/UnitTests/InterpolationTests/LinearSplineTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,21 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// LinearSpline test case + /// [TestFixture] public class LinearSplineTest { - readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; - readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; + /// + /// Sample points. + /// + private readonly double[] _t = new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 1.0, 2.0, -1.0, 0.0, 1.0 }; /// /// Verifies that the interpolation matches the given value at all the provided sample points. @@ -62,16 +72,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// f := x -> piecewise(x<-1,3+x,x<0,-1-3*x,x<1,-1+x,-1+x); /// f(x) /// - [Test, Sequential] - public void FitsAtArbitraryPointsWithMaple( - [Values(-2.4, -0.9, -0.5, -0.1, 0.1, 0.4, 1.2, 10.0, -10.0)] double t, - [Values(.6, 1.7, .5, -.7, -.9, -.6, .2, 9.0, -7.0)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15)] double maxAbsoluteError) + [TestCase(-2.4, .6, 1e-15)] + [TestCase(-0.9, 1.7, 1e-15)] + [TestCase(-0.5, .5, 1e-15)] + [TestCase(-0.1, -.7, 1e-15)] + [TestCase(0.1, -.9, 1e-15)] + [TestCase(0.4, -.6, 1e-15)] + [TestCase(1.2, .2, 1e-15)] + [TestCase(10.0, 9.0, 1e-15)] + [TestCase(-10.0, -7.0, 1e-15)] + public void FitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { IInterpolation interpolation = new LinearSplineInterpolation(_t, _x); @@ -86,8 +104,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that the interpolation supports the linear case appropriately /// - [Test] - public void SupportsLinearCase([Values(2, 4, 12)] int samples) + /// Samples array. + [TestCase(2)] + [TestCase(4)] + [TestCase(12)] + public void SupportsLinearCase(int samples) { double[] x, y, xtest, ytest; LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples); diff --git a/src/UnitTests/InterpolationTests/NevillePolynomialTest.cs b/src/UnitTests/InterpolationTests/NevillePolynomialTest.cs index 1fa95190..1c5abfcb 100644 --- a/src/UnitTests/InterpolationTests/NevillePolynomialTest.cs +++ b/src/UnitTests/InterpolationTests/NevillePolynomialTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,11 +34,21 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests using Interpolation.Algorithms; using NUnit.Framework; + /// + /// NevillePolynomial test case. + /// [TestFixture] public class NevillePolynomialTest { - readonly double[] _t = new[] { 0.0, 1.0, 3.0, 4.0 }; - readonly double[] _x = new[] { 0.0, 3.0, 1.0, 3.0 }; + /// + /// Sample points. + /// + private readonly double[] _t = new[] { 0.0, 1.0, 3.0, 4.0 }; + + /// + /// Sample values. + /// + private readonly double[] _x = new[] { 0.0, 3.0, 1.0, 3.0 }; /// /// Verifies that the interpolation matches the given value at all the provided sample points. @@ -62,18 +72,24 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that at points other than the provided sample points, the interpolation matches the one computed by Maple as a reference. /// + /// Sample point. + /// Sample value. + /// Maximum absolute error. /// /// Maple: /// with(CurveFitting); /// evalf(subs({x=0.1},PolynomialInterpolation([[0,0],[1,3],[3,1],[4,3]], x)),20); /// - [Test, Sequential] - public void FitsAtArbitraryPointsWithMaple( - [Values(0.1, 0.4, 1.1, 3.2, 4.5, 10.0, -10.0)] double t, - [Values(.57225, 1.884, 3.0314166666666666667, 1.034666666666666667, 6.28125, 277.5, -1010.8333333333333333)] double x, - [Values(1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-15, 1e-12)] double maxAbsoluteError) + [TestCase(0.1, .57225, 1e-15)] + [TestCase(0.4, 1.884, 1e-15)] + [TestCase(1.1, 3.0314166666666666667, 1e-15)] + [TestCase(3.2, 1.034666666666666667, 1e-15)] + [TestCase(4.5, 6.28125, 1e-15)] + [TestCase(10.0, 277.5, 1e-15)] + [TestCase(-10.0, -1010.8333333333333333, 1e-12)] + public void FitsAtArbitraryPointsWithMaple(double t, double x, double maxAbsoluteError) { - IInterpolation interpolation = new NevillePolynomialInterpolation(_t, _x); + IInterpolation interpolation = new NevillePolynomialInterpolation(_t, _x); Assert.AreEqual(x, interpolation.Interpolate(t), maxAbsoluteError, "Interpolation at {0}", t); @@ -86,8 +102,11 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests /// /// Verifies that the interpolation supports the linear case appropriately /// - [Test] - public void SupportsLinearCase([Values(2, 4, 12)] int samples) + /// Samples array. + [TestCase(2)] + [TestCase(4)] + [TestCase(12)] + public void SupportsLinearCase(int samples) { double[] x, y, xtest, ytest; LinearInterpolationCase.Build(out x, out y, out xtest, out ytest, samples); diff --git a/src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs b/src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs index 1f933ddf..a1f5b6b9 100644 --- a/src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs +++ b/src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -29,7 +29,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex using System; using System.Collections.Generic; using System.Numerics; - using Algorithms.LinearAlgebra; using LinearAlgebra.Complex; using LinearAlgebra.Generic; @@ -57,11 +56,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex /// private readonly IDictionary _matrices = new Dictionary { - { "Singular3x3", new DenseMatrix(new[,] { { new Complex(1.0, 0), 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } }) }, - { "Square3x3", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } }) }, - { "Square4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } }) }, - { "Singular4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } }) }, - { "Tall3x2", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, + { "Singular3x3", new DenseMatrix(new[,] { { new Complex(1.0, 0), 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } }) }, + { "Square3x3", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } }) }, + { "Square4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } }) }, + { "Singular4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } }) }, + { "Tall3x2", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, { "Wide2x3", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) } }; @@ -181,7 +180,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex Assert.AreEqual(_x[i] / _y[i], result[i]); } } - + /// /// Can compute L1 norm. /// @@ -414,16 +413,16 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex var matrix = _matrices["Square3x3"]; var a = new Complex[matrix.RowCount * matrix.RowCount]; Array.Copy(matrix.Data, a, a.Length); - + Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount); AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 14); - AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14); + AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14); AssertHelpers.AlmostEqual(a[2], 0.454545454545454, 14); AssertHelpers.AlmostEqual(a[3], -0.340909090909090, 14); AssertHelpers.AlmostEqual(a[4], -2.045454545454543, 14); AssertHelpers.AlmostEqual(a[5], 1.477272727272726, 14); - AssertHelpers.AlmostEqual(a[6], -0.113636363636364, 14); + AssertHelpers.AlmostEqual(a[6], -0.113636363636364, 14); AssertHelpers.AlmostEqual(a[7], 0.227272727272727, 14); AssertHelpers.AlmostEqual(a[8], -0.113636363636364, 14); } @@ -647,7 +646,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex { for (var col = 0; col < matrix.ColumnCount; col++) { - AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 14); + AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 14); } } } @@ -830,7 +829,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex var b = new[] { new Complex(1.0, 0), 2.0, 3.0, 4.0, 5.0, 6.0 }; var x = new Complex[matrix.ColumnCount * 2]; Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x); - + NotModified(3, 2, a, matrix); var mb = new DenseMatrix(matrix.RowCount, 2, b); diff --git a/src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs b/src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs index cae00bdc..5a664193 100644 --- a/src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs +++ b/src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -28,12 +28,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 { using System; using System.Collections.Generic; - using Algorithms.LinearAlgebra; using LinearAlgebra.Complex32; using LinearAlgebra.Generic; using Numerics; - using NUnit.Framework; /// @@ -57,11 +55,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 /// private readonly IDictionary _matrices = new Dictionary { - { "Singular3x3", new DenseMatrix(new[,] { { new Complex32(1.0f, 0.0f), 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } }) }, - { "Square3x3", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } }) }, - { "Square4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } }) }, - { "Singular4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } }) }, - { "Tall3x2", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) }, + { "Singular3x3", new DenseMatrix(new[,] { { new Complex32(1.0f, 0.0f), 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } }) }, + { "Square3x3", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } }) }, + { "Square4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } }) }, + { "Singular4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } }) }, + { "Tall3x2", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) }, { "Wide2x3", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } }) } }; @@ -181,7 +179,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 Assert.AreEqual(_x[i] / _y[i], result[i]); } } - + /// /// Can compute L1 norm. /// @@ -373,7 +371,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 for (var j = 0; j < c.ColumnCount; j++) { var test = 2.2f * x.Row(i) * y.Column(j); - + // if they are both close to zero, skip if (Math.Abs(test.Real) < 1e-7 && Math.Abs(c[i, j].Real) < 1e-7) { @@ -422,16 +420,16 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 var matrix = _matrices["Square3x3"]; var a = new Complex32[matrix.RowCount * matrix.RowCount]; Array.Copy(matrix.Data, a, a.Length); - + Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount); AssertHelpers.AlmostEqual(a[0], -0.454545454545454f, 6); - AssertHelpers.AlmostEqual(a[1], -0.909090909090908f, 6); + AssertHelpers.AlmostEqual(a[1], -0.909090909090908f, 6); AssertHelpers.AlmostEqual(a[2], 0.454545454545454f, 6); AssertHelpers.AlmostEqual(a[3], -0.340909090909090f, 6); AssertHelpers.AlmostEqual(a[4], -2.045454545454543f, 6); AssertHelpers.AlmostEqual(a[5], 1.477272727272726f, 6); - AssertHelpers.AlmostEqual(a[6], -0.113636363636364f, 6); + AssertHelpers.AlmostEqual(a[6], -0.113636363636364f, 6); AssertHelpers.AlmostEqual(a[7], 0.227272727272727f, 6); AssertHelpers.AlmostEqual(a[8], -0.113636363636364f, 6); } @@ -655,7 +653,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 { for (var col = 0; col < matrix.ColumnCount; col++) { - AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 6); + AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 6); } } } @@ -838,7 +836,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 var b = new[] { new Complex32(1.0f, 0.0f), 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; var x = new Complex32[matrix.ColumnCount * 2]; Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x); - + NotModified(3, 2, a, matrix); var mb = new DenseMatrix(matrix.RowCount, 2, b); @@ -1271,7 +1269,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 /// Can solve Ax=b using SVD factorization with a tall A matrix. /// [Test] - public void CanSolveUsingSVDTallMatrix() + public void CanSolveUsingSvdTallMatrix() { var matrix = _matrices["Tall3x2"]; var a = new Complex32[matrix.RowCount * matrix.ColumnCount]; @@ -1286,10 +1284,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 var mb = new DenseMatrix(matrix.RowCount, 2, b); var test = (matrix.Transpose() * matrix).Inverse() * matrix.Transpose() * mb; - AssertHelpers.AlmostEqual(test[0, 0], x[0], 6); - AssertHelpers.AlmostEqual(test[1, 0], x[1], 6); - AssertHelpers.AlmostEqual(test[0, 1], x[2], 6); - AssertHelpers.AlmostEqual(test[1, 1], x[3], 6); + AssertHelpers.AlmostEqual(test[0, 0], x[0], 5); + AssertHelpers.AlmostEqual(test[1, 0], x[1], 5); + AssertHelpers.AlmostEqual(test[0, 1], x[2], 5); + AssertHelpers.AlmostEqual(test[1, 1], x[3], 5); } /// @@ -1297,7 +1295,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 /// using a factored matrix. /// [Test] - public void CanSolveUsingSVDSquareMatrixOnFactoredMatrix() + public void CanSolveUsingSvdSquareMatrixOnFactoredMatrix() { var matrix = _matrices["Square3x3"]; var a = new Complex32[matrix.RowCount * matrix.ColumnCount]; @@ -1316,8 +1314,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 var mx = new DenseMatrix(matrix.ColumnCount, 2, x); var mb = matrix * mx; - AssertHelpers.AlmostEqual(mb[0, 0], b[0], 6); - AssertHelpers.AlmostEqual(mb[1, 0], b[1], 6); + AssertHelpers.AlmostEqual(mb[0, 0], b[0], 5); + AssertHelpers.AlmostEqual(mb[1, 0], b[1], 5); AssertHelpers.AlmostEqual(mb[2, 0], b[2], 5); AssertHelpers.AlmostEqual(mb[0, 1], b[3], 5); AssertHelpers.AlmostEqual(mb[1, 1], b[4], 5); @@ -1329,7 +1327,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 /// using a factored matrix. /// [Test] - public void CanSolveUsingSVDTallMatrixOnFactoredMatrix() + public void CanSolveUsingSvdTallMatrixOnFactoredMatrix() { var matrix = _matrices["Tall3x2"]; var a = new Complex32[matrix.RowCount * matrix.ColumnCount]; @@ -1348,10 +1346,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 var mb = new DenseMatrix(matrix.RowCount, 2, b); var test = (matrix.Transpose() * matrix).Inverse() * matrix.Transpose() * mb; - AssertHelpers.AlmostEqual(test[0, 0], x[0], 6); - AssertHelpers.AlmostEqual(test[1, 0], x[1], 6); - AssertHelpers.AlmostEqual(test[0, 1], x[2], 6); - AssertHelpers.AlmostEqual(test[1, 1], x[3], 6); + AssertHelpers.AlmostEqual(test[0, 0], x[0], 5); + AssertHelpers.AlmostEqual(test[1, 0], x[1], 5); + AssertHelpers.AlmostEqual(test[0, 1], x[2], 5); + AssertHelpers.AlmostEqual(test[1, 1], x[3], 5); } /// diff --git a/src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs b/src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs index 2bec971e..d73274a1 100644 --- a/src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs +++ b/src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -28,11 +28,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double { using System; using System.Collections.Generic; - using Algorithms.LinearAlgebra; using LinearAlgebra.Double; using LinearAlgebra.Generic; - using NUnit.Framework; /// @@ -56,11 +54,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double /// private readonly IDictionary _matrices = new Dictionary { - { "Singular3x3", new DenseMatrix(new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } }) }, - { "Square3x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } }) }, - { "Square4x4", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } }) }, - { "Singular4x4", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } }) }, - { "Tall3x2", new DenseMatrix(new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, + { "Singular3x3", new DenseMatrix(new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } }) }, + { "Square3x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } }) }, + { "Square4x4", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } }) }, + { "Singular4x4", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } }) }, + { "Tall3x2", new DenseMatrix(new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, { "Wide2x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) } }; @@ -180,7 +178,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double Assert.AreEqual(_x[i] / _y[i], result[i]); } } - + /// /// Can compute L1 norm. /// @@ -413,16 +411,16 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double var matrix = _matrices["Square3x3"]; var a = new double[matrix.RowCount * matrix.RowCount]; Array.Copy(matrix.Data, a, a.Length); - + Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount); AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 14); - AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14); + AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 14); AssertHelpers.AlmostEqual(a[2], 0.454545454545454, 14); AssertHelpers.AlmostEqual(a[3], -0.340909090909090, 14); AssertHelpers.AlmostEqual(a[4], -2.045454545454543, 14); AssertHelpers.AlmostEqual(a[5], 1.477272727272726, 14); - AssertHelpers.AlmostEqual(a[6], -0.113636363636364, 14); + AssertHelpers.AlmostEqual(a[6], -0.113636363636364, 14); AssertHelpers.AlmostEqual(a[7], 0.227272727272727, 14); AssertHelpers.AlmostEqual(a[8], -0.113636363636364, 14); } @@ -543,7 +541,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double var ipiv = new int[matrix.RowCount]; Control.LinearAlgebraProvider.LUFactor(a, matrix.RowCount, ipiv); - + var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; Control.LinearAlgebraProvider.LUSolveFactored(2, a, matrix.RowCount, ipiv, b); @@ -646,7 +644,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double { for (var col = 0; col < matrix.ColumnCount; col++) { - AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 14); + AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 14); } } } @@ -829,7 +827,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double var b = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; var x = new double[matrix.ColumnCount * 2]; Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x); - + NotModified(3, 2, a, matrix); var mb = new DenseMatrix(matrix.RowCount, 2, b); diff --git a/src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs b/src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs index 19b9cc4d..56ce00d2 100644 --- a/src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs +++ b/src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -28,11 +28,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single { using System; using System.Collections.Generic; - using Algorithms.LinearAlgebra; using LinearAlgebra.Generic; using LinearAlgebra.Single; - using NUnit.Framework; /// @@ -56,11 +54,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single /// private readonly IDictionary _matrices = new Dictionary { - { "Singular3x3", new DenseMatrix(new[,] { { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } }) }, - { "Square3x3", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } }) }, - { "Square4x4", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } }) }, - { "Singular4x4", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } }) }, - { "Tall3x2", new DenseMatrix(new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) }, + { "Singular3x3", new DenseMatrix(new[,] { { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } }) }, + { "Square3x3", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } }) }, + { "Square4x4", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } }) }, + { "Singular4x4", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } }) }, + { "Tall3x2", new DenseMatrix(new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) }, { "Wide2x3", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } }) } }; @@ -180,7 +178,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single Assert.AreEqual(_x[i] / _y[i], result[i]); } } - + /// /// Can compute L1 norm. /// @@ -372,7 +370,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single for (var j = 0; j < c.ColumnCount; j++) { var test = 2.2f * x.Row(i) * y.Column(j); - + // if they are both close to zero, skip if (Math.Abs(test) < 1e-7 && Math.Abs(c[i, j]) < 1e-7) { @@ -421,16 +419,16 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single var matrix = _matrices["Square3x3"]; var a = new float[matrix.RowCount * matrix.RowCount]; Array.Copy(matrix.Data, a, a.Length); - + Control.LinearAlgebraProvider.LUInverse(a, matrix.RowCount); AssertHelpers.AlmostEqual(a[0], -0.454545454545454, 6); - AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 6); + AssertHelpers.AlmostEqual(a[1], -0.909090909090908, 6); AssertHelpers.AlmostEqual(a[2], 0.454545454545454, 6); AssertHelpers.AlmostEqual(a[3], -0.340909090909090, 6); AssertHelpers.AlmostEqual(a[4], -2.045454545454543, 6); AssertHelpers.AlmostEqual(a[5], 1.477272727272726, 6); - AssertHelpers.AlmostEqual(a[6], -0.113636363636364, 6); + AssertHelpers.AlmostEqual(a[6], -0.113636363636364, 6); AssertHelpers.AlmostEqual(a[7], 0.227272727272727, 6); AssertHelpers.AlmostEqual(a[8], -0.113636363636364, 6); } @@ -654,7 +652,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single { for (var col = 0; col < matrix.ColumnCount; col++) { - AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 6); + AssertHelpers.AlmostEqual(matrix[row, col], a[row, col], 6); } } } @@ -837,7 +835,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single var b = new[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; var x = new float[matrix.ColumnCount * 2]; Control.LinearAlgebraProvider.QRSolve(a, matrix.RowCount, matrix.ColumnCount, b, 2, x); - + NotModified(3, 2, a, matrix); var mb = new DenseMatrix(matrix.RowCount, 2, b); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs index 4d8a6cdc..e8253f6c 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var testData = new Dictionary { - { "Singular3x3", new DenseMatrix(3, 3, new[] { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1), new Complex(2.0, 1), new Complex(2.0, 1) }) }, - { "Square3x3", new DenseMatrix(3, 3, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.6, 1) }) }, - { "Square4x4", new DenseMatrix(4, 4, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(1.0, 1), new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(2.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.2, 1), new Complex(6.6, 1), new Complex(-4.4, 1), new Complex(3.3, 1), new Complex(4.3, 1), new Complex(-7.7, 1) }) }, - { "Tall3x2", new DenseMatrix(3, 2, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1) }) }, + { "Singular3x3", new DenseMatrix(3, 3, new[] { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1), new Complex(2.0, 1), new Complex(2.0, 1) }) }, + { "Square3x3", new DenseMatrix(3, 3, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.6, 1) }) }, + { "Square4x4", new DenseMatrix(4, 4, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(1.0, 1), new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(2.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.2, 1), new Complex(6.6, 1), new Complex(-4.4, 1), new Complex(3.3, 1), new Complex(4.3, 1), new Complex(-7.7, 1) }) }, + { "Tall3x2", new DenseMatrix(3, 2, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1) }) }, { "Wide2x3", new DenseMatrix(2, 3, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(-3.3, 1), new Complex(2.2, 1) }) } }; @@ -127,8 +127,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DenseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -176,8 +181,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DenseMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs index b3ad942e..d6d4e6a0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseComplexDenseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1.1 , 2.1 , 3.1 ] ", " [ -1.1 , 2.1 , +3.1 ] ", " [1.2,3.4 , 5.6] ", "[1+1i,2+1i,3+1i]", " [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", " [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", " [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ")] string stringToParse, [Values("(2, 0)", "(3, 0)", "(1, 0),(2, 0),(3, 0)", "(1.1, 0),(2.1, 0),(3.1, 0)", "(-1.1, 0),(2.1, 0),(3.1, 0)", "(1.2, 0),(3.4, 0),(5.6, 0)", "(1, 1),(2, 1),(3, 1)", "(1.1, 1),(2.1, 1),(3.1, 1)", "(-1.1, 1),(2.1, -1),(3.1, 1)", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] string expectedToString) + [TestCase("2", "(2, 0)")] + [TestCase("(3)", "(3, 0)")] + [TestCase("[1,2,3]", "(1, 0),(2, 0),(3, 0)")] + [TestCase(" [ 1.1 , 2.1 , 3.1 ] ", "(1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [ -1.1 , 2.1 , +3.1 ] ", "(-1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [1.2,3.4 , 5.6] ", "(1.2, 0),(3.4, 0),(5.6, 0)")] + [TestCase("[1+1i,2+1i,3+1i]", "(1, 1),(2, 1),(3, 1)")] + [TestCase(" [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", "(1.1, 1),(2.1, 1),(3.1, 1)")] + [TestCase(" [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", "(-1.1, 1),(2.1, -1),(3.1, 1)")] + [TestCase(" [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] + public void CanParseComplexDenseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = DenseVector.Parse(stringToParse, formatProvider); @@ -57,10 +66,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseComplexDenseVectorsWithCulture([Values(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", " 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", " 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ")] string stringToParse, [Values("(1.2, 1),(3.4, 1),(5.6, 1)", "(1.2, 1);(3.4, 1);(5.6, 1)", "(1,2, 1);(3,4, 1);(5,6, 1)")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] + [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] +#if !SILVERLIGHT + [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] +#endif + public void CanParseComplexDenseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = DenseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -80,8 +93,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { DenseVector vector; var ret = DenseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs index 25c63753..42037cf5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs index 3a681937..f228ff55 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -33,6 +33,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex using LinearAlgebra.Complex; using NUnit.Framework; +#if SILVERLIGHT + using Threading; +#endif + /// /// Diagonal matrix tests. /// @@ -46,11 +50,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { new Complex(1.0, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(3.0, 1) } } }, - { "Square3x3", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(6.6, 1) } } }, - { "Square4x4", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(6.2, 1), Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, new Complex(-7.7, 1) } } }, - { "Singular4x4", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(-2.2, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, new Complex(-4.4, 1) } } }, - { "Tall3x2", new[,] { { new Complex(-1.1, 1), Complex.Zero }, { Complex.Zero, new Complex(1.1, 1) }, { Complex.Zero, Complex.Zero } } }, + { "Singular3x3", new[,] { { new Complex(1.0, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(3.0, 1) } } }, + { "Square3x3", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(6.6, 1) } } }, + { "Square4x4", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, new Complex(6.2, 1), Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, new Complex(-7.7, 1) } } }, + { "Singular4x4", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(-2.2, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero }, { Complex.Zero, Complex.Zero, Complex.Zero, new Complex(-4.4, 1) } } }, + { "Tall3x2", new[,] { { new Complex(-1.1, 1), Complex.Zero }, { Complex.Zero, new Complex(1.1, 1) }, { Complex.Zero, Complex.Zero } } }, { "Wide2x3", new[,] { { new Complex(-1.1, 1), Complex.Zero, Complex.Zero }, { Complex.Zero, new Complex(1.1, 1), Complex.Zero } } } }; @@ -111,11 +115,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var testData = new Dictionary { - { "Singular3x3", new DiagonalMatrix(3, 3, new[] { new Complex(1.0, 1), Complex.Zero, new Complex(3.0, 1) }) }, - { "Square3x3", new DiagonalMatrix(4, 4, new[] { new Complex(-1.1, 1), new Complex(1.1, 1), new Complex(6.6, 1) }) }, - { "Square4x4", new DiagonalMatrix(4, 4, new[] { new Complex(-1.1, 1), new Complex(1.1, 1), new Complex(6.2, 1), new Complex(-7.7, 1) }) }, - { "Tall3x2", new DiagonalMatrix(3, 2, new[] { new Complex(-1.1, 1), new Complex(1.1, 1) }) }, - { "Wide2x3", new DiagonalMatrix(2, 3, new[] { new Complex(-1.1, 1), new Complex(1.1, 1) }) }, + { "Singular3x3", new DiagonalMatrix(3, 3, new[] { new Complex(1.0, 1), Complex.Zero, new Complex(3.0, 1) }) }, + { "Square3x3", new DiagonalMatrix(4, 4, new[] { new Complex(-1.1, 1), new Complex(1.1, 1), new Complex(6.6, 1) }) }, + { "Square4x4", new DiagonalMatrix(4, 4, new[] { new Complex(-1.1, 1), new Complex(1.1, 1), new Complex(6.2, 1), new Complex(-7.7, 1) }) }, + { "Tall3x2", new DiagonalMatrix(3, 2, new[] { new Complex(-1.1, 1), new Complex(1.1, 1) }) }, + { "Wide2x3", new DiagonalMatrix(2, 3, new[] { new Complex(-1.1, 1), new Complex(1.1, 1) }) }, }; foreach (var name in testData.Keys) @@ -140,8 +144,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DiagonalMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -186,8 +195,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DiagonalMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs index af861a5c..4785eb0e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/CholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -84,8 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -97,8 +101,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(order); var chol = matrixX.Cholesky(); @@ -132,8 +141,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -166,8 +180,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(row); var matrixACopy = matrixA.Clone(); @@ -203,8 +222,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -245,8 +269,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/EvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/EvdTests.cs index edc99226..8b8e1668 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/EvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/EvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -76,8 +78,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -142,8 +149,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -155,8 +164,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -179,8 +190,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs index 1f7660ed..3337c886 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/GramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -60,8 +60,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -106,8 +108,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -119,8 +123,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -179,8 +188,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -213,8 +227,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -254,8 +273,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -295,8 +319,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs index 4b91ae2a..1657b60b 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/LUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -86,8 +88,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var lu = matrixI.LU(); @@ -98,8 +102,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorLU = matrixX.LU(); @@ -148,8 +157,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -182,8 +196,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -223,8 +242,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -264,8 +288,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -317,8 +346,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs index 605cd190..e7d56d70 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/QRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -60,8 +60,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -90,8 +92,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -103,8 +107,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorQR = matrixA.QR(); @@ -146,8 +155,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -180,8 +194,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -221,8 +240,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -262,8 +286,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs index 15609d40..fd9c761f 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/SvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -83,8 +85,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -120,8 +127,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -134,8 +143,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -154,8 +168,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -205,8 +221,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -240,8 +261,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -282,8 +308,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -322,8 +353,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs index fd964542..5a985623 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserCholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -83,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -96,8 +100,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var chol = matrixX.Cholesky(); @@ -131,8 +140,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -165,8 +179,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); @@ -202,8 +221,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -244,8 +268,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserEvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserEvdTests.cs index 4fdfc527..10d79e5f 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserEvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserEvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -75,8 +77,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -106,8 +113,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a symmetric random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var factorEvd = matrixA.Evd(); @@ -136,8 +148,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -149,8 +163,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -173,8 +189,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -185,8 +203,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -219,8 +242,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -260,8 +288,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorAndSymmetricMatrixWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorAndSymmetricMatrixWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -299,8 +332,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B) into result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs index 56c7e526..55ea0c0e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserGramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -58,8 +58,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -104,8 +106,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -117,8 +121,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -177,8 +186,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -211,8 +225,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -252,8 +271,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -293,8 +317,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs index 6ecc5f08..26b967ef 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserLUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -85,8 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var lu = matrixI.LU(); @@ -97,8 +101,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorLU = matrixX.LU(); @@ -147,8 +156,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -181,8 +195,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -222,8 +241,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -263,8 +287,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -316,8 +345,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs index 73379b18..43ea2fcf 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserQRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -59,8 +59,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -90,8 +92,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -103,8 +107,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorQR = matrixA.QR(); @@ -146,8 +155,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -180,8 +194,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -221,8 +240,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -262,8 +286,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs index cda32efb..42aa9037 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Factorization/UserSvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -82,8 +84,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -119,8 +126,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -133,8 +142,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -153,8 +167,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -204,8 +220,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -239,8 +260,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -281,8 +307,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -321,8 +352,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedReaderTests.cs index df8ed611..cb8283df 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -53,7 +53,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.IO var reader = new DelimitedReader(',') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = CultureInfo.InvariantCulture }; @@ -145,7 +145,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.IO var reader = new DelimitedReader('.') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = new CultureInfo("tr-TR") }; diff --git a/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs index ac77ad85..2cb0d5f0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/IO/DelimitedWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabReaderTests.cs index 4b6fe2a6..5fdbedb5 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabWriterTests.cs index e06e224b..486251df 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/IO/MatlabWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs index 48b27c68..eb5b97be 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -95,12 +95,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) } } }, - { "Square3x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1) } } }, - { "Square4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1), new Complex(3.3, 1) }, { new Complex(1.0, 1), new Complex(2.1, 1), new Complex(6.2, 1), new Complex(4.3, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1), new Complex(-7.7, 1) } } }, - { "Singular4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) } } }, - { "Tall3x2", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1) }, { Complex.Zero, new Complex(1.1, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1) } } }, - { "Wide2x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) } } }, + { "Singular3x3", new[,] { { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) } } }, + { "Square3x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1) } } }, + { "Square4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1), new Complex(3.3, 1) }, { new Complex(1.0, 1), new Complex(2.1, 1), new Complex(6.2, 1), new Complex(4.3, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1), new Complex(-7.7, 1) } } }, + { "Singular4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) } } }, + { "Tall3x2", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1) }, { Complex.Zero, new Complex(1.1, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1) } } }, + { "Wide2x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) } } }, { "Symmetric3x3", new[,] { { Complex.One, 2.0, 3.0 }, { 2.0, 2.0, 0.0 }, { 3.0, 0.0, 3.0 } } } }; diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs index 0e826c8a..93bb191d 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can multiply with a complex number. /// /// Complex real part value. - [Test] - public void CanMultiplyWithComplex([Values(0, 1, 2.2)] double real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanMultiplyWithComplex(double real) { var value = new Complex(real, 1.0); var matrix = TestMatrices["Singular3x3"]; @@ -148,8 +150,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can left multiply with a complex. /// /// Complex real value. - [Test, Sequential] - public void CanOperatorLeftMultiplyWithComplex([Values(0, 1, 2.2)] double real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanOperatorLeftMultiplyWithComplex(double real) { var value = new Complex(real, 1.0); var matrix = TestMatrices["Singular3x3"]; @@ -168,8 +172,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can right multiply with a Complex. /// /// Complex real value. - [Test, Sequential] - public void CanOperatorRightMultiplyWithComplex([Values(0, 1, 2.2)] double real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanOperatorRightMultiplyWithComplex(double real) { var value = new Complex(real, 1.0); var matrix = TestMatrices["Singular3x3"]; @@ -188,8 +194,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can multiply with a Complex into result. /// /// Complex real value. - [Test] - public void CanMultiplyWithComplexIntoResult([Values(0, 1, 2.2)] double real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanMultiplyWithComplexIntoResult(double real) { var value = new Complex(real, 1.0); var matrix = TestMatrices["Singular3x3"]; @@ -263,8 +271,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -318,8 +327,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -383,8 +393,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -438,8 +449,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -503,8 +515,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public void CanMultiplyMatrixWithMatrix(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -526,8 +542,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can transpose and multiply a matrix with matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -605,8 +624,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can transpose and multiply a matrix with matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -624,7 +646,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } } - + /// /// Multiply a matrix with incompatible size matrix throws ArgumentException. /// @@ -663,8 +685,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public virtual void CanMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public virtual void CanMultiplyMatrixWithMatrixIntoResult(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -772,8 +798,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can multiply transposed matrix with another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -817,8 +846,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Multiply transpose of this matrix with another matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -841,8 +873,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can negate a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegate([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegate(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -862,8 +898,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can negate a matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegateIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegateIntoResult(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -965,8 +1005,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can normalize columns of a matrix. /// /// The norm under which to normalize the columns under. - [Test, Sequential] - public void CanNormalizeColumns([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeColumns(int p) { var matrix = TestMatrices["Square4x4"]; var result = matrix.NormalizeColumns(p); @@ -990,8 +1031,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can normalize rows of a matrix. /// /// The norm under which to normalize the rows under. - [Test, Sequential] - public void CanNormalizeRows([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeRows(int p) { var matrix = TestMatrices["Square4x4"].NormalizeRows(p); for (var i = 0; i < matrix.RowCount; i++) @@ -1166,8 +1208,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Create random matrix with non-positive number of rows throw ArgumentException. /// /// Number of rows. - [Test, Sequential] - public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException([Values(0, -2)] int numberOfRows) + [TestCase(0)] + [TestCase(-2)] + public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { var matrix = CreateMatrix(2, 3); Assert.Throws(() => matrix.Random(numberOfRows, 4, new ContinuousUniform())); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.cs index 1b34b2c9..de188d39 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,15 +34,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Abstract class with the common set of matrix tests /// - [TestFixture] public abstract partial class MatrixTests : MatrixLoader { /// /// Can clone a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var clone = matrix.Clone(); @@ -63,8 +66,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can clone a matrix using ICloneable interface. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrixUsingICloneable([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrixUsingICloneable(string name) { var matrix = TestMatrices[name]; var clone = (Matrix)((ICloneable)matrix).Clone(); @@ -85,8 +92,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can copy a matrix to another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCopyTo([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCopyTo(string name) { var matrix = TestMatrices[name]; var copy = CreateMatrix(matrix.RowCount, matrix.ColumnCount); @@ -150,8 +161,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can equate matrices. /// /// Matrix name. - [Test, Sequential] - public void CanEquateMatrices([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanEquateMatrices(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -167,8 +182,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// The number of rows. /// The number of columns. - [Test, Sequential] - public void IfSizeIsNotPositiveThrowsArgumentException([Values(0, 2, 0, -1, 1)] int rows, [Values(2, 0, 0, 1, -1)] int columns) + [TestCase(0, 2)] + [TestCase(2, 0)] + [TestCase(0, 0)] + [TestCase(-1, 1)] + [TestCase(1, -1)] + public void IfSizeIsNotPositiveThrowsArgumentException(int rows, int columns) { Assert.Throws(() => CreateMatrix(rows, columns)); } @@ -177,8 +196,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Testing for equality with non-matrix returns false. /// /// Matrix name. - [Test, Sequential] - public void TestingForEqualityWithNonMatrixReturnsFalse([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void TestingForEqualityWithNonMatrixReturnsFalse(string name) { var matrix = CreateMatrix(TestData2D[name]); Assert.IsFalse(matrix.Equals(2)); @@ -188,8 +211,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can test for equality using Object.Equals. /// /// Matrix name. - [Test, Sequential] - public void CanTestForEqualityUsingObjectEquals([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTestForEqualityUsingObjectEquals(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -202,8 +229,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Row index. /// Column index. /// Matrix name. - [Test, Sequential] - public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException([Values(-1, 1, 4)] int i, [Values(1, -1, 2)] int j, [Values("Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(-1, 1, "Singular3x3")] + [TestCase(1, -1, "Singular3x3")] + [TestCase(4, 2, "Square3x3")] + public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException(int i, int j, string name) { Assert.Throws(() => { var x = TestMatrices[name][i, j]; }); } @@ -239,8 +268,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRow(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex); @@ -277,8 +308,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRowIntoResult([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRowIntoResult(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = CreateVector(matrix.ColumnCount); @@ -330,8 +363,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Column start. /// Row length. /// Matrix name. - [Test, Sequential] - public void CanGetRowWithRange([Values(0, 1, 2, 2)] int rowIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetRowWithRange(int rowIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex, start, length); @@ -370,8 +406,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumn(int colIndex, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex); @@ -408,8 +446,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumnIntoResult([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumnIntoResult(int colIndex, string name) { var matrix = TestMatrices[name]; var col = CreateVector(matrix.RowCount); @@ -461,8 +501,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Start index. /// Column length. /// Matrix name. - [Test, Sequential] - public void CanGetColumnWithRange([Values(0, 1, 2, 2)] int colIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetColumnWithRange(int colIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex, start, length); @@ -501,8 +544,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanSetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetRow(int rowIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetRow(rowIndex, CreateVector(matrix.ColumnCount)); @@ -521,8 +566,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanSetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetColumn(int colIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetColumn(colIndex, CreateVector(matrix.ColumnCount)); @@ -540,8 +587,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Get an upper triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangle(string name) { var data = TestMatrices[name]; var upper = data.UpperTriangle(); @@ -558,8 +609,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Get an upper triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -610,8 +665,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Get a lower triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangle(string name) { var data = TestMatrices[name]; var lower = data.LowerTriangle(); @@ -628,8 +687,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Get a lower triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -824,8 +887,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can transpose a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTransposeMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var transpose = matrix.Transpose(); @@ -846,8 +913,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can conjugate transpose a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanConjugateTransposeMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanConjugateTransposeMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var transpose = matrix.ConjugateTranspose(); @@ -869,8 +940,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix name. /// Column real values array. - [Test, Sequential] - public virtual void CanSetColumnWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 })] double[] real) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + public virtual void CanSetColumnWithArray(string name, double[] real) { var column = new Complex[real.Length]; for (var i = 0; i < real.Length; i++) @@ -926,8 +1000,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix name. /// Column real values. - [Test, Sequential] - public virtual void CanSetColumnWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 })] double[] real) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + public virtual void CanSetColumnWithVector(string name, double[] real) { var column = new Complex[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1046,8 +1123,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix name. /// Row index. - [Test, Sequential] - public virtual void CanSetRowWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2, 3 })] double[] real) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + [TestCase("Wide2x3", new double[] { 1, 2, 3 })] + public virtual void CanSetRowWithArray(string name, double[] real) { var row = new Complex[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1093,8 +1173,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix name. /// Row real values. - [Test, Sequential] - public virtual void CanSetRowWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2, 3 })] double[] real) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + [TestCase("Wide2x3", new double[] { 1, 2, 3 })] + public virtual void CanSetRowWithVector(string name, double[] real) { var row = new Complex[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1154,8 +1237,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void CanSetSubMatrix([Values(0, 1)] int rowStart, [Values(2, 1)] int rowLength, [Values(0, 1)] int colStart, [Values(2, 1)] int colLength) + [TestCase(0, 2, 0, 2)] + [TestCase(1, 1, 1, 1)] + public virtual void CanSetSubMatrix(int rowStart, int rowLength, int colStart, int colLength) { foreach (var matrix in TestMatrices.Values) { @@ -1183,8 +1267,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException([Values(0, 0, 4, 0, -1, 0)] int rowStart, [Values(4, 2, 2, 2, 2, 2)] int rowLength, [Values(0, 0, 0, 4, 0, -1)] int colStart, [Values(2, 4, 2, 2, 2, 2)] int colLength) + [TestCase(0, 4, 0, 2)] + [TestCase(0, 2, 0, 4)] + [TestCase(4, 2, 0, 2)] + [TestCase(0, 2, 4, 2)] + [TestCase(-1, 2, 0, 2)] + [TestCase(0, 2, -1, 2)] + public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0; @@ -1201,8 +1290,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException([Values(0, 0)] int rowStart, [Values(-1, 2)] int rowLength, [Values(0, 0)] int colStart, [Values(2, -1)] int colLength) + [TestCase(0, -1, 0, 2)] + [TestCase(0, 2, 0, -1)] + public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0; @@ -1227,8 +1317,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix name. /// Diagonal real values. - [Test, Sequential] - public void CanSetDiagonalVector([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2 })] double[] real) + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + public void CanSetDiagonalVector(string name, double[] real) { var diagonal = new Complex[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1274,8 +1366,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Matrix name. /// Diagonal real values. - [Test, Sequential] - public void CanSetDiagonalArray([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2 })] double[] real) + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + public void CanSetDiagonalArray(string name, double[] real) { var diagonal = new Complex[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1443,8 +1537,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can permute matrix rows. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixRows([Values("Singular3x3", "Square3x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Tall3x2")] + public virtual void CanPermuteMatrixRows(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); @@ -1468,8 +1564,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can permute matrix columns. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixColumns([Values("Singular3x3", "Square3x3", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Wide2x3")] + public virtual void CanPermuteMatrixColumns(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs index dba213af..94efd775 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs @@ -92,9 +92,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -246,16 +246,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new BiCgStab(monitor); @@ -276,16 +278,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new BiCgStab(monitor); var matrixX = solver.Solve(matrixA, matrixB); @@ -297,6 +301,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ Assert.AreEqual(matrixB.ColumnCount, matrixX.ColumnCount); var matrixBReconstruct = matrixA * matrixX; + // Check the reconstruction. for (var i = 0; i < matrixB.RowCount; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs index 0c531659..502478f9 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new GpBiCg(monitor); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -247,16 +247,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new GpBiCg(monitor); @@ -277,16 +279,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new GpBiCg(monitor); var matrixX = solver.Solve(matrixA, matrixB); @@ -298,6 +302,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ Assert.AreEqual(matrixB.ColumnCount, matrixX.ColumnCount); var matrixBReconstruct = matrixA * matrixX; + // Check the reconstruction. for (var i = 0; i < matrixB.RowCount; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs index c55fd4bd..db0ebf20 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs @@ -90,9 +90,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -214,9 +214,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -245,16 +245,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new MlkBiCgStab(monitor); @@ -275,16 +277,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new MlkBiCgStab(monitor); var matrixX = solver.Solve(matrixA, matrixB); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs index 03b727cd..dffdf776 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs @@ -90,9 +90,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -214,9 +214,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -245,16 +245,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new TFQMR(monitor); @@ -275,16 +277,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new TFQMR(monitor); var matrixX = solver.Solve(matrixA, matrixB); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs index f8d58679..e15ff400 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/IteratorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { Assert.Throws(() => new Iterator(new IIterationStopCriterium[] { - new FailureStopCriterium(), + new FailureStopCriterium(), new FailureStopCriterium() })); } @@ -94,9 +94,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -143,9 +143,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(); @@ -175,9 +175,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -194,9 +194,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), }; var iterator = new Iterator(criteria); Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); @@ -213,9 +213,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -236,9 +236,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var iterator = new Iterator(); Assert.Throws(() => iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 5), + 0, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -250,17 +250,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -272,17 +272,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -294,17 +294,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 5), - null, + 1, + new DenseVector(3, 5), + null, new DenseVector(3, 6))); } @@ -316,17 +316,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -338,8 +338,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -347,17 +347,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); // Second step, should run out of iterations. iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationStoppedWithoutConvergence), iterator.Status, "Incorrect status"); } @@ -370,8 +370,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -379,9 +379,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); @@ -400,9 +400,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; @@ -416,6 +416,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers // ReSharper disable PossibleNullReferenceException Assert.AreEqual(iterator.NumberOfCriteria, clone.NumberOfCriteria, "Incorrect criterium count"); + // ReSharper restore PossibleNullReferenceException var enumerator = clone.StoredStopCriteria; while (enumerator.MoveNext()) diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs index 4321d375..71b15204 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs @@ -74,11 +74,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi { var type = ilutp.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilutp, null); return (T)obj; @@ -138,8 +138,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi { var result = new Ilutp { - DropTolerance = _dropTolerance, - FillLevel = _fillLevel, + DropTolerance = _dropTolerance, + FillLevel = _fillLevel, PivotTolerance = _pivotTolerance }; return result; @@ -240,8 +240,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 0.0, - DropTolerance = 0, + PivotTolerance = 0.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -296,8 +296,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -333,8 +333,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi var vector = CreateStandardBcVector(Size); var preconditioner = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; preconditioner.Initialize(newMatrix); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs index c0cf0849..d3546f14 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs @@ -48,11 +48,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi { var type = ilu.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilu, null); return (T)obj; diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index a09148ac..366c7f5a 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs @@ -108,9 +108,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -122,9 +122,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -143,9 +143,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit for (var i = 0; i < Iterations - 1; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + i, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex((i + 1) * (Increase + 0.1), 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -167,9 +167,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit for (var i = 0; i < Iterations * 2; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + i, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex((i + 1) * (Increase - 0.01), 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -191,9 +191,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit for (var i = 0; i < Iterations - 5; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + i, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex((i + 1) * (Increase - 0.01), 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -201,9 +201,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit // Now make it fail by throwing in a NaN criterium.DetermineStatus( - Iterations, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + Iterations, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex(double.NaN, 0) })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -226,9 +226,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit { previous *= 1 + Increase + 0.01; criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + i, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex(previous, 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -237,9 +237,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit // Add the final residual. Now we should have divergence previous *= 1 + Increase + 0.01; criterium.DetermineStatus( - Iterations - 1, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + Iterations - 1, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex(previous, 0) })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -258,9 +258,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit // Add residuals. Blow it up instantly criterium.DetermineStatus( - 1, - new DenseVector(new[] { new Complex(1.0, 0) }), - new DenseVector(new[] { new Complex(1.0, 0) }), + 1, + new DenseVector(new[] { new Complex(1.0, 0) }), + new DenseVector(new[] { new Complex(1.0, 0) }), new DenseVector(new[] { new Complex(double.NaN, 0) })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -294,6 +294,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.MaximumRelativeIncrease, clonedCriterium.MaximumRelativeIncrease, "Incorrect maximum"); Assert.AreEqual(criterium.MinimumNumberOfIterations, clonedCriterium.MinimumNumberOfIterations, "Incorrect iteration count"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index 588ba8b5..af2c2f39 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -134,6 +134,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.MaximumNumberOfIterations, clonedCriterium.MaximumNumberOfIterations, "Clone failed"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index 2bb0311a..29547626 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/Solvers/StopCriterium/ResidualStopCriteriumTest.cs @@ -106,9 +106,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -122,9 +122,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -138,9 +138,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - null, + 1, + new DenseVector(3, 4), + null, new DenseVector(3, 6))); } @@ -154,9 +154,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -170,9 +170,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(4, 4), - new DenseVector(3, 4), + 1, + new DenseVector(4, 4), + new DenseVector(3, 4), new DenseVector(3, 4))); } @@ -186,9 +186,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(4, 4), + 1, + new DenseVector(3, 4), + new DenseVector(4, 4), new DenseVector(3, 4))); } @@ -202,9 +202,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(4, 4))); } @@ -326,6 +326,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.StopCrit // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.Maximum, clonedCriterium.Maximum, "Clone failed"); Assert.AreEqual(criterium.MinimumIterationsBelowMaximum, clonedCriterium.MinimumIterationsBelowMaximum, "Clone failed"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs index 2183d7e4..d70cc6ed 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { var testData = new Dictionary { - { "Singular3x3", new SparseMatrix(3, 3, new[] { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1), new Complex(2.0, 1), new Complex(2.0, 1) }) }, - { "Square3x3", new SparseMatrix(3, 3, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.6, 1) }) }, - { "Square4x4", new SparseMatrix(4, 4, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(1.0, 1), new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(2.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.2, 1), new Complex(6.6, 1), new Complex(-4.4, 1), new Complex(3.3, 1), new Complex(4.3, 1), new Complex(-7.7, 1) }) }, - { "Tall3x2", new SparseMatrix(3, 2, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1) }) }, + { "Singular3x3", new SparseMatrix(3, 3, new[] { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1), new Complex(2.0, 1), new Complex(2.0, 1) }) }, + { "Square3x3", new SparseMatrix(3, 3, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.6, 1) }) }, + { "Square4x4", new SparseMatrix(4, 4, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(1.0, 1), new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(2.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.2, 1), new Complex(6.6, 1), new Complex(-4.4, 1), new Complex(3.3, 1), new Complex(4.3, 1), new Complex(-7.7, 1) }) }, + { "Tall3x2", new SparseMatrix(3, 2, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1) }) }, { "Wide2x3", new SparseMatrix(2, 3, new[] { new Complex(-1.1, 1), Complex.Zero, new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(-3.3, 1), new Complex(2.2, 1) }) } }; @@ -128,8 +128,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new SparseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -177,8 +182,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => SparseMatrix.Identity(order)); } @@ -304,10 +310,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [Test] public void CanCreateLargeMatrix() { - const int order = 1000000; - var matrix = new SparseMatrix(order); - Assert.AreEqual(order, matrix.RowCount); - Assert.AreEqual(order, matrix.ColumnCount); + const int Order = 1000000; + var matrix = new SparseMatrix(Order); + Assert.AreEqual(Order, matrix.RowCount); + Assert.AreEqual(Order, matrix.ColumnCount); Assert.DoesNotThrow(() => matrix[0, 0] = 1); } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs index 2952049a..8301d7b0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseComplexSparseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1.1 , 2.1 , 3.1 ] ", " [ -1.1 , 2.1 , +3.1 ] ", " [1.2,3.4 , 5.6] ", "[1+1i,2+1i,3+1i]", " [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", " [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", " [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ")] string stringToParse, [Values("(2, 0)", "(3, 0)", "(1, 0),(2, 0),(3, 0)", "(1.1, 0),(2.1, 0),(3.1, 0)", "(-1.1, 0),(2.1, 0),(3.1, 0)", "(1.2, 0),(3.4, 0),(5.6, 0)", "(1, 1),(2, 1),(3, 1)", "(1.1, 1),(2.1, 1),(3.1, 1)", "(-1.1, 1),(2.1, -1),(3.1, 1)", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] string expectedToString) + [TestCase("2", "(2, 0)")] + [TestCase("(3)", "(3, 0)")] + [TestCase("[1,2,3]", "(1, 0),(2, 0),(3, 0)")] + [TestCase(" [ 1.1 , 2.1 , 3.1 ] ", "(1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [ -1.1 , 2.1 , +3.1 ] ", "(-1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [1.2,3.4 , 5.6] ", "(1.2, 0),(3.4, 0),(5.6, 0)")] + [TestCase("[1+1i,2+1i,3+1i]", "(1, 1),(2, 1),(3, 1)")] + [TestCase(" [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", "(1.1, 1),(2.1, 1),(3.1, 1)")] + [TestCase(" [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", "(-1.1, 1),(2.1, -1),(3.1, 1)")] + [TestCase(" [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] + public void CanParseComplexSparseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = SparseVector.Parse(stringToParse, formatProvider); @@ -56,10 +65,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseComplexSparseVectorsWithCulture([Values(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", " 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", " 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ")] string stringToParse, [Values("(1.2, 1),(3.4, 1),(5.6, 1)", "(1.2, 1);(3.4, 1);(5.6, 1)", "(1,2, 1);(3,4, 1);(5,6, 1)")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] + [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] +#if !SILVERLIGHT + [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] +#endif + public void CanParseComplexSparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = SparseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -79,8 +92,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { SparseVector vector; var ret = SparseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs index 374e5910..a7732477 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs index 45a59f92..3f5243e6 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrixTests.cs index a711c74f..11aef56e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVector.cs b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVector.cs index 76991a09..8f341ee8 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVector.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVector.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVectorTests.cs index a42effc7..b7c0cee7 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs index d5bace77..0b835161 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Norm.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Norm.cs index b8761b01..5b59dcb3 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Norm.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Norm.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -70,8 +70,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// The norm index. /// The expected P-norm value. - [Test, Sequential] - public void CanComputeNormP([Values(1, 2, 3, 10)] int p, [Values(16.0346843392517, 7.74596669241483, 6.28528392332871, 5.1608912235454)] double expected) + [TestCase(1, 16.0346843392517)] + [TestCase(2, 7.74596669241483)] + [TestCase(3, 6.28528392332871)] + [TestCase(10, 5.1608912235454)] + public void CanComputeNormP(int p, double expected) { var vector = CreateVector(Data); AssertHelpers.AlmostEqual(expected, vector.Norm(p), 15); diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs index 278dbe53..406e183b 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,7 +39,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Abstract class with the common set of vector tests. /// - [TestFixture] public abstract partial class VectorTests { /// @@ -61,6 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex CollectionAssert.AreEqual(vector, clone); } +#if !SILVERLIGHT /// /// Can clone a vector using IClonable interface method. /// @@ -74,6 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.AreEqual(vector.Count, clone.Count); CollectionAssert.AreEqual(vector, clone); } +#endif /// /// Can convert vector to string. @@ -307,8 +308,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Sequential] - public void CanGetSubVector([Values(0, 2, 1)] int index, [Values(5, 2, 4)] int length) + [TestCase(0, 5)] + [TestCase(2, 2)] + [TestCase(1, 4)] + public void CanGetSubVector(int index, int length) { var vector = CreateVector(Data); var sub = vector.SubVector(index, length); @@ -324,8 +327,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Combinatorial] - public void CanGetSubVectorWithWrongValuesShouldThrowException([Values(6, 1)] int index, [Values(10, -10)] int length) + [TestCase(6, 10)] + [TestCase(1, -10)] + public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); Assert.Throws(() => vector.SubVector(index, length)); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs index c061b289..d690b5f2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var testData = new Dictionary { - { "Singular3x3", new DenseMatrix(3, 3, new[] { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1) }) }, - { "Square3x3", new DenseMatrix(3, 3, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.6f, 1) }) }, - { "Square4x4", new DenseMatrix(4, 4, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(1.0f, 1), new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(2.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.2f, 1), new Complex32(6.6f, 1), new Complex32(-4.4f, 1), new Complex32(3.3f, 1), new Complex32(4.3f, 1), new Complex32(-7.7f, 1) }) }, - { "Tall3x2", new DenseMatrix(3, 2, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1) }) }, + { "Singular3x3", new DenseMatrix(3, 3, new[] { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1) }) }, + { "Square3x3", new DenseMatrix(3, 3, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.6f, 1) }) }, + { "Square4x4", new DenseMatrix(4, 4, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(1.0f, 1), new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(2.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.2f, 1), new Complex32(6.6f, 1), new Complex32(-4.4f, 1), new Complex32(3.3f, 1), new Complex32(4.3f, 1), new Complex32(-7.7f, 1) }) }, + { "Tall3x2", new DenseMatrix(3, 2, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1) }) }, { "Wide2x3", new DenseMatrix(2, 3, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1) }) } }; @@ -127,8 +127,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DenseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -176,8 +181,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DenseMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs index 668453ca..0db9b541 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseComplex32DenseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1.1 , 2.1 , 3.1 ] ", " [ -1.1 , 2.1 , +3.1 ] ", " [1.2,3.4 , 5.6] ", "[1+1i,2+1i,3+1i]", " [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", " [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", " [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ")] string stringToParse, [Values("(2, 0)", "(3, 0)", "(1, 0),(2, 0),(3, 0)", "(1.1, 0),(2.1, 0),(3.1, 0)", "(-1.1, 0),(2.1, 0),(3.1, 0)", "(1.2, 0),(3.4, 0),(5.6, 0)", "(1, 1),(2, 1),(3, 1)", "(1.1, 1),(2.1, 1),(3.1, 1)", "(-1.1, 1),(2.1, -1),(3.1, 1)", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] string expectedToString) + [TestCase("2", "(2, 0)")] + [TestCase("(3)", "(3, 0)")] + [TestCase("[1,2,3]", "(1, 0),(2, 0),(3, 0)")] + [TestCase(" [ 1.1 , 2.1 , 3.1 ] ", "(1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [ -1.1 , 2.1 , +3.1 ] ", "(-1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [1.2,3.4 , 5.6] ", "(1.2, 0),(3.4, 0),(5.6, 0)")] + [TestCase("[1+1i,2+1i,3+1i]", "(1, 1),(2, 1),(3, 1)")] + [TestCase(" [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", "(1.1, 1),(2.1, 1),(3.1, 1)")] + [TestCase(" [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", "(-1.1, 1),(2.1, -1),(3.1, 1)")] + [TestCase(" [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] + public void CanParseComplex32DenseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = DenseVector.Parse(stringToParse, formatProvider); @@ -57,10 +66,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseComplex32DenseVectorsWithCulture([Values(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", " 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", " 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ")] string stringToParse, [Values("(1.2, 1),(3.4, 1),(5.6, 1)", "(1.2, 1);(3.4, 1);(5.6, 1)", "(1,2, 1);(3,4, 1);(5,6, 1)")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] + [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] +#if !SILVERLIGHT + [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] +#endif + public void CanParseComplex32DenseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = DenseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -80,8 +93,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { DenseVector vector; var ret = DenseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs index c86b8055..b603509e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs index c8f377f7..e789e8f1 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -33,6 +33,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 using NUnit.Framework; using Complex32 = Numerics.Complex32; +#if SILVERLIGHT + using Threading; +#endif + /// /// Diagonal matrix tests. /// @@ -46,11 +50,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { new Complex32(1.0f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, new Complex32(3.0f, 1) } } }, - { "Square3x3", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1), Complex32.Zero }, { Complex32.Zero, Complex32.Zero, new Complex32(6.6f, 1) } } }, - { "Square4x4", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, new Complex32(6.2f, 1), Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero, new Complex32(-7.7f, 1) } } }, - { "Singular4x4", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(-2.2f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero, new Complex32(-4.4f, 1) } } }, - { "Tall3x2", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1) }, { Complex32.Zero, Complex32.Zero } } }, + { "Singular3x3", new[,] { { new Complex32(1.0f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, new Complex32(3.0f, 1) } } }, + { "Square3x3", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1), Complex32.Zero }, { Complex32.Zero, Complex32.Zero, new Complex32(6.6f, 1) } } }, + { "Square4x4", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, new Complex32(6.2f, 1), Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero, new Complex32(-7.7f, 1) } } }, + { "Singular4x4", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(-2.2f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero, Complex32.Zero }, { Complex32.Zero, Complex32.Zero, Complex32.Zero, new Complex32(-4.4f, 1) } } }, + { "Tall3x2", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1) }, { Complex32.Zero, Complex32.Zero } } }, { "Wide2x3", new[,] { { new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero }, { Complex32.Zero, new Complex32(1.1f, 1), Complex32.Zero } } } }; @@ -111,11 +115,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var testData = new Dictionary { - { "Singular3x3", new DiagonalMatrix(3, 3, new[] { new Complex32(1.0f, 1), Complex32.Zero, new Complex32(3.0f, 1) }) }, - { "Square3x3", new DiagonalMatrix(4, 4, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1), new Complex32(6.6f, 1) }) }, - { "Square4x4", new DiagonalMatrix(4, 4, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1), new Complex32(6.2f, 1), new Complex32(-7.7f, 1) }) }, - { "Tall3x2", new DiagonalMatrix(3, 2, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1) }) }, - { "Wide2x3", new DiagonalMatrix(2, 3, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1) }) }, + { "Singular3x3", new DiagonalMatrix(3, 3, new[] { new Complex32(1.0f, 1), Complex32.Zero, new Complex32(3.0f, 1) }) }, + { "Square3x3", new DiagonalMatrix(4, 4, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1), new Complex32(6.6f, 1) }) }, + { "Square4x4", new DiagonalMatrix(4, 4, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1), new Complex32(6.2f, 1), new Complex32(-7.7f, 1) }) }, + { "Tall3x2", new DiagonalMatrix(3, 2, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1) }) }, + { "Wide2x3", new DiagonalMatrix(2, 3, new[] { new Complex32(-1.1f, 1), new Complex32(1.1f, 1) }) }, }; foreach (var name in testData.Keys) @@ -140,8 +144,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DiagonalMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -186,8 +195,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DiagonalMatrix.Identity(order)); } @@ -592,6 +602,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 var matrix = TestMatrices["Square3x3"]; Assert.IsTrue(matrix.IsSymmetric); } + /// /// Can get a sub-matrix. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs index 8f387257..870d1c17 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/CholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -83,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -96,8 +100,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(order); var chol = matrixX.Cholesky(); @@ -132,8 +141,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -167,8 +181,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(row); var matrixACopy = matrixA.Clone(); @@ -205,8 +224,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -248,8 +272,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianDenseMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/EvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/EvdTests.cs index ba705c01..b3a0a2d2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/EvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/EvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -52,8 +52,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -77,8 +79,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -138,8 +145,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -151,8 +160,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -175,8 +186,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -187,7 +200,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b). /// /// Matrix order. - [Test,Ignore] + [Test, Ignore] [TestCase(1)] [TestCase(2)] [TestCase(5, Ignore = true, IgnoreReason = "Problem with native providers determining if the matrix is symmetric.")] diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs index 5098b102..fca0d180 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/GramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -60,15 +60,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); var q = factorGramSchmidt.Q; var r = factorGramSchmidt.R; - Assert.AreEqual(matrixI.RowCount, q.RowCount); + Assert.AreEqual(matrixI.RowCount, q.RowCount); Assert.AreEqual(matrixI.ColumnCount, q.ColumnCount); for (var i = 0; i < r.RowCount; i++) @@ -106,8 +108,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -119,8 +123,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -182,8 +191,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -217,8 +231,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -259,8 +278,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -301,8 +325,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs index 198c8d56..cf38c4aa 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/LUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -86,8 +88,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var lu = matrixI.LU(); @@ -98,8 +102,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorLU = matrixX.LU(); @@ -149,8 +158,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -184,8 +198,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -226,8 +245,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -268,8 +292,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -322,8 +351,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs index bdcd95da..4e4b4ee0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/QRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -60,8 +60,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -90,8 +92,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -103,8 +107,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorQR = matrixA.QR(); @@ -166,8 +175,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -201,8 +215,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -243,8 +262,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -285,8 +309,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs index b875d72e..188d1a29 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/SvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -83,8 +85,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -121,8 +128,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -135,8 +144,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -155,8 +169,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -206,8 +222,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -242,8 +263,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -285,8 +311,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -326,8 +357,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs index 78f3fa5f..79340733 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserCholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -83,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -96,8 +100,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var chol = matrixX.Cholesky(); @@ -132,8 +141,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -167,8 +181,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); @@ -205,8 +224,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -248,8 +272,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserEvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserEvdTests.cs index b6e8341f..90e5c873 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserEvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserEvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -76,8 +78,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -139,8 +146,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -152,8 +161,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -176,8 +187,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -223,8 +236,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -305,8 +323,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B) into result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs index ec49bb45..54ba2f29 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserGramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -58,8 +58,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -104,8 +106,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -117,8 +121,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -180,8 +189,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -215,8 +229,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -257,8 +276,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -299,8 +323,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs index f2ea0ec4..ac1198e2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserLUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -85,8 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var lu = matrixI.LU(); @@ -97,8 +101,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorLU = matrixX.LU(); @@ -148,8 +157,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -183,8 +197,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -225,8 +244,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -267,8 +291,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -321,8 +350,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs index 9b92b2ca..04956678 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserQRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -59,8 +59,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -89,8 +91,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -102,8 +106,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorQR = matrixA.QR(); @@ -165,8 +174,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -200,8 +214,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -242,8 +261,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -284,8 +308,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs index b876339a..1567b987 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Factorization/UserSvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -82,8 +84,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -120,8 +127,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -134,8 +143,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -154,8 +168,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -205,8 +221,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -241,8 +262,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -284,8 +310,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -325,8 +356,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedReaderTests.cs index bd162652..01ed3748 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -53,7 +53,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.IO var reader = new DelimitedReader(',') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = CultureInfo.InvariantCulture }; @@ -145,7 +145,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.IO var reader = new DelimitedReader('.') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = new CultureInfo("tr-TR") }; diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs index 41198b75..b1657140 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/IO/DelimitedWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabReaderTests.cs index a414ebb5..ae0e6dd9 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabWriterTests.cs index 006ca542..c21d51d9 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/IO/MatlabWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs index ff031c31..26e2ea6d 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -95,11 +95,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) } } }, - { "Square3x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1) } } }, - { "Square4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1) }, { new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1) } } }, - { "Singular4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) } } }, - { "Tall3x2", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1) } } }, + { "Singular3x3", new[,] { { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) } } }, + { "Square3x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1) } } }, + { "Square4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1) }, { new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1) } } }, + { "Singular4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) } } }, + { "Tall3x2", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1) } } }, { "Wide2x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) } } }, { "Symmetric3x3", new[,] { { Complex32.One, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } } }; diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs index c3c680ea..e97197e9 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can multiply with a complex number. /// /// Complex32 real part value. - [Test] - public void CanMultiplyWithComplex([Values(0, 1, 2.2f)] float real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanMultiplyWithComplex(float real) { var value = new Complex32(real, 1.0f); var matrix = TestMatrices["Singular3x3"]; @@ -148,8 +150,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can left multiply with a complex. /// /// Complex32 real value. - [Test, Sequential] - public void CanOperatorLeftMultiplyWithComplex([Values(0, 1, 2.2f)] float real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanOperatorLeftMultiplyWithComplex(float real) { var value = new Complex32(real, 1.0f); var matrix = TestMatrices["Singular3x3"]; @@ -168,8 +172,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can right multiply with a Complex. /// /// Complex32 real value. - [Test, Sequential] - public void CanOperatorRightMultiplyWithComplex([Values(0, 1, 2.2f)] float real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanOperatorRightMultiplyWithComplex(float real) { var value = new Complex32(real, 1.0f); var matrix = TestMatrices["Singular3x3"]; @@ -188,8 +194,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can multiply with a Complex into result. /// /// Complex32 real value. - [Test] - public void CanMultiplyWithComplexIntoResult([Values(0, 1, 2.2f)] float real) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanMultiplyWithComplexIntoResult(float real) { var value = new Complex32(real, 1.0f); var matrix = TestMatrices["Singular3x3"]; @@ -263,8 +271,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -318,8 +327,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -383,8 +393,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -438,8 +449,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -503,8 +515,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public void CanMultiplyMatrixWithMatrix(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -526,8 +542,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can transpose and multiply a matrix with matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -605,8 +624,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can transpose and multiply a matrix with matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -663,8 +685,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public virtual void CanMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public virtual void CanMultiplyMatrixWithMatrixIntoResult(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -772,8 +798,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can multiply transposed matrix with another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -817,8 +846,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Multiply transpose of this matrix with another matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -841,8 +873,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can negate a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegate([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegate(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -862,8 +898,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can negate a matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegateIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegateIntoResult(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -965,8 +1005,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can normalize columns of a matrix. /// /// The norm under which to normalize the columns under. - [Test, Sequential] - public void CanNormalizeColumns([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeColumns(int p) { var matrix = TestMatrices["Square4x4"]; var result = matrix.NormalizeColumns(p); @@ -990,8 +1031,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can normalize rows of a matrix. /// /// The norm under which to normalize the rows under. - [Test, Sequential] - public void CanNormalizeRows([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeRows(int p) { var matrix = TestMatrices["Square4x4"].NormalizeRows(p); for (var i = 0; i < matrix.RowCount; i++) @@ -1166,8 +1208,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Create random matrix with non-positive number of rows throw ArgumentException. /// /// Number of rows. - [Test, Sequential] - public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException([Values(0, -2)] int numberOfRows) + [TestCase(0)] + [TestCase(-2)] + public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { var matrix = CreateMatrix(2, 3); Assert.Throws(() => matrix.Random(numberOfRows, 4, new ContinuousUniform())); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.cs index 0b8f820c..d628e6d2 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -34,15 +34,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Abstract class with the common set of matrix tests /// - [TestFixture] public abstract partial class MatrixTests : MatrixLoader { /// /// Can clone a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var clone = matrix.Clone(); @@ -63,8 +66,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can clone a matrix using ICloneable interface. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrixUsingICloneable([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrixUsingICloneable(string name) { var matrix = TestMatrices[name]; var clone = (Matrix)((ICloneable)matrix).Clone(); @@ -85,8 +92,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can copy a matrix to another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCopyTo([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCopyTo(string name) { var matrix = TestMatrices[name]; var copy = CreateMatrix(matrix.RowCount, matrix.ColumnCount); @@ -150,8 +161,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can equate matrices. /// /// Matrix name. - [Test, Sequential] - public void CanEquateMatrices([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanEquateMatrices(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -167,8 +182,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// The number of rows. /// The number of columns. - [Test, Sequential] - public void IfSizeIsNotPositiveThrowsArgumentException([Values(0, 2, 0, -1, 1)] int rows, [Values(2, 0, 0, 1, -1)] int columns) + [TestCase(0, 2)] + [TestCase(2, 0)] + [TestCase(0, 0)] + [TestCase(-1, 1)] + [TestCase(1, -1)] + public void IfSizeIsNotPositiveThrowsArgumentException(int rows, int columns) { Assert.Throws(() => CreateMatrix(rows, columns)); } @@ -177,8 +196,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Testing for equality with non-matrix returns false. /// /// Matrix name. - [Test, Sequential] - public void TestingForEqualityWithNonMatrixReturnsFalse([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void TestingForEqualityWithNonMatrixReturnsFalse(string name) { var matrix = CreateMatrix(TestData2D[name]); Assert.IsFalse(matrix.Equals(2)); @@ -188,8 +211,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can test for equality using Object.Equals. /// /// Matrix name. - [Test, Sequential] - public void CanTestForEqualityUsingObjectEquals([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTestForEqualityUsingObjectEquals(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -202,8 +229,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Row index. /// Column index. /// Matrix name. - [Test, Sequential] - public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException([Values(-1, 1, 4)] int i, [Values(1, -1, 2)] int j, [Values("Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(-1, 1, "Singular3x3")] + [TestCase(1, -1, "Singular3x3")] + [TestCase(4, 2, "Square3x3")] + public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException(int i, int j, string name) { Assert.Throws(() => { var x = TestMatrices[name][i, j]; }); } @@ -239,8 +268,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRow(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex); @@ -277,8 +308,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRowIntoResult([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRowIntoResult(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = CreateVector(matrix.ColumnCount); @@ -330,8 +363,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Column start. /// Row length. /// Matrix name. - [Test, Sequential] - public void CanGetRowWithRange([Values(0, 1, 2, 2)] int rowIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetRowWithRange(int rowIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex, start, length); @@ -370,8 +406,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumn(int colIndex, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex); @@ -408,8 +446,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumnIntoResult([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumnIntoResult(int colIndex, string name) { var matrix = TestMatrices[name]; var col = CreateVector(matrix.RowCount); @@ -461,8 +501,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Start index. /// Column length. /// Matrix name. - [Test, Sequential] - public void CanGetColumnWithRange([Values(0, 1, 2, 2)] int colIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetColumnWithRange(int colIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex, start, length); @@ -501,8 +544,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanSetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetRow(int rowIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetRow(rowIndex, CreateVector(matrix.ColumnCount)); @@ -521,8 +566,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanSetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetColumn(int colIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetColumn(colIndex, CreateVector(matrix.ColumnCount)); @@ -540,8 +587,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Get an upper triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangle(string name) { var data = TestMatrices[name]; var upper = data.UpperTriangle(); @@ -558,8 +609,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Get an upper triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -610,8 +665,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Get a lower triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangle(string name) { var data = TestMatrices[name]; var lower = data.LowerTriangle(); @@ -628,8 +687,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Get a lower triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -824,8 +887,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can transpose a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTransposeMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var transpose = matrix.Transpose(); @@ -846,8 +913,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can conjugate transpose a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanConjugateTransposeMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanConjugateTransposeMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var transpose = matrix.ConjugateTranspose(); @@ -869,8 +940,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix name. /// Column real values array. - [Test, Sequential] - public virtual void CanSetColumnWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 })] float[] real) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + public virtual void CanSetColumnWithArray(string name, float[] real) { var column = new Complex32[real.Length]; for (var i = 0; i < real.Length; i++) @@ -926,8 +1000,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix name. /// Column real values. - [Test, Sequential] - public virtual void CanSetColumnWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 })] float[] real) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + public virtual void CanSetColumnWithVector(string name, float[] real) { var column = new Complex32[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1046,8 +1123,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix name. /// Row index. - [Test, Sequential] - public virtual void CanSetRowWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2, 3 })] float[] real) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + [TestCase("Wide2x3", new float[] { 1, 2, 3 })] + public virtual void CanSetRowWithArray(string name, float[] real) { var row = new Complex32[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1093,8 +1173,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix name. /// Row real values. - [Test, Sequential] - public virtual void CanSetRowWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2, 3 })] float[] real) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + [TestCase("Wide2x3", new float[] { 1, 2, 3 })] + public virtual void CanSetRowWithVector(string name, float[] real) { var row = new Complex32[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1154,8 +1237,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void CanSetSubMatrix([Values(0, 1)] int rowStart, [Values(2, 1)] int rowLength, [Values(0, 1)] int colStart, [Values(2, 1)] int colLength) + [TestCase(0, 2, 0, 2)] + [TestCase(1, 1, 1, 1)] + public virtual void CanSetSubMatrix(int rowStart, int rowLength, int colStart, int colLength) { foreach (var matrix in TestMatrices.Values) { @@ -1183,8 +1267,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException([Values(0, 0, 4, 0, -1, 0)] int rowStart, [Values(4, 2, 2, 2, 2, 2)] int rowLength, [Values(0, 0, 0, 4, 0, -1)] int colStart, [Values(2, 4, 2, 2, 2, 2)] int colLength) + [TestCase(0, 4, 0, 2)] + [TestCase(0, 2, 0, 4)] + [TestCase(4, 2, 0, 2)] + [TestCase(0, 2, 4, 2)] + [TestCase(-1, 2, 0, 2)] + [TestCase(0, 2, -1, 2)] + public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0f; @@ -1201,8 +1290,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException([Values(0, 0)] int rowStart, [Values(-1, 2)] int rowLength, [Values(0, 0)] int colStart, [Values(2, -1)] int colLength) + [TestCase(0, -1, 0, 2)] + [TestCase(0, 2, 0, -1)] + public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0f; @@ -1227,8 +1317,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix name. /// Diagonal real values. - [Test, Sequential] - public void CanSetDiagonalVector([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2 })] float[] real) + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + public void CanSetDiagonalVector(string name, float[] real) { var diagonal = new Complex32[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1274,8 +1366,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Matrix name. /// Diagonal real values. - [Test, Sequential] - public void CanSetDiagonalArray([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2 })] float[] real) + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + public void CanSetDiagonalArray(string name, float[] real) { var diagonal = new Complex32[real.Length]; for (var i = 0; i < real.Length; i++) @@ -1443,8 +1537,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can permute matrix rows. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixRows([Values("Singular3x3", "Square3x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Tall3x2")] + public virtual void CanPermuteMatrixRows(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); @@ -1468,8 +1564,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can permute matrix columns. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixColumns([Values("Singular3x3", "Square3x3", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Wide2x3")] + public virtual void CanPermuteMatrixColumns(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs index b5ef738e..4d046f97 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -214,9 +214,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -237,7 +237,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Now compare the vectors for (var i = 0; i < y.Count; i++) { +#if !SILVERLIGHT Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary, 1), "#05-" + i); +#else + Assert.IsTrue((y[i] - z[i]).Magnitude.IsSmaller(ConvergenceBoundary * 10.0f, 1), "#05-" + i); +#endif } } @@ -245,8 +249,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomVector(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -255,8 +259,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new BiCgStab(monitor); @@ -288,8 +292,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomMatrix(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -298,7 +302,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new BiCgStab(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs index 2e24d371..2b32e55b 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new GpBiCg(monitor); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -247,8 +247,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomVector(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -257,8 +257,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new GpBiCg(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs index f595bab2..c82dd1d6 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -246,8 +246,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomVector(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -256,8 +256,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new MlkBiCgStab(monitor); @@ -289,8 +289,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomMatrix(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new MlkBiCgStab(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs index 0a64ffe4..8fd1850e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -246,8 +246,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomVector(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -256,8 +256,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new TFQMR(monitor); @@ -289,8 +289,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4)] int order) + [TestCase(4)] + public void CanSolveForRandomMatrix(int order) { for (var iteration = 5; iteration > 3; iteration--) { @@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new TFQMR(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs index 77cd528c..72db8743 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/IteratorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { Assert.Throws(() => new Iterator(new IIterationStopCriterium[] { - new FailureStopCriterium(), + new FailureStopCriterium(), new FailureStopCriterium() })); } @@ -93,9 +93,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -142,9 +142,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(); @@ -174,9 +174,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -193,9 +193,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), }; var iterator = new Iterator(criteria); Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); @@ -212,9 +212,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -235,9 +235,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var iterator = new Iterator(); Assert.Throws(() => iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 5), + 0, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -249,17 +249,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -271,17 +271,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -293,17 +293,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 5), - null, + 1, + new DenseVector(3, 5), + null, new DenseVector(3, 6))); } @@ -315,17 +315,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -337,8 +337,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -346,17 +346,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); // Second step, should run out of iterations. iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationStoppedWithoutConvergence), iterator.Status, "Incorrect status"); } @@ -369,8 +369,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -378,9 +378,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); @@ -399,9 +399,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs index 91f9aff9..cd41396f 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs @@ -75,11 +75,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon { var type = ilutp.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilutp, null); return (T)obj; @@ -139,8 +139,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon { var result = new Ilutp { - DropTolerance = _dropTolerance, - FillLevel = _fillLevel, + DropTolerance = _dropTolerance, + FillLevel = _fillLevel, PivotTolerance = _pivotTolerance }; return result; @@ -241,8 +241,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 0.0, - DropTolerance = 0, + PivotTolerance = 0.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -297,8 +297,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -334,8 +334,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon var vector = CreateStandardBcVector(Size); var preconditioner = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; preconditioner.Initialize(newMatrix); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs index fa1e88c2..39a283cd 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs @@ -49,11 +49,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon { var type = ilu.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilu, null); return (T)obj; diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index c19d8fff..4c899a4e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs @@ -107,9 +107,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -121,9 +121,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -142,9 +142,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr for (var i = 0; i < Iterations - 1; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + i, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32((i + 1) * (Increase + 0.1f), 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); } @@ -165,9 +165,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr for (var i = 0; i < Iterations * 2; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + i, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32((i + 1) * (Increase - 0.01f), 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -189,9 +189,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr for (var i = 0; i < Iterations - 5; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + i, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32((i + 1) * (Increase - 0.01f), 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -199,9 +199,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr // Now make it fail by throwing in a NaN criterium.DetermineStatus( - Iterations, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + Iterations, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32(float.NaN, 0) })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -224,9 +224,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr { previous *= 1 + Increase + 0.01f; criterium.DetermineStatus( - i, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + i, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32(previous, 0) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -235,9 +235,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr // Add the final residual. Now we should have divergence previous *= 1 + Increase + 0.01f; criterium.DetermineStatus( - Iterations - 1, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + Iterations - 1, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32(previous, 0) })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -256,9 +256,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr // Add residuals. Blow it up instantly criterium.DetermineStatus( - 1, - new DenseVector(new[] { new Complex32(1.0f, 0) }), - new DenseVector(new[] { new Complex32(1.0f, 0) }), + 1, + new DenseVector(new[] { new Complex32(1.0f, 0) }), + new DenseVector(new[] { new Complex32(1.0f, 0) }), new DenseVector(new[] { new Complex32(float.NaN, 0) })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index 10429b61..eba403b7 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/Solvers/StopCriterium/ResidualStopCriteriumTest.cs @@ -106,9 +106,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -122,9 +122,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -138,9 +138,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - null, + 1, + new DenseVector(3, 4), + null, new DenseVector(3, 6))); } @@ -154,9 +154,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -170,9 +170,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(4, 4), - new DenseVector(3, 4), + 1, + new DenseVector(4, 4), + new DenseVector(3, 4), new DenseVector(3, 4))); } @@ -186,9 +186,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(4, 4), + 1, + new DenseVector(3, 4), + new DenseVector(4, 4), new DenseVector(3, 4))); } @@ -202,9 +202,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(4, 4))); } @@ -326,6 +326,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.StopCr // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.Maximum, clonedCriterium.Maximum, "Clone failed"); Assert.AreEqual(criterium.MinimumIterationsBelowMaximum, clonedCriterium.MinimumIterationsBelowMaximum, "Clone failed"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs index c1dbf407..89e40bfd 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { var testData = new Dictionary { - { "Singular3x3", new SparseMatrix(3, 3, new[] { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1) }) }, - { "Square3x3", new SparseMatrix(3, 3, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.6f, 1) }) }, - { "Square4x4", new SparseMatrix(4, 4, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(1.0f, 1), new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(2.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.2f, 1), new Complex32(6.6f, 1), new Complex32(-4.4f, 1), new Complex32(3.3f, 1), new Complex32(4.3f, 1), new Complex32(-7.7f, 1) }) }, - { "Tall3x2", new SparseMatrix(3, 2, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1) }) }, + { "Singular3x3", new SparseMatrix(3, 3, new[] { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1) }) }, + { "Square3x3", new SparseMatrix(3, 3, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.6f, 1) }) }, + { "Square4x4", new SparseMatrix(4, 4, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(1.0f, 1), new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(2.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.2f, 1), new Complex32(6.6f, 1), new Complex32(-4.4f, 1), new Complex32(3.3f, 1), new Complex32(4.3f, 1), new Complex32(-7.7f, 1) }) }, + { "Tall3x2", new SparseMatrix(3, 2, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1) }) }, { "Wide2x3", new SparseMatrix(2, 3, new[] { new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1) }) } }; @@ -128,8 +128,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new SparseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -177,8 +182,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => SparseMatrix.Identity(order)); } @@ -304,10 +310,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [Test] public void CanCreateLargeMatrix() { - const int order = 1000000; - var matrix = new SparseMatrix(order); - Assert.AreEqual(order, matrix.RowCount); - Assert.AreEqual(order, matrix.ColumnCount); + const int Order = 1000000; + var matrix = new SparseMatrix(Order); + Assert.AreEqual(Order, matrix.RowCount); + Assert.AreEqual(Order, matrix.ColumnCount); Assert.DoesNotThrow(() => matrix[0, 0] = 1); } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs index acaac99e..1215e791 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseComplex32SparseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1.1 , 2.1 , 3.1 ] ", " [ -1.1 , 2.1 , +3.1 ] ", " [1.2,3.4 , 5.6] ", "[1+1i,2+1i,3+1i]", " [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", " [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", " [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ")] string stringToParse, [Values("(2, 0)", "(3, 0)", "(1, 0),(2, 0),(3, 0)", "(1.1, 0),(2.1, 0),(3.1, 0)", "(-1.1, 0),(2.1, 0),(3.1, 0)", "(1.2, 0),(3.4, 0),(5.6, 0)", "(1, 1),(2, 1),(3, 1)", "(1.1, 1),(2.1, 1),(3.1, 1)", "(-1.1, 1),(2.1, -1),(3.1, 1)", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] string expectedToString) + [TestCase("2", "(2, 0)")] + [TestCase("(3)", "(3, 0)")] + [TestCase("[1,2,3]", "(1, 0),(2, 0),(3, 0)")] + [TestCase(" [ 1.1 , 2.1 , 3.1 ] ", "(1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [ -1.1 , 2.1 , +3.1 ] ", "(-1.1, 0),(2.1, 0),(3.1, 0)")] + [TestCase(" [1.2,3.4 , 5.6] ", "(1.2, 0),(3.4, 0),(5.6, 0)")] + [TestCase("[1+1i,2+1i,3+1i]", "(1, 1),(2, 1),(3, 1)")] + [TestCase(" [ 1.1 + 1i , 2.1+1i , 3.1+1i ] ", "(1.1, 1),(2.1, 1),(3.1, 1)")] + [TestCase(" [ -1.1 + 1i , 2.1-1i , +3.1+1i ] ", "(-1.1, 1),(2.1, -1),(3.1, 1)")] + [TestCase(" [1.2+2.3i ,3.4+4.5i , 5.6+ 6.7i] ", "(1.2, 2.3),(3.4, 4.5),(5.6, 6.7)")] + public void CanParseComplex32SparseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = SparseVector.Parse(stringToParse, formatProvider); @@ -56,10 +65,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseComplex32SparseVectorsWithCulture([Values(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", " 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", " 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ")] string stringToParse, [Values("(1.2, 1),(3.4, 1),(5.6, 1)", "(1.2, 1);(3.4, 1);(5.6, 1)", "(1,2, 1);(3,4, 1);(5,6, 1)")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2 + 1i , 3.4 + 1i , 5.6 + 1i ", "(1.2, 1),(3.4, 1),(5.6, 1)", "en-US")] + [TestCase(" 1.2 + 1i ; 3.4 + 1i ; 5.6 + 1i ", "(1.2, 1);(3.4, 1);(5.6, 1)", "de-CH")] +#if !SILVERLIGHT + [TestCase(" 1,2 + 1i ; 3,4 + 1i ; 5,6 + 1i ", "(1,2, 1);(3,4, 1);(5,6, 1)", "de-DE")] +#endif + public void CanParseComplex32SparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = SparseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -79,8 +92,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { SparseVector vector; var ret = SparseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs index 9ab10aee..537ad2cb 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs index d741eb3d..e523b123 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrixTests.cs index f788ea63..b7315542 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVector.cs b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVector.cs index c1c60e72..9b2fb9f3 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVector.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVector.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVectorTests.cs index 61fb74e0..87b388df 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs index a7072043..7562f85c 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Norm.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Norm.cs index 1b1320d3..a20c2654 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Norm.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Norm.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -70,8 +70,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// The norm index. /// The expected P-norm value. - [Test, Sequential] - public void CanComputeNormP([Values(1, 2, 3, 10)] int p, [Values(16.0346843392517f, 7.74596669241483f, 6.28528392332871f, 5.1608912235454f)] float expected) + [TestCase(1, 16.0346843392517f)] + [TestCase(2, 7.74596669241483f)] + [TestCase(3, 6.28528392332871f)] + [TestCase(10, 5.1608912235454f)] + public void CanComputeNormP(int p, float expected) { var vector = CreateVector(Data); AssertHelpers.AlmostEqual(expected, vector.Norm(p).Real, 5); diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs index 964af4bc..4431bea4 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,7 +39,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Abstract class with the common set of vector tests. /// - [TestFixture] public abstract partial class VectorTests { /// @@ -61,6 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 CollectionAssert.AreEqual(vector, clone); } +#if !SILVERLIGHT /// /// Can clone a vector using IClonable interface method. /// @@ -74,6 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.AreEqual(vector.Count, clone.Count); CollectionAssert.AreEqual(vector, clone); } +#endif /// /// Can convert vector to string. @@ -307,8 +308,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Sequential] - public void CanGetSubVector([Values(0, 2, 1)] int index, [Values(5, 2, 4)] int length) + [TestCase(0, 5)] + [TestCase(2, 2)] + [TestCase(1, 4)] + public void CanGetSubVector(int index, int length) { var vector = CreateVector(Data); var sub = vector.SubVector(index, length); @@ -324,8 +327,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Combinatorial] - public void CanGetSubVectorWithWrongValuesShouldThrowException([Values(6, 1)] int index, [Values(10, -10)] int length) + [TestCase(6, 10)] + [TestCase(1, -10)] + public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); Assert.Throws(() => vector.SubVector(index, length)); diff --git a/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs index 141284c8..8b4acf3f 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -86,10 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var testData = new Dictionary { - { "Singular3x3", new DenseMatrix(3, 3, new[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }) }, - { "Square3x3", new DenseMatrix(3, 3, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5, -3.3, 2.2, 6.6 }) }, - { "Square4x4", new DenseMatrix(4, 4, new[] { -1.1, 0.0, 1.0, -4.4, -2.2, 1.1, 2.1, 5.5, -3.3, 2.2, 6.2, 6.6, -4.4, 3.3, 4.3, -7.7 }) }, - { "Tall3x2", new DenseMatrix(3, 2, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5 }) }, + { "Singular3x3", new DenseMatrix(3, 3, new[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }) }, + { "Square3x3", new DenseMatrix(3, 3, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5, -3.3, 2.2, 6.6 }) }, + { "Square4x4", new DenseMatrix(4, 4, new[] { -1.1, 0.0, 1.0, -4.4, -2.2, 1.1, 2.1, 5.5, -3.3, 2.2, 6.2, 6.6, -4.4, 3.3, 4.3, -7.7 }) }, + { "Tall3x2", new DenseMatrix(3, 2, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5 }) }, { "Wide2x3", new DenseMatrix(2, 3, new[] { -1.1, 0.0, -2.2, 1.1, -3.3, 2.2 }) } }; @@ -126,8 +126,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DenseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -175,8 +180,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DenseMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs index 0edb308c..1dba194e 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseDoubleDenseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1 , 2 , 3 ] ", " [ -1 , 2 , +3 ] ", " [1.2,3.4 , 5.6] ")] string stringToParse, [Values("2", "3", "1,2,3", "1,2,3", "-1,2,3", "1.2,3.4,5.6")] string expectedToString) + [TestCase("2", "2")] + [TestCase("(3)", "3")] + [TestCase("[1,2,3]", "1,2,3")] + [TestCase(" [ 1 , 2 , 3 ] ", "1,2,3")] + [TestCase(" [ -1 , 2 , +3 ] ", "-1,2,3")] + [TestCase(" [1.2,3.4 , 5.6] ", "1.2,3.4,5.6")] + public void CanParseDoubleDenseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = DenseVector.Parse(stringToParse, formatProvider); @@ -57,10 +62,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseDoubleDenseVectorsWithCulture([Values(" 1.2,3.4 , 5.6 ", " 1.2;3.4 ; 5.6 ", " 1,2;3,4 ; 5,6 ")] string stringToParse, [Values("1.2,3.4,5.6", "1.2;3.4;5.6", "1,2;3,4;5,6")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2,3.4 , 5.6 ", "1.2,3.4,5.6", "en-US")] + [TestCase(" 1.2;3.4 ; 5.6 ", "1.2;3.4;5.6", "de-CH")] + [TestCase(" 1,2;3,4 ; 5,6 ", "1,2;3,4;5,6", "de-DE")] + public void CanParseDoubleDenseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = DenseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -70,12 +77,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can parse double dense vectors. /// /// Vector as string. - [Test] - public void CanParseDoubleDenseVectors([Values("15", "1{0}2{1}3{0}4{1}5{0}6")] string vectorAsString) + [TestCase("15")] + [TestCase("1{0}2{1}3{0}4{1}5{0}6")] + public void CanParseDoubleDenseVectors(string vectorAsString) { var mappedString = String.Format( - vectorAsString, - CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, + vectorAsString, + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, CultureInfo.CurrentCulture.TextInfo.ListSeparator); var vector = DenseVector.Parse(mappedString); @@ -101,10 +109,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var data = new[] { 1.2, 3.4, 5.6e-78 }; var text = String.Format( - "{1}{0}{2}{0}{3}", - CultureInfo.CurrentCulture.TextInfo.ListSeparator, - data[0], - data[1], + "{1}{0}{2}{0}{3}", + CultureInfo.CurrentCulture.TextInfo.ListSeparator, + data[0], + data[1], data[2]); DenseVector vector; @@ -121,8 +129,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { DenseVector vector; var ret = DenseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs index cadfbc19..6fd95661 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs index af838fb6..d14d2951 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -33,6 +33,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double using LinearAlgebra.Generic; using NUnit.Framework; +#if SILVERLIGHT + using Threading; +#endif + /// /// Diagonal matrix tests. /// @@ -46,11 +50,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { 1.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 3.0 } } }, - { "Square3x3", new[,] { { -1.1, 0.0, 0.0 }, { 0.0, 1.1, 0.0 }, { 0.0, 0.0, 6.6 } } }, - { "Square4x4", new[,] { { -1.1, 0.0, 0.0, 0.0 }, { 0.0, 1.1, 0.0, 0.0 }, { 0.0, 0.0, 6.2, 0.0 }, { 0.0, 0.0, 0.0, -7.7 } } }, - { "Singular4x4", new[,] { { -1.1, 0.0, 0.0, 0.0 }, { 0.0, -2.2, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, -4.4 } } }, - { "Tall3x2", new[,] { { -1.1, 0.0 }, { 0.0, 1.1 }, { 0.0, 0.0 } } }, + { "Singular3x3", new[,] { { 1.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 3.0 } } }, + { "Square3x3", new[,] { { -1.1, 0.0, 0.0 }, { 0.0, 1.1, 0.0 }, { 0.0, 0.0, 6.6 } } }, + { "Square4x4", new[,] { { -1.1, 0.0, 0.0, 0.0 }, { 0.0, 1.1, 0.0, 0.0 }, { 0.0, 0.0, 6.2, 0.0 }, { 0.0, 0.0, 0.0, -7.7 } } }, + { "Singular4x4", new[,] { { -1.1, 0.0, 0.0, 0.0 }, { 0.0, -2.2, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, -4.4 } } }, + { "Tall3x2", new[,] { { -1.1, 0.0 }, { 0.0, 1.1 }, { 0.0, 0.0 } } }, { "Wide2x3", new[,] { { -1.1, 0.0, 0.0 }, { 0.0, 1.1, 0.0 } } } }; @@ -111,11 +115,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var testData = new Dictionary> { - { "Singular3x3", new DiagonalMatrix(3, 3, new[] { 1.0, 0.0, 3.0 }) }, - { "Square3x3", new DiagonalMatrix(4, 4, new[] { -1.1, 1.1, 6.6 }) }, - { "Square4x4", new DiagonalMatrix(4, 4, new[] { -1.1, 1.1, 6.2, -7.7 }) }, - { "Tall3x2", new DiagonalMatrix(3, 2, new[] { -1.1, 1.1 }) }, - { "Wide2x3", new DiagonalMatrix(2, 3, new[] { -1.1, 1.1 }) }, + { "Singular3x3", new DiagonalMatrix(3, 3, new[] { 1.0, 0.0, 3.0 }) }, + { "Square3x3", new DiagonalMatrix(4, 4, new[] { -1.1, 1.1, 6.6 }) }, + { "Square4x4", new DiagonalMatrix(4, 4, new[] { -1.1, 1.1, 6.2, -7.7 }) }, + { "Tall3x2", new DiagonalMatrix(3, 2, new[] { -1.1, 1.1 }) }, + { "Wide2x3", new DiagonalMatrix(2, 3, new[] { -1.1, 1.1 }) }, }; foreach (var name in testData.Keys) @@ -140,8 +144,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DiagonalMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -186,8 +195,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DiagonalMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs index 10cca1f9..dfc2c0dd 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/CholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,8 +39,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -82,8 +84,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -95,8 +99,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var chol = matrixX.Cholesky(); @@ -130,8 +139,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -164,8 +178,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(row); var matrixACopy = matrixA.Clone(); @@ -201,8 +220,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -243,8 +267,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/EvdTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/EvdTests.cs index 53191ffe..72f56c81 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/EvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/EvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -76,8 +78,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -107,8 +114,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a symmetric random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var factorEvd = matrixA.Evd(); @@ -137,8 +149,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -150,8 +164,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -174,8 +190,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs index 8a56fa64..657cc48d 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/GramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -59,8 +59,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -105,8 +107,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -118,8 +122,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -161,8 +170,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -195,8 +209,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -236,8 +255,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -277,8 +301,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs index 25dbce37..2a9e7085 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/LUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -85,8 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var lu = matrixI.LU(); @@ -97,8 +101,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorLU = matrixX.LU(); @@ -147,8 +156,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -181,8 +195,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -222,8 +241,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -263,8 +287,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -316,8 +345,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs index dbed8f2a..e8edb44b 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/QRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -59,8 +59,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -89,8 +91,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -102,8 +106,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorQR = matrixA.QR(); @@ -145,8 +154,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -179,8 +193,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -220,8 +239,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -261,8 +285,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs index 19f7323d..cc223645 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/SvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -82,8 +84,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -119,8 +126,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -133,8 +142,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -153,8 +167,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -204,8 +220,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -239,8 +260,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -281,8 +307,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -321,8 +352,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs index 0955023a..d3810f3b 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserCholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,8 +39,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -82,8 +84,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -95,8 +99,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var chol = matrixX.Cholesky(); @@ -130,8 +139,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -164,8 +178,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); @@ -201,8 +220,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -243,8 +267,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserEvdTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserEvdTests.cs index 1163456f..1140d3f9 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserEvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserEvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -75,8 +77,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -106,8 +113,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a symmetric random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var factorEvd = matrixA.Evd(); @@ -136,8 +148,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -149,8 +163,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -173,8 +189,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -185,8 +203,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -219,8 +242,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -260,8 +288,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorAndSymmetricMatrixWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorAndSymmetricMatrixWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -299,8 +332,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B) into result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs index 3f129792..29c83214 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserGramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -57,8 +57,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -103,8 +105,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -116,8 +120,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -159,8 +168,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -193,8 +207,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -234,8 +253,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -275,8 +299,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs index f7b91721..c454a42c 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserLUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,8 +39,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -84,8 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var lu = matrixI.LU(); @@ -96,8 +100,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorLU = matrixX.LU(); @@ -146,8 +155,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -180,8 +194,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -221,8 +240,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -262,8 +286,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -315,8 +344,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs index 9ba564d6..a3404a92 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserQRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -58,8 +58,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -88,8 +90,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -101,8 +105,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorQR = matrixA.QR(); @@ -144,8 +153,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -178,8 +192,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -219,8 +238,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -260,8 +284,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs index b8485277..4cbdc443 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Factorization/UserSvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -49,8 +49,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -81,8 +83,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -118,8 +125,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -132,8 +141,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -152,8 +166,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -203,8 +219,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -238,8 +259,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -280,8 +306,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -320,8 +351,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedReaderTests.cs index 3fe29e4a..6092b222 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -53,7 +53,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.IO var reader = new DelimitedReader(',') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = CultureInfo.InvariantCulture }; @@ -142,7 +142,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.IO var reader = new DelimitedReader('.') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = new CultureInfo("tr-TR") }; var matrix = reader.ReadMatrix(new MemoryStream(Encoding.UTF8.GetBytes(data))); diff --git a/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs index 0e1881b4..0bc905c4 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/IO/DelimitedWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabReaderTests.cs index f55c4476..265ce3d9 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabWriterTests.cs index 157823fc..608d6ef1 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/IO/MatlabWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs index 542888f8..5d54d54b 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -94,12 +94,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } } }, - { "Square3x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } } }, - { "Square4x4", new[,] { { -1.1, -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } } }, - { "Singular4x4", new[,] { { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } } }, - { "Tall3x2", new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } } }, - { "Wide2x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } } }, + { "Singular3x3", new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } } }, + { "Square3x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } } }, + { "Square4x4", new[,] { { -1.1, -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } } }, + { "Singular4x4", new[,] { { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } } }, + { "Tall3x2", new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } } }, + { "Wide2x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } } }, { "Symmetric3x3", new[,] { { 1.0, 2.0, 3.0 }, { 2.0, 2.0, 0.0 }, { 3.0, 0.0, 3.0 } } } }; diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs index ce74c16a..a2bedd61 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can multiply with a scalar. /// /// Scalar value. - [Test] - public void CanMultiplyWithScalar([Values(0, 1, 2.2)] double scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanMultiplyWithScalar(double scalar) { var matrix = TestMatrices["Singular3x3"]; var clone = matrix.Clone(); @@ -146,8 +148,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can left multiply with a scalar. /// /// Scalar value. - [Test, Sequential] - public void CanOperatorLeftMultiplyWithScalar([Values(0, 1, 2.2)] double scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanOperatorLeftMultiplyWithScalar(double scalar) { var matrix = TestMatrices["Singular3x3"]; var clone = scalar * matrix; @@ -165,8 +169,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can right multiply with a scalar. /// /// Scalar value. - [Test, Sequential] - public void CanOperatorRightMultiplyWithScalar([Values(0, 1, 2.2)] double scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanOperatorRightMultiplyWithScalar(double scalar) { var matrix = TestMatrices["Singular3x3"]; var clone = matrix * scalar; @@ -184,8 +190,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can multiply with a scalar into result. /// /// Scalar value. - [Test] - public void CanMultiplyWithScalarIntoResult([Values(0, 1, 2.2)] double scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2)] + public void CanMultiplyWithScalarIntoResult(double scalar) { var matrix = TestMatrices["Singular3x3"]; var result = matrix.Clone(); @@ -258,8 +266,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -313,8 +322,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -378,8 +388,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -433,8 +444,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -498,8 +510,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public void CanMultiplyMatrixWithMatrix(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -521,8 +537,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can transpose and multiply a matrix with matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -600,8 +619,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can transpose and multiply a matrix with matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -658,8 +680,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public virtual void CanMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public virtual void CanMultiplyMatrixWithMatrixIntoResult(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -767,8 +793,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can multiply transposed matrix with another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -812,8 +841,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Multiply transpose of this matrix with another matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -836,8 +868,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can negate a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegate([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegate(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -857,8 +893,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can negate a matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegateIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegateIntoResult(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -960,8 +1000,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can normalize columns of a matrix. /// /// The norm under which to normalize the columns under. - [Test, Sequential] - public void CanNormalizeColumns([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeColumns(int p) { var matrix = TestMatrices["Square4x4"]; var result = matrix.NormalizeColumns(p); @@ -985,8 +1026,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can normalize rows of a matrix. /// /// The norm under which to normalize the rows under. - [Test, Sequential] - public void CanNormalizeRows([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeRows(int p) { var matrix = TestMatrices["Square4x4"].NormalizeRows(p); for (var i = 0; i < matrix.RowCount; i++) @@ -1161,8 +1203,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Create random matrix with non-positive number of rows throw ArgumentException. /// /// Number of rows. - [Test, Sequential] - public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException([Values(0, -2)] int numberOfRows) + [TestCase(0)] + [TestCase(-2)] + public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { var matrix = CreateMatrix(2, 3); Assert.Throws(() => matrix.Random(numberOfRows, 4, new ContinuousUniform())); diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.cs index aa6b53a8..a006eb41 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -33,15 +33,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Abstract class with the common set of matrix tests /// - [TestFixture] public abstract partial class MatrixTests : MatrixLoader { /// /// Can clone a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var clone = matrix.Clone(); @@ -62,8 +65,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can clone a matrix using ICloneable interface. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrixUsingICloneable([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrixUsingICloneable(string name) { var matrix = TestMatrices[name]; var clone = (Matrix)((ICloneable)matrix).Clone(); @@ -84,8 +91,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can copy a matrix to another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCopyTo([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCopyTo(string name) { var matrix = TestMatrices[name]; var copy = CreateMatrix(matrix.RowCount, matrix.ColumnCount); @@ -149,8 +160,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can equate matrices. /// /// Matrix name. - [Test, Sequential] - public void CanEquateMatrices([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanEquateMatrices(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -166,8 +181,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// The number of rows. /// The number of columns. - [Test, Sequential] - public void IfSizeIsNotPositiveThrowsArgumentException([Values(0, 2, 0, -1, 1)] int rows, [Values(2, 0, 0, 1, -1)] int columns) + [TestCase(0, 2)] + [TestCase(2, 0)] + [TestCase(0, 0)] + [TestCase(-1, 1)] + [TestCase(1, -1)] + public void IfSizeIsNotPositiveThrowsArgumentException(int rows, int columns) { Assert.Throws(() => CreateMatrix(rows, columns)); } @@ -176,8 +195,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Testing for equality with non-matrix returns false. /// /// Matrix name. - [Test, Sequential] - public void TestingForEqualityWithNonMatrixReturnsFalse([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void TestingForEqualityWithNonMatrixReturnsFalse(string name) { var matrix = CreateMatrix(TestData2D[name]); Assert.IsFalse(matrix.Equals(2)); @@ -187,8 +210,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can test for equality using Object.Equals. /// /// Matrix name. - [Test, Sequential] - public void CanTestForEqualityUsingObjectEquals([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTestForEqualityUsingObjectEquals(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -201,8 +228,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Row index. /// Column index. /// Matrix name. - [Test, Sequential] - public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException([Values(-1, 1, 4)] int i, [Values(1, -1, 2)] int j, [Values("Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(-1, 1, "Singular3x3")] + [TestCase(1, -1, "Singular3x3")] + [TestCase(4, 2, "Square3x3")] + public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException(int i, int j, string name) { Assert.Throws(() => { var x = TestMatrices[name][i, j]; }); } @@ -238,8 +267,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRow(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex); @@ -276,8 +307,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRowIntoResult([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRowIntoResult(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = CreateVector(matrix.ColumnCount); @@ -329,8 +362,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Column start. /// Row length. /// Matrix name. - [Test, Sequential] - public void CanGetRowWithRange([Values(0, 1, 2, 2)] int rowIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetRowWithRange(int rowIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex, start, length); @@ -369,8 +405,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumn(int colIndex, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex); @@ -407,8 +445,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumnIntoResult([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumnIntoResult(int colIndex, string name) { var matrix = TestMatrices[name]; var col = CreateVector(matrix.RowCount); @@ -460,8 +500,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Start index. /// Column length. /// Matrix name. - [Test, Sequential] - public void CanGetColumnWithRange([Values(0, 1, 2, 2)] int colIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetColumnWithRange(int colIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex, start, length); @@ -500,8 +543,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanSetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetRow(int rowIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetRow(rowIndex, CreateVector(matrix.ColumnCount)); @@ -520,8 +565,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanSetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetColumn(int colIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetColumn(colIndex, CreateVector(matrix.ColumnCount)); @@ -539,8 +586,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Get an upper triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangle(string name) { var data = TestMatrices[name]; var upper = data.UpperTriangle(); @@ -557,8 +608,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Get an upper triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -609,8 +664,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Get a lower triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangle(string name) { var data = TestMatrices[name]; var lower = data.LowerTriangle(); @@ -627,8 +686,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Get a lower triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -823,8 +886,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can transpose a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTransposeMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var transpose = matrix.Transpose(); @@ -846,8 +913,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix name. /// Column array. - [Test, Sequential] - public virtual void CanSetColumnWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 })] double[] column) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + public virtual void CanSetColumnWithArray(string name, double[] column) { var matrix = TestMatrices[name]; for (var i = 0; i < matrix.ColumnCount; i++) @@ -897,8 +967,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix name. /// Column values. - [Test, Sequential] - public virtual void CanSetColumnWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 })] double[] column) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + public virtual void CanSetColumnWithVector(string name, double[] column) { var matrix = TestMatrices[name]; var columnVector = CreateVector(column); @@ -1011,8 +1084,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix name. /// Row index. - [Test, Sequential] - public virtual void CanSetRowWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2, 3 })] double[] row) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + [TestCase("Wide2x3", new double[] { 1, 2, 3 })] + public virtual void CanSetRowWithArray(string name, double[] row) { var matrix = TestMatrices[name]; for (var i = 0; i < matrix.RowCount; i++) @@ -1052,8 +1128,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix name. /// Row index. - [Test, Sequential] - public virtual void CanSetRowWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2, 3 })] double[] row) + [TestCase("Singular3x3", new double[] { 1, 2, 3 })] + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + [TestCase("Wide2x3", new double[] { 1, 2, 3 })] + public virtual void CanSetRowWithVector(string name, double[] row) { var matrix = TestMatrices[name]; var rowVector = CreateVector(row); @@ -1107,8 +1186,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void CanSetSubMatrix([Values(0, 1)] int rowStart, [Values(2, 1)] int rowLength, [Values(0, 1)] int colStart, [Values(2, 1)] int colLength) + [TestCase(0, 2, 0, 2)] + [TestCase(1, 1, 1, 1)] + public virtual void CanSetSubMatrix(int rowStart, int rowLength, int colStart, int colLength) { foreach (var matrix in TestMatrices.Values) { @@ -1136,8 +1216,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException([Values(0, 0, 4, 0, -1, 0)] int rowStart, [Values(4, 2, 2, 2, 2, 2)] int rowLength, [Values(0, 0, 0, 4, 0, -1)] int colStart, [Values(2, 4, 2, 2, 2, 2)] int colLength) + [TestCase(0, 4, 0, 2)] + [TestCase(0, 2, 0, 4)] + [TestCase(4, 2, 0, 2)] + [TestCase(0, 2, 4, 2)] + [TestCase(-1, 2, 0, 2)] + [TestCase(0, 2, -1, 2)] + public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0; @@ -1154,8 +1239,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException([Values(0, 0)] int rowStart, [Values(-1, 2)] int rowLength, [Values(0, 0)] int colStart, [Values(2, -1)] int colLength) + [TestCase(0, -1, 0, 2)] + [TestCase(0, 2, 0, -1)] + public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0; @@ -1180,8 +1266,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix name. /// Diagonal vector. - [Test, Sequential] - public void CanSetDiagonalVector([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2 })] double[] diagonal) + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + public void CanSetDiagonalVector(string name, double[] diagonal) { var matrix = TestMatrices[name]; var vector = CreateVector(diagonal); @@ -1221,8 +1309,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Matrix name. /// Diagonal array. - [Test, Sequential] - public void CanSetDiagonalArray([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new double[] { 1, 2, 3 }, new double[] { 1, 2 }, new double[] { 1, 2 })] double[] diagonal) + [TestCase("Square3x3", new double[] { 1, 2, 3 })] + [TestCase("Wide2x3", new double[] { 1, 2 })] + [TestCase("Tall3x2", new double[] { 1, 2 })] + public void CanSetDiagonalArray(string name, double[] diagonal) { var matrix = TestMatrices[name]; matrix.SetDiagonal(diagonal); @@ -1384,8 +1474,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can permute matrix rows. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixRows([Values("Singular3x3", "Square3x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Tall3x2")] + public virtual void CanPermuteMatrixRows(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); @@ -1409,8 +1501,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can permute matrix columns. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixColumns([Values("Singular3x3", "Square3x3", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Wide2x3")] + public virtual void CanPermuteMatrixColumns(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); @@ -1801,7 +1895,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var matrix = TestMatrices["Symmetric3x3"]; Assert.IsTrue(matrix.IsSymmetric); - + matrix = TestMatrices["Square3x3"]; Assert.IsFalse(matrix.IsSymmetric); } diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs index e2f1add2..7239dabf 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -214,9 +214,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -237,7 +237,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Now compare the vectors for (var i = 0; i < y.Count; i++) { +#if !SILVERLIGHT Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i); +#else + Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i); +#endif } } @@ -245,16 +249,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new BiCgStab(monitor); @@ -274,15 +280,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium(1e-10) }); var solver = new BiCgStab(monitor); @@ -295,6 +303,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative Assert.AreEqual(matrixB.ColumnCount, matrixX.ColumnCount); var matrixBReconstruct = matrixA * matrixX; + // Check the reconstruction. for (var i = 0; i < matrixB.RowCount; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs index 454a584d..df8c0208 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new GpBiCg(monitor); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -239,7 +239,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Now compare the vectors for (var i = 0; i < y.Count; i++) { +#if !SILVERLIGHT Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i); +#else + Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i); +#endif } } @@ -247,16 +251,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new GpBiCg(monitor); @@ -276,15 +282,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium(1e-10) }); var solver = new GpBiCg(monitor); @@ -297,6 +305,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative Assert.AreEqual(matrixB.ColumnCount, matrixX.ColumnCount); var matrixBReconstruct = matrixA * matrixX; + // Check the reconstruction. for (var i = 0; i < matrixB.RowCount; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs index adc882ce..6939715a 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -238,7 +238,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Now compare the vectors for (var i = 0; i < y.Count; i++) { +#if !SILVERLIGHT Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary, 1), "#05-" + i); +#else + Assert.IsTrue(Math.Abs(y[i] - z[i]).IsSmaller(ConvergenceBoundary * 100.0, 1), "#05-" + i); +#endif } } @@ -246,16 +250,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new MlkBiCgStab(monitor); @@ -275,15 +281,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium(1e-10) }); var solver = new MlkBiCgStab(monitor); @@ -296,7 +304,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative Assert.AreEqual(matrixB.ColumnCount, matrixX.ColumnCount); var matrixBReconstruct = matrixA * matrixX; - + // Check the reconstruction. for (var i = 0; i < matrixB.RowCount; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs index 0bae2805..ae20fcc4 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs @@ -91,9 +91,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -215,9 +215,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -246,16 +246,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var vectorb = MatrixLoader.GenerateRandomDenseVector(order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), - new ResidualStopCriterium(1e-10), + new IterationCountStopCriterium(1000), + new ResidualStopCriterium(1e-10), }); var solver = new TFQMR(monitor); @@ -275,15 +277,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(4, 8, 10)] int order) + [TestCase(4)] + [TestCase(8)] + [TestCase(10)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixB = MatrixLoader.GenerateRandomDenseMatrix(order, order); var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(1000), + new IterationCountStopCriterium(1000), new ResidualStopCriterium(1e-10) }); var solver = new TFQMR(monitor); @@ -296,6 +300,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative Assert.AreEqual(matrixB.ColumnCount, matrixX.ColumnCount); var matrixBReconstruct = matrixA * matrixX; + // Check the reconstruction. for (var i = 0; i < matrixB.RowCount; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs index c2d5e7a2..a6387579 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/IteratorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { Assert.Throws(() => new Iterator(new IIterationStopCriterium[] { - new FailureStopCriterium(), + new FailureStopCriterium(), new FailureStopCriterium() })); } @@ -94,9 +94,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -143,9 +143,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(); @@ -175,9 +175,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -194,9 +194,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), }; var iterator = new Iterator(criteria); Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); @@ -213,9 +213,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -236,9 +236,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var iterator = new Iterator(); Assert.Throws(() => iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 5), + 0, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -250,17 +250,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -272,17 +272,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -294,17 +294,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 5), - null, + 1, + new DenseVector(3, 5), + null, new DenseVector(3, 6))); } @@ -316,17 +316,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -338,8 +338,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -347,17 +347,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); // Second step, should run out of iterations. iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationStoppedWithoutConvergence), iterator.Status, "Incorrect status"); } @@ -370,8 +370,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -379,9 +379,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); @@ -400,9 +400,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; @@ -416,6 +416,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers // ReSharper disable PossibleNullReferenceException Assert.AreEqual(iterator.NumberOfCriteria, clone.NumberOfCriteria, "Incorrect criterium count"); + // ReSharper restore PossibleNullReferenceException var enumerator = clone.StoredStopCriteria; while (enumerator.MoveNext()) diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs index 1a835cf1..02ab3136 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs @@ -75,11 +75,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit { var type = ilutp.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilutp, null); return (T)obj; @@ -139,8 +139,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit { var result = new Ilutp { - DropTolerance = _dropTolerance, - FillLevel = _fillLevel, + DropTolerance = _dropTolerance, + FillLevel = _fillLevel, PivotTolerance = _pivotTolerance }; return result; @@ -240,8 +240,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 0.0, - DropTolerance = 0, + PivotTolerance = 0.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -295,8 +295,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -331,8 +331,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit var vector = CreateStandardBcVector(Size); var preconditioner = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; preconditioner.Initialize(newMatrix); diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs index c6123ce3..9c063ffa 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs @@ -49,11 +49,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit { var type = ilu.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilu, null); return (T)obj; diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/UnitPreconditionerTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/UnitPreconditionerTest.cs index ba7780e9..101485c6 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/UnitPreconditionerTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/UnitPreconditionerTest.cs @@ -55,6 +55,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit protected override void CheckResult(IPreConditioner preconditioner, SparseMatrix matrix, Vector vector, Vector result) { Assert.AreEqual(typeof(UnitPreconditioner), preconditioner.GetType(), "#01"); + // Unit preconditioner is doing nothing. Vector and result should be equal for (var i = 0; i < vector.Count; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index 214f53b8..e89a954c 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs @@ -107,9 +107,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -121,9 +121,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -142,9 +142,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite for (var i = 0; i < Iterations - 1; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + i, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { (i + 1) * (Increase + 0.1) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -166,9 +166,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite for (var i = 0; i < Iterations * 2; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + i, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { (i + 1) * (Increase - 0.01) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -190,9 +190,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite for (var i = 0; i < Iterations - 5; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + i, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { (i + 1) * (Increase - 0.01) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -200,9 +200,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // Now make it fail by throwing in a NaN criterium.DetermineStatus( - Iterations, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + Iterations, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { double.NaN })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -225,9 +225,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite { previous *= 1 + Increase + 0.01; criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + i, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { previous })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -236,9 +236,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // Add the final residual. Now we should have divergence previous *= 1 + Increase + 0.01; criterium.DetermineStatus( - Iterations - 1, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + Iterations - 1, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { previous })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -257,9 +257,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // Add residuals. Blow it up instantly criterium.DetermineStatus( - 1, - new DenseVector(new[] { 1.0 }), - new DenseVector(new[] { 1.0 }), + 1, + new DenseVector(new[] { 1.0 }), + new DenseVector(new[] { 1.0 }), new DenseVector(new[] { double.NaN })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -293,6 +293,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.MaximumRelativeIncrease, clonedCriterium.MaximumRelativeIncrease, "Incorrect maximum"); Assert.AreEqual(criterium.MinimumNumberOfIterations, clonedCriterium.MinimumNumberOfIterations, "Incorrect iteration count"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index 3894d42e..77b6974f 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -134,6 +134,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.MaximumNumberOfIterations, clonedCriterium.MaximumNumberOfIterations, "Clone failed"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index 75847eca..029fe1bc 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/Solvers/StopCriterium/ResidualStopCriteriumTest.cs @@ -105,9 +105,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -121,9 +121,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -137,9 +137,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - null, + 1, + new DenseVector(3, 4), + null, new DenseVector(3, 6))); } @@ -153,9 +153,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -169,9 +169,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(4, 4), - new DenseVector(3, 4), + 1, + new DenseVector(4, 4), + new DenseVector(3, 4), new DenseVector(3, 4))); } @@ -185,9 +185,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(4, 4), + 1, + new DenseVector(3, 4), + new DenseVector(4, 4), new DenseVector(3, 4))); } @@ -201,9 +201,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(4, 4))); } @@ -321,6 +321,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.StopCrite // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.Maximum, clonedCriterium.Maximum, "Clone failed"); Assert.AreEqual(criterium.MinimumIterationsBelowMaximum, clonedCriterium.MinimumIterationsBelowMaximum, "Clone failed"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs index 15c741cf..6396f95d 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -86,10 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var testData = new Dictionary { - { "Singular3x3", new SparseMatrix(3, 3, new double[] { 1, 1, 1, 1, 1, 1, 2, 2, 2 }) }, - { "Square3x3", new SparseMatrix(3, 3, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5, -3.3, 2.2, 6.6 }) }, - { "Square4x4", new SparseMatrix(4, 4, new[] { -1.1, 0.0, 1.0, -4.4, -2.2, 1.1, 2.1, 5.5, -3.3, 2.2, 6.2, 6.6, -4.4, 3.3, 4.3, -7.7 }) }, - { "Tall3x2", new SparseMatrix(3, 2, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5 }) }, + { "Singular3x3", new SparseMatrix(3, 3, new double[] { 1, 1, 1, 1, 1, 1, 2, 2, 2 }) }, + { "Square3x3", new SparseMatrix(3, 3, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5, -3.3, 2.2, 6.6 }) }, + { "Square4x4", new SparseMatrix(4, 4, new[] { -1.1, 0.0, 1.0, -4.4, -2.2, 1.1, 2.1, 5.5, -3.3, 2.2, 6.2, 6.6, -4.4, 3.3, 4.3, -7.7 }) }, + { "Tall3x2", new SparseMatrix(3, 2, new[] { -1.1, 0.0, -4.4, -2.2, 1.1, 5.5 }) }, { "Wide2x3", new SparseMatrix(2, 3, new[] { -1.1, 0.0, -2.2, 1.1, -3.3, 2.2 }) } }; @@ -127,8 +127,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new SparseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -176,8 +181,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => SparseMatrix.Identity(order)); } @@ -237,7 +243,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double sparseResult = new SparseMatrix(new double[,] { { 0, 1, 1 } }); sparseResult.Add(sparseResult, sparseResult); Assert.IsTrue(sparseResult.Equals(2 * sum1)); - + var denseResult = new DenseMatrix(1, 3); denseResult.Add(m2, denseResult); Assert.IsTrue(denseResult.Equals(sum1)); @@ -303,10 +309,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [Test] public void CanCreateLargeMatrix() { - const int order = 1000000; - var matrix = new SparseMatrix(order); - Assert.AreEqual(order, matrix.RowCount); - Assert.AreEqual(order, matrix.ColumnCount); + const int Order = 1000000; + var matrix = new SparseMatrix(Order); + Assert.AreEqual(Order, matrix.RowCount); + Assert.AreEqual(Order, matrix.ColumnCount); Assert.DoesNotThrow(() => matrix[0, 0] = 1); } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs index 260e67e9..45412891 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseDoubleSparseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1 , 2 , 3 ] ", " [ -1 , 2 , +3 ] ", " [1.2,3.4 , 5.6] ")] string stringToParse, [Values("2", "3", "1,2,3", "1,2,3", "-1,2,3", "1.2,3.4,5.6")] string expectedToString) + [TestCase("2", "2")] + [TestCase("(3)", "3")] + [TestCase("[1,2,3]", "1,2,3")] + [TestCase(" [ 1 , 2 , 3 ] ", "1,2,3")] + [TestCase(" [ -1 , 2 , +3 ] ", "-1,2,3")] + [TestCase(" [1.2,3.4 , 5.6] ", "1.2,3.4,5.6")] + public void CanParseDoubleSparseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = SparseVector.Parse(stringToParse, formatProvider); @@ -56,10 +61,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseDoubleSparseVectorsWithCulture([Values(" 1.2,3.4 , 5.6 ", " 1.2;3.4 ; 5.6 ", " 1,2;3,4 ; 5,6 ")] string stringToParse, [Values("1.2,3.4,5.6", "1.2;3.4;5.6", "1,2;3,4;5,6")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2,3.4 , 5.6 ", "1.2,3.4,5.6", "en-US")] + [TestCase(" 1.2;3.4 ; 5.6 ", "1.2;3.4;5.6", "de-CH")] + [TestCase(" 1,2;3,4 ; 5,6 ", "1,2;3,4;5,6", "de-DE")] + public void CanParseDoubleSparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = SparseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -69,12 +76,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Can parse double sparse vectors. /// /// Vector as string. - [Test] - public void CanParseDoubleSparseVectors([Values("15", "1{0}2{1}3{0}4{1}5{0}6")] string vectorAsString) + [TestCase("15")] + [TestCase("1{0}2{1}3{0}4{1}5{0}6")] + public void CanParseDoubleSparseVectors(string vectorAsString) { var mappedString = String.Format( - vectorAsString, - CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, + vectorAsString, + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, CultureInfo.CurrentCulture.TextInfo.ListSeparator); var vector = SparseVector.Parse(mappedString); @@ -100,10 +108,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { var data = new[] { 1.2, 3.4, 5.6e-78 }; var text = String.Format( - "{1}{0}{2}{0}{3}", - CultureInfo.CurrentCulture.TextInfo.ListSeparator, - data[0], - data[1], + "{1}{0}{2}{0}{3}", + CultureInfo.CurrentCulture.TextInfo.ListSeparator, + data[0], + data[1], data[2]); SparseVector vector; @@ -120,8 +128,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { SparseVector vector; var ret = SparseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs index dbdb7c60..ffb284c1 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs index 382fb315..74fd4992 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs index b9b43687..59254ac6 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVector.cs b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVector.cs index 866bdfc0..03a7f618 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVector.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVector.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVectorTests.cs index 79a047ca..e222705a 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs index a07ab17b..c2393ab2 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Norm.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Norm.cs index 751fd8a9..596182dd 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Norm.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Norm.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -69,8 +69,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// The norm index. /// The expected P-norm value. - [Test, Sequential] - public void CanComputeNormP([Values(1, 2, 3, 10)] int p, [Values(15.0, 7.416198487095663, 6.0822019955734001, 5.0540557845353753)] double expected) + [TestCase(1, 15.0)] + [TestCase(2, 7.416198487095663)] + [TestCase(3, 6.0822019955734001)] + [TestCase(10, 5.0540557845353753)] + public void CanComputeNormP(int p, double expected) { var vector = CreateVector(Data); AssertHelpers.AlmostEqual(expected, vector.Norm(p), 15); diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs index 6de63357..babe2714 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -37,7 +37,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Abstract class with the common set of vector tests. /// - [TestFixture] public abstract partial class VectorTests { /// @@ -59,6 +58,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double CollectionAssert.AreEqual(vector, clone); } +#if !SILVERLIGHT /// /// Can clone a vector using IClonable interface method. /// @@ -72,6 +72,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.AreEqual(vector.Count, clone.Count); CollectionAssert.AreEqual(vector, clone); } +#endif /// /// Can convert vector to string. @@ -305,8 +306,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Sequential] - public void CanGetSubVector([Values(0, 2, 1)] int index, [Values(5, 2, 4)] int length) + [TestCase(0, 5)] + [TestCase(2, 2)] + [TestCase(1, 4)] + public void CanGetSubVector(int index, int length) { var vector = CreateVector(Data); var sub = vector.SubVector(index, length); @@ -322,8 +325,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Combinatorial] - public void CanGetSubVectorWithWrongValuesShouldThrowException([Values(6, 1)] int index, [Values(10, -10)] int length) + [TestCase(6, 10)] + [TestCase(1, -10)] + public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); Assert.Throws(() => vector.SubVector(index, length)); diff --git a/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs index cb82218b..7285df09 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -86,10 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var testData = new Dictionary { - { "Singular3x3", new DenseMatrix(3, 3, new[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f }) }, - { "Square3x3", new DenseMatrix(3, 3, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f, -3.3f, 2.2f, 6.6f }) }, - { "Square4x4", new DenseMatrix(4, 4, new[] { -1.1f, 0.0f, 1.0f, -4.4f, -2.2f, 1.1f, 2.1f, 5.5f, -3.3f, 2.2f, 6.2f, 6.6f, -4.4f, 3.3f, 4.3f, -7.7f }) }, - { "Tall3x2", new DenseMatrix(3, 2, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f }) }, + { "Singular3x3", new DenseMatrix(3, 3, new[] { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f }) }, + { "Square3x3", new DenseMatrix(3, 3, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f, -3.3f, 2.2f, 6.6f }) }, + { "Square4x4", new DenseMatrix(4, 4, new[] { -1.1f, 0.0f, 1.0f, -4.4f, -2.2f, 1.1f, 2.1f, 5.5f, -3.3f, 2.2f, 6.2f, 6.6f, -4.4f, 3.3f, 4.3f, -7.7f }) }, + { "Tall3x2", new DenseMatrix(3, 2, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f }) }, { "Wide2x3", new DenseMatrix(2, 3, new[] { -1.1f, 0.0f, -2.2f, 1.1f, -3.3f, 2.2f }) } }; @@ -126,8 +126,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DenseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -175,8 +180,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DenseMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs index de4f094e..0bd4170e 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -42,8 +42,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseSingleDenseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1 , 2 , 3 ] ", " [ -1 , 2 , +3 ] ", " [1.2,3.4 , 5.6] ")] string stringToParse, [Values("2", "3", "1,2,3", "1,2,3", "-1,2,3", "1.2,3.4,5.6")] string expectedToString) + [TestCase("2", "2")] + [TestCase("(3)", "3")] + [TestCase("[1,2,3]", "1,2,3")] + [TestCase(" [ 1 , 2 , 3 ] ", "1,2,3")] + [TestCase(" [ -1 , 2 , +3 ] ", "-1,2,3")] + [TestCase(" [1.2,3.4 , 5.6] ", "1.2,3.4,5.6")] + public void CanParseSingleDenseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = DenseVector.Parse(stringToParse, formatProvider); @@ -57,10 +62,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseSingleDenseVectorsWithCulture([Values(" 1.2,3.4 , 5.6 ", " 1.2;3.4 ; 5.6 ", " 1,2;3,4 ; 5,6 ")] string stringToParse, [Values("1.2,3.4,5.6", "1.2;3.4;5.6", "1,2;3,4;5,6")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2,3.4 , 5.6 ", "1.2,3.4,5.6", "en-US")] + [TestCase(" 1.2;3.4 ; 5.6 ", "1.2;3.4;5.6", "de-CH")] + [TestCase(" 1,2;3,4 ; 5,6 ", "1,2;3,4;5,6", "de-DE")] + public void CanParseSingleDenseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = DenseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -70,12 +77,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can parse float dense vectors. /// /// Vector as string. - [Test] - public void CanParseSingleDenseVectors([Values("15", "1{0}2{1}3{0}4{1}5{0}6")] string vectorAsString) + [TestCase("15")] + [TestCase("1{0}2{1}3{0}4{1}5{0}6")] + public void CanParseSingleDenseVectors(string vectorAsString) { var mappedString = String.Format( - vectorAsString, - CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, + vectorAsString, + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, CultureInfo.CurrentCulture.TextInfo.ListSeparator); var vector = DenseVector.Parse(mappedString); @@ -101,10 +109,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var data = new[] { 1.2f, 3.4f, 5.6e-78f }; var text = String.Format( - "{1}{0}{2}{0}{3}", - CultureInfo.CurrentCulture.TextInfo.ListSeparator, - data[0], - data[1], + "{1}{0}{2}{0}{3}", + CultureInfo.CurrentCulture.TextInfo.ListSeparator, + data[0], + data[1], data[2]); DenseVector vector; @@ -121,8 +129,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { DenseVector vector; var ret = DenseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs index 082c5d71..8d14d0a0 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs index 61a57ee7..831a9fd0 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -32,6 +32,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single using LinearAlgebra.Single; using NUnit.Framework; +#if SILVERLIGHT + using Threading; +#endif + /// /// Diagonal matrix tests. /// @@ -45,11 +49,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { 1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 3.0f } } }, - { "Square3x3", new[,] { { -1.1f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f }, { 0.0f, 0.0f, 6.6f } } }, - { "Square4x4", new[,] { { -1.1f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f, 0.0f }, { 0.0f, 0.0f, 6.2f, 0.0f }, { 0.0f, 0.0f, 0.0f, -7.7f } } }, - { "Singular4x4", new[,] { { -1.1f, 0.0f, 0.0f, 0.0f }, { 0.0f, -2.2f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, -4.4f } } }, - { "Tall3x2", new[,] { { -1.1f, 0.0f }, { 0.0f, 1.1f }, { 0.0f, 0.0f } } }, + { "Singular3x3", new[,] { { 1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 3.0f } } }, + { "Square3x3", new[,] { { -1.1f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f }, { 0.0f, 0.0f, 6.6f } } }, + { "Square4x4", new[,] { { -1.1f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f, 0.0f }, { 0.0f, 0.0f, 6.2f, 0.0f }, { 0.0f, 0.0f, 0.0f, -7.7f } } }, + { "Singular4x4", new[,] { { -1.1f, 0.0f, 0.0f, 0.0f }, { 0.0f, -2.2f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, -4.4f } } }, + { "Tall3x2", new[,] { { -1.1f, 0.0f }, { 0.0f, 1.1f }, { 0.0f, 0.0f } } }, { "Wide2x3", new[,] { { -1.1f, 0.0f, 0.0f }, { 0.0f, 1.1f, 0.0f } } } }; @@ -110,11 +114,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var testData = new Dictionary { - { "Singular3x3", new DiagonalMatrix(3, 3, new[] { 1.0f, 0.0f, 3.0f }) }, - { "Square3x3", new DiagonalMatrix(4, 4, new[] { -1.1f, 1.1f, 6.6f }) }, - { "Square4x4", new DiagonalMatrix(4, 4, new[] { -1.1f, 1.1f, 6.2f, -7.7f }) }, - { "Tall3x2", new DiagonalMatrix(3, 2, new[] { -1.1f, 1.1f }) }, - { "Wide2x3", new DiagonalMatrix(2, 3, new[] { -1.1f, 1.1f }) }, + { "Singular3x3", new DiagonalMatrix(3, 3, new[] { 1.0f, 0.0f, 3.0f }) }, + { "Square3x3", new DiagonalMatrix(4, 4, new[] { -1.1f, 1.1f, 6.6f }) }, + { "Square4x4", new DiagonalMatrix(4, 4, new[] { -1.1f, 1.1f, 6.2f, -7.7f }) }, + { "Tall3x2", new DiagonalMatrix(3, 2, new[] { -1.1f, 1.1f }) }, + { "Wide2x3", new DiagonalMatrix(2, 3, new[] { -1.1f, 1.1f }) }, }; foreach (var name in testData.Keys) @@ -139,8 +143,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new DiagonalMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -185,8 +194,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => DiagonalMatrix.Identity(order)); } diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs index 27a7a53e..54971d5d 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/CholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -83,8 +85,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -96,8 +100,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var chol = matrixX.Cholesky(); @@ -131,8 +140,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -165,8 +179,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(row); var matrixACopy = matrixA.Clone(); @@ -202,8 +221,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order); var matrixACopy = matrixA.Clone(); @@ -244,8 +268,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/EvdTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/EvdTests.cs index 0cd58c18..d2bf2c94 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/EvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/EvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -51,8 +51,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -137,8 +139,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -150,8 +154,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -174,8 +180,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorEvd = matrixI.Evd(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs index 9b1c3f7c..5f299fda 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/GramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -59,8 +59,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -105,8 +107,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -118,8 +122,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -161,8 +170,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -195,8 +209,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -236,8 +255,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -277,8 +301,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs index ee91b8fb..020df06f 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/LUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -40,8 +40,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -85,8 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var lu = matrixI.LU(); @@ -97,8 +101,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorLU = matrixX.LU(); @@ -147,8 +156,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -181,8 +195,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -222,8 +241,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -263,8 +287,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -316,8 +345,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs index be891fc5..29980350 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/QRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -59,8 +59,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -89,8 +91,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = DenseMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -102,8 +106,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorQR = matrixA.QR(); @@ -145,8 +154,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -179,8 +193,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -220,8 +239,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -261,8 +285,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs index 75d5a085..e430848d 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/SvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = DenseMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -82,8 +84,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -119,8 +126,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -133,8 +142,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -153,8 +167,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new DenseMatrix(order, order); matrixA[0, 0] = 1; @@ -204,8 +220,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -239,8 +260,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -281,8 +307,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -321,8 +352,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomDenseMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs index bf2230b5..6186f6b3 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserCholeskyTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,8 +39,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky().Factor; @@ -82,8 +84,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorC = matrixI.Cholesky(); @@ -95,8 +99,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var chol = matrixX.Cholesky(); @@ -130,8 +139,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -164,8 +178,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrix(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); @@ -201,8 +220,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -243,8 +267,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 4, 8, 3, 10, 100)] int col) + [TestCase(1, 1)] + [TestCase(2, 4)] + [TestCase(5, 8)] + [TestCase(10, 3)] + [TestCase(50, 10)] + [TestCase(100, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int col) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(row); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserEvdTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserEvdTests.cs index 86b8924d..3be73123 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserEvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserEvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -50,8 +50,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -75,8 +77,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -136,8 +143,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorEvd = matrixA.Evd(); @@ -149,8 +158,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -173,8 +184,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorEvd = matrixI.Evd(); @@ -185,8 +198,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -219,8 +237,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -260,8 +283,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector and symmetric matrix (Ax=b) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorAndSymmetricMatrixWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorAndSymmetricMatrixWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); @@ -299,8 +327,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix and symmetric matrix (AX=B) into result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixAndSymmetricMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomPositiveDefiniteUserDefinedMatrix(order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs index ce01d42c..92f2b0d7 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserGramSchmidtTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -57,8 +57,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -103,8 +105,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorGramSchmidt = matrixI.GramSchmidt(); @@ -116,8 +120,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorGramSchmidt = matrixA.GramSchmidt(); @@ -159,8 +168,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -193,8 +207,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -234,8 +253,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -275,8 +299,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs index dbc3936a..fcebf02a 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserLUTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,8 +39,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorLU = matrixI.LU(); @@ -84,8 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var lu = matrixI.LU(); @@ -96,8 +100,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize a random square matrix. /// /// Matrix order. - [Test] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanFactorizeRandomMatrix(int order) { var matrixX = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorLU = matrixX.LU(); @@ -146,8 +155,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -180,8 +194,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -221,8 +240,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -262,8 +286,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix row number. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -315,8 +344,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can inverse a matrix. /// /// Matrix order. - [Test] - public void CanInverse([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanInverse(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs index 50d9cad9..9340c2fe 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserQRTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -58,8 +58,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -88,8 +90,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Identity determinant is one. /// /// Matrix order. - [Test] - public void IdentityDeterminantIsOne([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void IdentityDeterminantIsOne(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorQR = matrixI.QR(); @@ -101,8 +105,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorQR = matrixA.QR(); @@ -144,8 +153,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random vector (Ax=b). /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVector(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -178,8 +192,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B). /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrix(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -219,8 +238,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve for a random vector into a result vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); @@ -260,8 +284,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can solve a system of linear equations for a random matrix (AX=B) into a result matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 2, 5, 10, 50, 100)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs index 2c7a4e67..1249b233 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Factorization/UserSvdTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -49,8 +49,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can factorize identity matrix. /// /// Matrix order. - [Test] - public void CanFactorizeIdentity([Values(1, 10, 100)] int order) + [TestCase(1)] + [TestCase(10)] + [TestCase(100)] + public void CanFactorizeIdentity(int order) { var matrixI = UserDefinedMatrix.Identity(order); var factorSvd = matrixI.Svd(true); @@ -81,8 +83,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanFactorizeRandomMatrix([Values(1, 2, 5, 10, 50, 100)] int row, [Values(1, 2, 5, 6, 48, 98)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(10, 6)] + [TestCase(50, 48)] + [TestCase(100, 98)] + public void CanFactorizeRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -118,8 +125,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanCheckRankOfNonSquare([Values(10, 48, 100)] int row, [Values(8, 52, 93)] int column) + [TestCase(10, 8)] + [TestCase(48, 52)] + [TestCase(100, 93)] + public void CanCheckRankOfNonSquare(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var factorSvd = matrixA.Svd(true); @@ -132,8 +141,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of a square matrix. /// /// Matrix order. - [Test] - public void CanCheckRankSquare([Values(1, 2, 5, 9, 50, 90)] int order) + [TestCase(1)] + [TestCase(2)] + [TestCase(5)] + [TestCase(9)] + [TestCase(50)] + [TestCase(90)] + public void CanCheckRankSquare(int order) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(order, order); var factorSvd = matrixA.Svd(true); @@ -152,8 +166,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// Can check rank of a square singular matrix. /// /// Matrix order. - [Test] - public void CanCheckRankOfSquareSingular([Values(10, 50, 100)] int order) + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] + public void CanCheckRankOfSquareSingular(int order) { var matrixA = new UserDefinedMatrix(order, order); matrixA[0, 0] = 1; @@ -203,8 +219,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVector([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVector(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -238,8 +259,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrix([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrix(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -280,8 +306,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomVectorWhenResultVectorGiven([Values(1, 2, 5, 9, 50, 90)] int row, [Values(1, 2, 5, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(2, 2)] + [TestCase(5, 5)] + [TestCase(9, 10)] + [TestCase(50, 50)] + [TestCase(90, 100)] + public void CanSolveForRandomVectorWhenResultVectorGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); @@ -320,8 +351,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Factorization /// /// Matrix row number. /// Matrix column number. - [Test, Sequential] - public void CanSolveForRandomMatrixWhenResultMatrixGiven([Values(1, 4, 7, 10, 45, 80)] int row, [Values(1, 4, 8, 10, 50, 100)] int column) + [TestCase(1, 1)] + [TestCase(4, 4)] + [TestCase(7, 8)] + [TestCase(10, 10)] + [TestCase(45, 50)] + [TestCase(80, 100)] + public void CanSolveForRandomMatrixWhenResultMatrixGiven(int row, int column) { var matrixA = MatrixLoader.GenerateRandomUserDefinedMatrix(row, column); var matrixACopy = matrixA.Clone(); diff --git a/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedReaderTests.cs index 4e99e6f9..915e8769 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -52,7 +52,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.IO var reader = new DelimitedReader(',') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = CultureInfo.InvariantCulture }; @@ -141,7 +141,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.IO var reader = new DelimitedReader('.') { - HasHeaderRow = true, + HasHeaderRow = true, CultureInfo = new CultureInfo("tr-TR") }; diff --git a/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs index 6698b771..f818232b 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/IO/DelimitedWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabReaderTests.cs b/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabReaderTests.cs index 42cbbe09..91d73ab4 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabReaderTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabReaderTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabWriterTests.cs b/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabWriterTests.cs index 8c5ac257..3ded9446 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabWriterTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/IO/MatlabWriterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs index 751281c0..09dbe2f5 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -94,12 +94,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { TestData2D = new Dictionary { - { "Singular3x3", new[,] { { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } } }, - { "Square3x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } } }, - { "Square4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } } }, - { "Singular4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } } }, - { "Tall3x2", new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } } }, - { "Wide2x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } } }, + { "Singular3x3", new[,] { { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } } }, + { "Square3x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } } }, + { "Square4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } } }, + { "Singular4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } } }, + { "Tall3x2", new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } } }, + { "Wide2x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } } }, { "Symmetric3x3", new[,] { { 1.0f, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } } }; diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs index 32172cce..b1c635be 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can multiply with a scalar. /// /// Scalar value. - [Test] - public void CanMultiplyWithScalar([Values(0, 1, 2.2f)] float scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanMultiplyWithScalar(float scalar) { var matrix = TestMatrices["Singular3x3"]; var clone = matrix.Clone(); @@ -146,8 +148,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can left multiply with a scalar. /// /// Scalar value. - [Test, Sequential] - public void CanOperatorLeftMultiplyWithScalar([Values(0, 1, 2.2f)] float scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanOperatorLeftMultiplyWithScalar(float scalar) { var matrix = TestMatrices["Singular3x3"]; var clone = scalar * matrix; @@ -165,8 +169,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can right multiply with a scalar. /// /// Scalar value. - [Test, Sequential] - public void CanOperatorRightMultiplyWithScalar([Values(0, 1, 2.2f)] float scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanOperatorRightMultiplyWithScalar(float scalar) { var matrix = TestMatrices["Singular3x3"]; var clone = matrix * scalar; @@ -184,8 +190,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can multiply with a scalar into result. /// /// Scalar value. - [Test] - public void CanMultiplyWithScalarIntoResult([Values(0, 1, 2.2f)] float scalar) + [TestCase(0)] + [TestCase(1)] + [TestCase(2.2f)] + public void CanMultiplyWithScalarIntoResult(float scalar) { var matrix = TestMatrices["Singular3x3"]; var result = matrix.Clone(); @@ -258,8 +266,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -313,8 +322,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanAddUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanAddUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -378,8 +388,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractMatrix([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractMatrix(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -433,8 +444,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanSubtractUsingOperator([Values("Singular3x3", "Singular4x4")] string mtxA, [Values("Square3x3", "Square4x4")] string mtxB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + public void CanSubtractUsingOperator(string mtxA, string mtxB) { var matrixA = TestMatrices[mtxA]; var matrixB = TestMatrices[mtxB]; @@ -498,8 +510,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public void CanMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public void CanMultiplyMatrixWithMatrix(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -521,8 +537,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can transpose and multiply a matrix with matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -600,8 +619,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can transpose and multiply a matrix with matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -658,8 +680,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix A name. /// Matrix B name. - [Test, Sequential] - public virtual void CanMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string nameA, [Values("Square3x3", "Square4x4", "Square3x3", "Tall3x2", "Wide2x3")] string nameB) + [TestCase("Singular3x3", "Square3x3")] + [TestCase("Singular4x4", "Square4x4")] + [TestCase("Wide2x3", "Square3x3")] + [TestCase("Wide2x3", "Tall3x2")] + [TestCase("Tall3x2", "Wide2x3")] + public virtual void CanMultiplyMatrixWithMatrixIntoResult(string nameA, string nameB) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameB]; @@ -767,8 +793,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can multiply transposed matrix with another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrix([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrix(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -812,8 +841,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Multiply transpose of this matrix with another matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Tall3x2")] string nameA) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanTransposeThisAndMultiplyMatrixWithMatrixIntoResult(string nameA) { var matrixA = TestMatrices[nameA]; var matrixB = TestMatrices[nameA]; @@ -836,8 +868,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can negate a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegate([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegate(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -857,8 +893,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can negate a matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanNegateIntoResult([Values("Singular3x3", "Singular4x4", "Wide2x3", "Wide2x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Wide2x3")] + [TestCase("Wide2x3")] + [TestCase("Tall3x2")] + public void CanNegateIntoResult(string name) { var matrix = TestMatrices[name]; var copy = matrix.Clone(); @@ -960,8 +1000,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can normalize columns of a matrix. /// /// The norm under which to normalize the columns under. - [Test, Sequential] - public void CanNormalizeColumns([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeColumns(int p) { var matrix = TestMatrices["Square4x4"]; var result = matrix.NormalizeColumns(p); @@ -985,8 +1026,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can normalize rows of a matrix. /// /// The norm under which to normalize the rows under. - [Test, Sequential] - public void CanNormalizeRows([Values(1, 2)] int p) + [TestCase(1)] + [TestCase(2)] + public void CanNormalizeRows(int p) { var matrix = TestMatrices["Square4x4"].NormalizeRows(p); for (var i = 0; i < matrix.RowCount; i++) @@ -1161,8 +1203,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Create random matrix with non-positive number of rows throw ArgumentException. /// /// Number of rows. - [Test, Sequential] - public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException([Values(0, -2)] int numberOfRows) + [TestCase(0)] + [TestCase(-2)] + public void RandomWithNonPositiveNumberOfRowsThrowsArgumentException(int numberOfRows) { var matrix = CreateMatrix(2, 3); Assert.Throws(() => matrix.Random(numberOfRows, 4, new ContinuousUniform())); diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.cs index 71fa3886..e6ae1c4e 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -33,15 +33,18 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Abstract class with the common set of matrix tests /// - [TestFixture] public abstract partial class MatrixTests : MatrixLoader { /// /// Can clone a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var clone = matrix.Clone(); @@ -62,8 +65,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can clone a matrix using ICloneable interface. /// /// Matrix name. - [Test, Sequential] - public void CanCloneMatrixUsingICloneable([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCloneMatrixUsingICloneable(string name) { var matrix = TestMatrices[name]; var clone = (Matrix)((ICloneable)matrix).Clone(); @@ -84,8 +91,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can copy a matrix to another matrix. /// /// Matrix name. - [Test, Sequential] - public void CanCopyTo([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCopyTo(string name) { var matrix = TestMatrices[name]; var copy = CreateMatrix(matrix.RowCount, matrix.ColumnCount); @@ -149,8 +160,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can equate matrices. /// /// Matrix name. - [Test, Sequential] - public void CanEquateMatrices([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanEquateMatrices(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -166,8 +181,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// The number of rows. /// The number of columns. - [Test, Sequential] - public void IfSizeIsNotPositiveThrowsArgumentException([Values(0, 2, 0, -1, 1)] int rows, [Values(2, 0, 0, 1, -1)] int columns) + [TestCase(0, 2)] + [TestCase(2, 0)] + [TestCase(0, 0)] + [TestCase(-1, 1)] + [TestCase(1, -1)] + public void IfSizeIsNotPositiveThrowsArgumentException(int rows, int columns) { Assert.Throws(() => CreateMatrix(rows, columns)); } @@ -176,8 +195,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Testing for equality with non-matrix returns false. /// /// Matrix name. - [Test, Sequential] - public void TestingForEqualityWithNonMatrixReturnsFalse([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void TestingForEqualityWithNonMatrixReturnsFalse(string name) { var matrix = CreateMatrix(TestData2D[name]); Assert.IsFalse(matrix.Equals(2)); @@ -187,8 +210,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can test for equality using Object.Equals. /// /// Matrix name. - [Test, Sequential] - public void CanTestForEqualityUsingObjectEquals([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTestForEqualityUsingObjectEquals(string name) { var matrix1 = CreateMatrix(TestData2D[name]); var matrix2 = CreateMatrix(TestData2D[name]); @@ -201,8 +228,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Row index. /// Column index. /// Matrix name. - [Test, Sequential] - public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException([Values(-1, 1, 4)] int i, [Values(1, -1, 2)] int j, [Values("Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(-1, 1, "Singular3x3")] + [TestCase(1, -1, "Singular3x3")] + [TestCase(4, 2, "Square3x3")] + public void RangeCheckWithInvalidIndicesThrowsArgumentOutOfRangeException(int i, int j, string name) { Assert.Throws(() => { var x = TestMatrices[name][i, j]; }); } @@ -238,8 +267,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRow(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex); @@ -276,8 +307,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetRowIntoResult([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetRowIntoResult(int rowIndex, string name) { var matrix = TestMatrices[name]; var row = CreateVector(matrix.ColumnCount); @@ -329,8 +362,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Column start. /// Row length. /// Matrix name. - [Test, Sequential] - public void CanGetRowWithRange([Values(0, 1, 2, 2)] int rowIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetRowWithRange(int rowIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var row = matrix.Row(rowIndex, start, length); @@ -369,8 +405,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumn(int colIndex, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex); @@ -407,8 +445,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanGetColumnIntoResult([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanGetColumnIntoResult(int colIndex, string name) { var matrix = TestMatrices[name]; var col = CreateVector(matrix.RowCount); @@ -460,8 +500,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Start index. /// Column length. /// Matrix name. - [Test, Sequential] - public void CanGetColumnWithRange([Values(0, 1, 2, 2)] int colIndex, [Values(0, 1, 0, 0)] int start, [Values(1, 2, 3, 3)] int length, [Values("Singular3x3", "Singular3x3", "Singular3x3", "Square3x3")] string name) + [TestCase(0, 0, 1, "Singular3x3")] + [TestCase(1, 1, 2, "Singular3x3")] + [TestCase(2, 0, 3, "Singular3x3")] + [TestCase(2, 0, 3, "Square3x3")] + public void CanGetColumnWithRange(int colIndex, int start, int length, string name) { var matrix = TestMatrices[name]; var col = matrix.Column(colIndex, start, length); @@ -500,8 +543,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Row index. /// Matrix name. - [Test, Combinatorial] - public void CanSetRow([Values(0, 1, 2)] int rowIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetRow(int rowIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetRow(rowIndex, CreateVector(matrix.ColumnCount)); @@ -520,8 +565,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Column index. /// Matrix name. - [Test, Combinatorial] - public void CanSetColumn([Values(0, 1, 2)] int colIndex, [Values("Singular3x3", "Square3x3")] string name) + [TestCase(0, "Singular3x3")] + [TestCase(1, "Square3x3")] + [TestCase(2, "Square3x3")] + public void CanSetColumn(int colIndex, string name) { var matrix = TestMatrices[name].Clone(); matrix.SetColumn(colIndex, CreateVector(matrix.ColumnCount)); @@ -539,8 +586,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Get an upper triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangle(string name) { var data = TestMatrices[name]; var upper = data.UpperTriangle(); @@ -557,8 +608,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Get an upper triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanUpperTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanUpperTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -609,8 +664,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Get a lower triangle matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangle([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangle(string name) { var data = TestMatrices[name]; var lower = data.LowerTriangle(); @@ -627,8 +686,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Get a lower triangle matrix into a result matrix. /// /// Matrix name. - [Test, Sequential] - public void CanLowerTriangleIntoResult([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanLowerTriangleIntoResult(string name) { var data = TestMatrices[name]; var result = CreateMatrix(data.RowCount, data.ColumnCount); @@ -823,8 +886,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can transpose a matrix. /// /// Matrix name. - [Test, Sequential] - public void CanTransposeMatrix([Values("Singular3x3", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanTransposeMatrix(string name) { var matrix = CreateMatrix(TestData2D[name]); var transpose = matrix.Transpose(); @@ -846,8 +913,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix name. /// Column array. - [Test, Sequential] - public virtual void CanSetColumnWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 })] float[] column) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + public virtual void CanSetColumnWithArray(string name, float[] column) { var matrix = TestMatrices[name]; for (var i = 0; i < matrix.ColumnCount; i++) @@ -897,8 +967,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix name. /// Column values. - [Test, Sequential] - public virtual void CanSetColumnWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 })] float[] column) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + public virtual void CanSetColumnWithVector(string name, float[] column) { var matrix = TestMatrices[name]; var columnVector = CreateVector(column); @@ -1011,8 +1084,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix name. /// Row index. - [Test, Sequential] - public virtual void CanSetRowWithArray([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2, 3 })] float[] row) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + [TestCase("Wide2x3", new float[] { 1, 2, 3 })] + public virtual void CanSetRowWithArray(string name, float[] row) { var matrix = TestMatrices[name]; for (var i = 0; i < matrix.RowCount; i++) @@ -1052,8 +1128,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix name. /// Row index. - [Test, Sequential] - public virtual void CanSetRowWithVector([Values("Singular3x3", "Square3x3", "Tall3x2", "Wide2x3")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2, 3 })] float[] row) + [TestCase("Singular3x3", new float[] { 1, 2, 3 })] + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + [TestCase("Wide2x3", new float[] { 1, 2, 3 })] + public virtual void CanSetRowWithVector(string name, float[] row) { var matrix = TestMatrices[name]; var rowVector = CreateVector(row); @@ -1107,8 +1186,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void CanSetSubMatrix([Values(0, 1)] int rowStart, [Values(2, 1)] int rowLength, [Values(0, 1)] int colStart, [Values(2, 1)] int colLength) + [TestCase(0, 2, 0, 2)] + [TestCase(1, 1, 1, 1)] + public virtual void CanSetSubMatrix(int rowStart, int rowLength, int colStart, int colLength) { foreach (var matrix in TestMatrices.Values) { @@ -1136,8 +1216,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException([Values(0, 0, 4, 0, -1, 0)] int rowStart, [Values(4, 2, 2, 2, 2, 2)] int rowLength, [Values(0, 0, 0, 4, 0, -1)] int colStart, [Values(2, 4, 2, 2, 2, 2)] int colLength) + [TestCase(0, 4, 0, 2)] + [TestCase(0, 2, 0, 4)] + [TestCase(4, 2, 0, 2)] + [TestCase(0, 2, 4, 2)] + [TestCase(-1, 2, 0, 2)] + [TestCase(0, 2, -1, 2)] + public virtual void SetSubMatrixWithInvalidRangesThrowsArgumentOutOfRangeException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0f; @@ -1154,8 +1239,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// The number of rows to copy. /// The column to start copying to. /// The number of columns to copy. - [Test, Sequential] - public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException([Values(0, 0)] int rowStart, [Values(-1, 2)] int rowLength, [Values(0, 0)] int colStart, [Values(2, -1)] int colLength) + [TestCase(0, -1, 0, 2)] + [TestCase(0, 2, 0, -1)] + public virtual void SetSubMatrixWithInvalidLengthsThrowsArgumentException(int rowStart, int rowLength, int colStart, int colLength) { var subMatrix = TestMatrices["Square3x3"].SubMatrix(0, 2, 0, 2); subMatrix[0, 0] = 10.0f; @@ -1180,8 +1266,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix name. /// Diagonal vector. - [Test, Sequential] - public void CanSetDiagonalVector([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2 })] float[] diagonal) + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + public void CanSetDiagonalVector(string name, float[] diagonal) { var matrix = TestMatrices[name]; var vector = CreateVector(diagonal); @@ -1221,8 +1309,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Matrix name. /// Diagonal array. - [Test, Sequential] - public void CanSetDiagonalArray([Values("Square3x3", "Wide2x3", "Tall3x2")] string name, [Values(new float[] { 1, 2, 3 }, new float[] { 1, 2 }, new float[] { 1, 2 })] float[] diagonal) + [TestCase("Square3x3", new float[] { 1, 2, 3 })] + [TestCase("Wide2x3", new float[] { 1, 2 })] + [TestCase("Tall3x2", new float[] { 1, 2 })] + public void CanSetDiagonalArray(string name, float[] diagonal) { var matrix = TestMatrices[name]; matrix.SetDiagonal(diagonal); @@ -1384,8 +1474,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can permute matrix rows. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixRows([Values("Singular3x3", "Square3x3", "Tall3x2")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Tall3x2")] + public virtual void CanPermuteMatrixRows(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); @@ -1409,8 +1501,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can permute matrix columns. /// /// Matrix name. - [Test, Sequential] - public virtual void CanPermuteMatrixColumns([Values("Singular3x3", "Square3x3", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Square3x3")] + [TestCase("Wide2x3")] + public virtual void CanPermuteMatrixColumns(string name) { var matrix = CreateMatrix(TestData2D[name]); var matrixp = CreateMatrix(TestData2D[name]); @@ -1728,7 +1822,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single matrix = TestMatrices["Tall3x2"]; AssertHelpers.AlmostEqual(7.182727033856683f, matrix.L2Norm(), 5); } - + /// /// Test whether the index enumerator returns the correct values. /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs index 6db78a5a..6b840b5f 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs @@ -90,9 +90,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -135,9 +135,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -213,9 +213,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new BiCgStab(monitor); @@ -244,8 +244,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomVector(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 3 tries and downgrade stop criterium each time @@ -256,8 +256,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new BiCgStab(monitor); var resultx = solver.Solve(matrixA, vectorb); @@ -285,8 +285,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomMatrix(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 3 tries and downgrade stop criterium each time @@ -297,7 +297,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), + new IterationCountStopCriterium(MaximumIterations), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new BiCgStab(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs index 9d3d7b8a..e5e673fd 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs @@ -90,9 +90,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new GpBiCg(monitor); @@ -135,9 +135,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -214,9 +214,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -246,8 +246,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomVector(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 3 tries and downgrade stop criterium each time @@ -258,8 +258,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new GpBiCg(monitor); var resultx = solver.Solve(matrixA, vectorb); @@ -287,8 +287,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomMatrix(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 3 tries and downgrade stop criterium each time @@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), + new IterationCountStopCriterium(MaximumIterations), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new GpBiCg(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs index a84aeae5..bf6f2324 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs @@ -90,9 +90,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -218,9 +218,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new MlkBiCgStab(monitor); @@ -262,8 +262,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomVector(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 4 tries and downgrade stop criterium each time @@ -274,8 +274,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new MlkBiCgStab(monitor); var resultx = solver.Solve(matrixA, vectorb); @@ -305,8 +305,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for a random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomMatrix(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 4 tries and downgrade stop criterium each time @@ -317,7 +317,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), + new IterationCountStopCriterium(MaximumIterations), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new MlkBiCgStab(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs index b77ec0b3..8d9baa92 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs @@ -90,9 +90,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -214,9 +214,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative // Create an iteration monitor which will keep track of iterative convergence var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium(ConvergenceBoundary), - new DivergenceStopCriterium(), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium(ConvergenceBoundary), + new DivergenceStopCriterium(), new FailureStopCriterium() }); var solver = new TFQMR(monitor); @@ -245,8 +245,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for a random vector. /// /// Matrix order. - [Test] - public void CanSolveForRandomVector([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomVector(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 3 tries and downgrade stop criterium each time @@ -257,8 +257,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), - new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), + new IterationCountStopCriterium(MaximumIterations), + new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)), }); var solver = new TFQMR(monitor); var resultx = solver.Solve(matrixA, vectorb); @@ -286,8 +286,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative /// Can solve for random matrix. /// /// Matrix order. - [Test] - public void CanSolveForRandomMatrix([Values(5)] int order) + [TestCase(5)] + public void CanSolveForRandomMatrix(int order) { // Due to datatype "float" it can happen that solution will not converge for specific random matrix // That's why we will do 4 tries and downgrade stop criterium each time @@ -298,7 +298,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative var monitor = new Iterator(new IIterationStopCriterium[] { - new IterationCountStopCriterium(MaximumIterations), + new IterationCountStopCriterium(MaximumIterations), new ResidualStopCriterium((float)Math.Pow(1.0 / 10.0, iteration)) }); var solver = new TFQMR(monitor); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs index feaad53b..e425e839 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/IteratorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { Assert.Throws(() => new Iterator(new IIterationStopCriterium[] { - new FailureStopCriterium(), + new FailureStopCriterium(), new FailureStopCriterium() })); } @@ -93,9 +93,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -142,9 +142,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(); @@ -174,9 +174,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -193,9 +193,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), }; var iterator = new Iterator(criteria); Assert.AreEqual(criteria.Count, iterator.NumberOfCriteria, "Incorrect criterium count"); @@ -212,9 +212,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); @@ -235,9 +235,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var iterator = new Iterator(); Assert.Throws(() => iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 5), + 0, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -249,17 +249,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -271,17 +271,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -293,17 +293,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 5), - null, + 1, + new DenseVector(3, 5), + null, new DenseVector(3, 6))); } @@ -315,17 +315,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; var iterator = new Iterator(criteria); Assert.Throws(() => iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -337,8 +337,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -346,17 +346,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); // Second step, should run out of iterations. iterator.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationStoppedWithoutConvergence), iterator.Status, "Incorrect status"); } @@ -369,8 +369,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), new IterationCountStopCriterium(1) }; @@ -378,9 +378,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers // First step, nothing should happen. iterator.DetermineStatus( - 0, - new DenseVector(3, 4), - new DenseVector(3, 4), + 0, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(3, 4)); Assert.IsInstanceOf(typeof(CalculationRunning), iterator.Status, "Incorrect status"); @@ -399,9 +399,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers { var criteria = new List { - new FailureStopCriterium(), - new DivergenceStopCriterium(), - new IterationCountStopCriterium(), + new FailureStopCriterium(), + new DivergenceStopCriterium(), + new IterationCountStopCriterium(), new ResidualStopCriterium() }; diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IlutpTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IlutpTest.cs index 222d3d15..fb052490 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IlutpTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IlutpTest.cs @@ -74,11 +74,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit { var type = ilutp.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilutp, null); return (T)obj; @@ -138,8 +138,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit { var result = new Ilutp { - DropTolerance = _dropTolerance, - FillLevel = _fillLevel, + DropTolerance = _dropTolerance, + FillLevel = _fillLevel, PivotTolerance = _pivotTolerance }; return result; @@ -239,8 +239,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 0.0, - DropTolerance = 0, + PivotTolerance = 0.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -271,7 +271,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit { for (var j = 0; j < sparseMatrix.ColumnCount; j++) { - Assert.IsTrue(((double)sparseMatrix[i, j]).AlmostEqual(original[i, j], -Epsilon.Magnitude()), "#03-" + i + "-" + j); + Assert.IsTrue(((double)sparseMatrix[i, j]).AlmostEqualInDecimalPlaces(original[i, j], 5), "#03-" + i + "-" + j); } } } @@ -294,8 +294,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit sparseMatrix[2, 2] = 9; var ilu = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; ilu.Initialize(sparseMatrix); @@ -330,8 +330,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit var vector = CreateStandardBcVector(Size); var preconditioner = new Ilutp { - PivotTolerance = 1.0, - DropTolerance = 0, + PivotTolerance = 1.0, + DropTolerance = 0, FillLevel = 10 }; preconditioner.Initialize(newMatrix); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs index 8d1b713f..2fa72e6f 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs @@ -48,11 +48,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit { var type = ilu.GetType(); var methodInfo = type.GetMethod( - methodName, - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, - null, - CallingConventions.Standard, - new Type[0], + methodName, + BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, + null, + CallingConventions.Standard, + new Type[0], null); var obj = methodInfo.Invoke(ilu, null); return (T)obj; diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs index 5e36ee35..fd0c480e 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/DivergenceStopCriteriumTest.cs @@ -106,9 +106,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -120,9 +120,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { var criterium = new DivergenceStopCriterium(0.5, 15); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -141,9 +141,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite for (var i = 0; i < Iterations - 1; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + i, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { (i + 1) * (Increase + 0.1f) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -165,9 +165,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite for (var i = 0; i < Iterations * 2; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + i, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { (i + 1) * (Increase - 0.01f) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -189,9 +189,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite for (var i = 0; i < Iterations - 5; i++) { criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + i, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { (i + 1) * (Increase - 0.01f) })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -199,9 +199,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite // Now make it fail by throwing in a NaN criterium.DetermineStatus( - Iterations, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + Iterations, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { float.NaN })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -224,9 +224,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite { previous *= 1 + Increase + 0.01f; criterium.DetermineStatus( - i, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + i, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { previous })); Assert.IsInstanceOf(typeof(CalculationRunning), criterium.Status, "Status check fail."); @@ -235,9 +235,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite // Add the final residual. Now we should have divergence previous *= 1 + Increase + 0.01f; criterium.DetermineStatus( - Iterations - 1, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + Iterations - 1, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { previous })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); @@ -256,9 +256,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite // Add residuals. Blow it up instantly criterium.DetermineStatus( - 1, - new DenseVector(new[] { 1.0f }), - new DenseVector(new[] { 1.0f }), + 1, + new DenseVector(new[] { 1.0f }), + new DenseVector(new[] { 1.0f }), new DenseVector(new[] { float.NaN })); Assert.IsInstanceOf(typeof(CalculationDiverged), criterium.Status, "Status check fail."); diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs index ea5ac75e..e3483475 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/IterationCountStopCriteriumTest.cs @@ -134,6 +134,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite // ReSharper disable PossibleNullReferenceException Assert.AreEqual(criterium.MaximumNumberOfIterations, clonedCriterium.MaximumNumberOfIterations, "Clone failed"); + // ReSharper restore PossibleNullReferenceException } } diff --git a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs index c64ec032..1db28d63 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/Solvers/StopCriterium/ResidualStopCriteriumTest.cs @@ -104,9 +104,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - -1, - new DenseVector(3, 4), - new DenseVector(3, 5), + -1, + new DenseVector(3, 4), + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -120,9 +120,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - null, - new DenseVector(3, 5), + 1, + null, + new DenseVector(3, 5), new DenseVector(3, 6))); } @@ -136,9 +136,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - null, + 1, + new DenseVector(3, 4), + null, new DenseVector(3, 6))); } @@ -152,9 +152,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 5), + 1, + new DenseVector(3, 4), + new DenseVector(3, 5), null)); } @@ -168,9 +168,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(4, 4), - new DenseVector(3, 4), + 1, + new DenseVector(4, 4), + new DenseVector(3, 4), new DenseVector(3, 4))); } @@ -184,9 +184,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(4, 4), + 1, + new DenseVector(3, 4), + new DenseVector(4, 4), new DenseVector(3, 4))); } @@ -200,9 +200,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.StopCrite Assert.IsNotNull(criterium, "There should be a criterium"); Assert.Throws(() => criterium.DetermineStatus( - 1, - new DenseVector(3, 4), - new DenseVector(3, 4), + 1, + new DenseVector(3, 4), + new DenseVector(3, 4), new DenseVector(4, 4))); } diff --git a/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs index baad4a95..6a88cdb9 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -86,10 +86,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var testData = new Dictionary { - { "Singular3x3", new SparseMatrix(3, 3, new float[] { 1, 1, 1, 1, 1, 1, 2, 2, 2 }) }, - { "Square3x3", new SparseMatrix(3, 3, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f, -3.3f, 2.2f, 6.6f }) }, - { "Square4x4", new SparseMatrix(4, 4, new[] { -1.1f, 0.0f, 1.0f, -4.4f, -2.2f, 1.1f, 2.1f, 5.5f, -3.3f, 2.2f, 6.2f, 6.6f, -4.4f, 3.3f, 4.3f, -7.7f }) }, - { "Tall3x2", new SparseMatrix(3, 2, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f }) }, + { "Singular3x3", new SparseMatrix(3, 3, new float[] { 1, 1, 1, 1, 1, 1, 2, 2, 2 }) }, + { "Square3x3", new SparseMatrix(3, 3, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f, -3.3f, 2.2f, 6.6f }) }, + { "Square4x4", new SparseMatrix(4, 4, new[] { -1.1f, 0.0f, 1.0f, -4.4f, -2.2f, 1.1f, 2.1f, 5.5f, -3.3f, 2.2f, 6.2f, 6.6f, -4.4f, 3.3f, 4.3f, -7.7f }) }, + { "Tall3x2", new SparseMatrix(3, 2, new[] { -1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f }) }, { "Wide2x3", new SparseMatrix(2, 3, new[] { -1.1f, 0.0f, -2.2f, 1.1f, -3.3f, 2.2f }) } }; @@ -127,8 +127,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can create a matrix from two-dimensional array. /// /// Matrix name. - [Test] - public void CanCreateMatrixFrom2DArray([Values("Singular3x3", "Singular4x4", "Square3x3", "Square4x4", "Tall3x2", "Wide2x3")] string name) + [TestCase("Singular3x3")] + [TestCase("Singular4x4")] + [TestCase("Square3x3")] + [TestCase("Square4x4")] + [TestCase("Tall3x2")] + [TestCase("Wide2x3")] + public void CanCreateMatrixFrom2DArray(string name) { var matrix = new SparseMatrix(TestData2D[name]); for (var i = 0; i < TestData2D[name].GetLength(0); i++) @@ -176,8 +181,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Identity with wrong order throws ArgumentOutOfRangeException. /// /// The size of the square matrix - [Test] - public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException([Values(0, -1)] int order) + [TestCase(0)] + [TestCase(-1)] + public void IdentityWithWrongOrderThrowsArgumentOutOfRangeException(int order) { Assert.Throws(() => SparseMatrix.Identity(order)); } @@ -303,10 +309,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [Test] public void CanCreateLargeMatrix() { - const int order = 1000000; - var matrix = new SparseMatrix(order); - Assert.AreEqual(order, matrix.RowCount); - Assert.AreEqual(order, matrix.ColumnCount); + const int Order = 1000000; + var matrix = new SparseMatrix(Order); + Assert.AreEqual(Order, matrix.RowCount); + Assert.AreEqual(Order, matrix.ColumnCount); Assert.DoesNotThrow(() => matrix[0, 0] = 1); } } diff --git a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs index 8ae022e0..d8bc2f9d 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.TextHandling.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -41,8 +41,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// String to parse. /// Expected result. - [Test, Sequential] - public void CanParseSingleSparseVectorsWithInvariant([Values("2", "(3)", "[1,2,3]", " [ 1 , 2 , 3 ] ", " [ -1 , 2 , +3 ] ", " [1.2,3.4 , 5.6] ")] string stringToParse, [Values("2", "3", "1,2,3", "1,2,3", "-1,2,3", "1.2,3.4,5.6")] string expectedToString) + [TestCase("2", "2")] + [TestCase("(3)", "3")] + [TestCase("[1,2,3]", "1,2,3")] + [TestCase(" [ 1 , 2 , 3 ] ", "1,2,3")] + [TestCase(" [ -1 , 2 , +3 ] ", "-1,2,3")] + [TestCase(" [1.2,3.4 , 5.6] ", "1.2,3.4,5.6")] + public void CanParseSingleSparseVectorsWithInvariant(string stringToParse, string expectedToString) { var formatProvider = CultureInfo.InvariantCulture; var vector = SparseVector.Parse(stringToParse, formatProvider); @@ -56,10 +61,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// String to parse. /// Expected result. /// Culture name. - [Test, Sequential] - public void CanParseSingleSparseVectorsWithCulture([Values(" 1.2,3.4 , 5.6 ", " 1.2;3.4 ; 5.6 ", " 1,2;3,4 ; 5,6 ")] string stringToParse, [Values("1.2,3.4,5.6", "1.2;3.4;5.6", "1,2;3,4;5,6")] string expectedToString, [Values("en-US", "de-CH", "de-DE")] string culture) + [TestCase(" 1.2,3.4 , 5.6 ", "1.2,3.4,5.6", "en-US")] + [TestCase(" 1.2;3.4 ; 5.6 ", "1.2;3.4;5.6", "de-CH")] + [TestCase(" 1,2;3,4 ; 5,6 ", "1,2;3,4;5,6", "de-DE")] + public void CanParseSingleSparseVectorsWithCulture(string stringToParse, string expectedToString, string culture) { - var formatProvider = CultureInfo.GetCultureInfo(culture); + var formatProvider = new CultureInfo(culture); var vector = SparseVector.Parse(stringToParse, formatProvider); Assert.AreEqual(expectedToString, vector.ToString(formatProvider)); @@ -69,12 +76,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Can parse float sparse vectors. /// /// Vector as string. - [Test] - public void CanParseSingleSparseVectors([Values("15", "1{0}2{1}3{0}4{1}5{0}6")] string vectorAsString) + [TestCase("15")] + [TestCase("1{0}2{1}3{0}4{1}5{0}6")] + public void CanParseSingleSparseVectors(string vectorAsString) { var mappedString = String.Format( - vectorAsString, - CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, + vectorAsString, + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, CultureInfo.CurrentCulture.TextInfo.ListSeparator); var vector = SparseVector.Parse(mappedString); @@ -100,10 +108,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { var data = new[] { 1.2f, 3.4f, 5.6e-10f }; var text = String.Format( - "{1}{0}{2}{0}{3}", - CultureInfo.CurrentCulture.TextInfo.ListSeparator, - data[0], - data[1], + "{1}{0}{2}{0}{3}", + CultureInfo.CurrentCulture.TextInfo.ListSeparator, + data[0], + data[1], data[2]); SparseVector vector; @@ -120,8 +128,19 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// Try parse a bad value with invariant returns false. /// /// Input string. - [Test] - public void TryParseBadValueWithInvariantReturnsFalse([Values(null, "", ",", "1,", ",1", "1,2,", ",1,2,", "1,,2,,3", "1e+", "1e", "()", "[ ]")] string str) + [TestCase(null)] + [TestCase("")] + [TestCase(",")] + [TestCase("1,")] + [TestCase(",1")] + [TestCase("1,2,")] + [TestCase(",1,2,")] + [TestCase("1,,2,,3")] + [TestCase("1e+")] + [TestCase("1e")] + [TestCase("()")] + [TestCase("[ ]")] + public void TryParseBadValueWithInvariantReturnsFalse(string str) { SparseVector vector; var ret = SparseVector.TryParse(str, CultureInfo.InvariantCulture, out vector); diff --git a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs index 773f5c20..59824af9 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs index d2995509..8c952436 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrixTests.cs b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrixTests.cs index b1b9f4ac..f3f9249a 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrixTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrixTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVector.cs b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVector.cs index 24ed3569..37f0a9e9 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVector.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVector.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVectorTests.cs index f1e5dda9..634e1d67 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedVectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs index 2528c7d7..db6f04f4 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Norm.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Norm.cs index 83838d1d..c8d218c2 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Norm.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Norm.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -69,8 +69,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// The norm index. /// The expected P-norm value. - [Test, Sequential] - public void CanComputeNormP([Values(1, 2, 3, 10)] int p, [Values(15.0f, 7.416198487095663f, 6.0822019955734001f, 5.0540557845353753f)] float expected) + [TestCase(1, 15.0f)] + [TestCase(2, 7.416198487095663f)] + [TestCase(3, 6.0822019955734001f)] + [TestCase(10, 5.0540557845353753f)] + public void CanComputeNormP(int p, float expected) { var vector = CreateVector(Data); AssertHelpers.AlmostEqual(expected, vector.Norm(p), 5); diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs index 40ee40b7..01743042 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -37,7 +37,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Abstract class with the common set of vector tests. /// - [TestFixture] public abstract partial class VectorTests { /// @@ -59,6 +58,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single CollectionAssert.AreEqual(vector, clone); } +#if !SILVERLIGHT /// /// Can clone a vector using IClonable interface method. /// @@ -72,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.AreEqual(vector.Count, clone.Count); CollectionAssert.AreEqual(vector, clone); } - + /// /// Can convert vector to string. /// @@ -84,6 +84,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single var sep = CultureInfo.CurrentCulture.TextInfo.ListSeparator; Assert.AreEqual(string.Format("1{0}2{0}3{0}4{0}5", sep), str); } +#endif /// /// Can copy part of a vector to another vector. @@ -305,8 +306,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Sequential] - public void CanGetSubVector([Values(0, 2, 1)] int index, [Values(5, 2, 4)] int length) + [TestCase(0, 5)] + [TestCase(2, 2)] + [TestCase(1, 4)] + public void CanGetSubVector(int index, int length) { var vector = CreateVector(Data); var sub = vector.SubVector(index, length); @@ -322,8 +325,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// The first element to begin copying from. /// The number of elements to copy. - [Test, Combinatorial] - public void CanGetSubVectorWithWrongValuesShouldThrowException([Values(6, 1)] int index, [Values(10, -10)] int length) + [TestCase(6, 10)] + [TestCase(1, -10)] + public void CanGetSubVectorWithWrongValuesShouldThrowException(int index, int length) { var vector = CreateVector(Data); Assert.Throws(() => vector.SubVector(index, length)); diff --git a/src/UnitTests/NumberTheoryTests/GcdRelatedTest.cs b/src/UnitTests/NumberTheoryTests/GcdRelatedTest.cs index 5c565079..b967f37e 100644 --- a/src/UnitTests/NumberTheoryTests/GcdRelatedTest.cs +++ b/src/UnitTests/NumberTheoryTests/GcdRelatedTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void ListGcdChecksForNullArguments() { Assert.Throws( - typeof(ArgumentNullException), + typeof(ArgumentNullException), () => IntegerTheory.GreatestCommonDivisor((long[])null)); } @@ -195,7 +195,7 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void ListLcmChecksForNullArguments() { Assert.Throws( - typeof(ArgumentNullException), + typeof(ArgumentNullException), () => IntegerTheory.LeastCommonMultiple((long[])null)); } } diff --git a/src/UnitTests/NumberTheoryTests/GcdRelatedTestBigInteger.cs b/src/UnitTests/NumberTheoryTests/GcdRelatedTestBigInteger.cs index cb9e3074..3c12b185 100644 --- a/src/UnitTests/NumberTheoryTests/GcdRelatedTestBigInteger.cs +++ b/src/UnitTests/NumberTheoryTests/GcdRelatedTestBigInteger.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -74,7 +74,9 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests Assert.AreEqual((BigInteger)1, IntegerTheory.GreatestCommonDivisor((BigInteger)Int32.MaxValue, Int64.MaxValue), "Gcd(Int32Max,Int64Max)"); Assert.AreEqual((BigInteger)(1 << 18), IntegerTheory.GreatestCommonDivisor((BigInteger)(1 << 18), 1 << 20), "Gcd(1>>18,1<<20)"); Assert.AreEqual((BigInteger)(1 << 18), IntegerTheory.GreatestCommonDivisor((BigInteger)(1 << 18), 1 << 20), "Gcd(1>>18,1<<20)"); +#if !SILVERLIGHT Assert.AreEqual((BigInteger)4569031055798, IntegerTheory.GreatestCommonDivisor(BigInteger.Parse("7305316061155559483748611586449542122662"), BigInteger.Parse("57377277362010117405715236427413896")), "Gcd(large)"); +#endif } /// @@ -94,12 +96,14 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests Assert.AreEqual((BigInteger)3, IntegerTheory.ExtendedGreatestCommonDivisor(-6, -15, out x, out y), "Egcd(-6,-15)"); Assert.AreEqual((BigInteger)3, (-6 * x) + (-15 * y), "Egcd(-6,-15) -> a*x+b*y"); +#if !SILVERLIGHT var a = BigInteger.Parse("7305316061155559483748611586449542122662"); var b = BigInteger.Parse("57377277362010117405715236427413896"); Assert.AreEqual((BigInteger)4569031055798, IntegerTheory.ExtendedGreatestCommonDivisor(a, b, out x, out y), "Egcd(large)"); Assert.AreEqual((BigInteger)4569031055798, (a * x) + (b * y), "Egcd(large) -> a*x+b*y"); Assert.AreEqual((BigInteger)4569031055798, IntegerTheory.ExtendedGreatestCommonDivisor(-a, b, out x, out y), "Egcd(-large)"); Assert.AreEqual((BigInteger)4569031055798, (-a * x) + (b * y), "Egcd(-large) -> a*x+b*y"); +#endif } /// @@ -132,7 +136,7 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void ListGcdChecksForNullArguments() { Assert.Throws( - typeof(ArgumentNullException), + typeof(ArgumentNullException), () => IntegerTheory.GreatestCommonDivisor((BigInteger[])null)); } @@ -173,7 +177,9 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests Assert.AreEqual((BigInteger)Int64.MaxValue, IntegerTheory.LeastCommonMultiple((BigInteger)Int64.MaxValue, Int64.MaxValue), "Lcm(Int64Max,Int64Max)"); Assert.AreEqual((BigInteger)Int64.MaxValue, IntegerTheory.LeastCommonMultiple((BigInteger)(-Int64.MaxValue), -Int64.MaxValue), "Lcm(-Int64Max,-Int64Max)"); Assert.AreEqual((BigInteger)Int64.MaxValue, IntegerTheory.LeastCommonMultiple((BigInteger)(-Int64.MaxValue), Int64.MaxValue), "Lcm(-Int64Max,Int64Max)"); +#if !SILVERLIGHT Assert.AreEqual(BigInteger.Parse("91739176367857263082719902034485224119528064014300888465614024"), IntegerTheory.LeastCommonMultiple(BigInteger.Parse("7305316061155559483748611586449542122662"), BigInteger.Parse("57377277362010117405715236427413896")), "Lcm(large)"); +#endif } /// @@ -206,7 +212,7 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void ListLcmChecksForNullArguments() { Assert.Throws( - typeof(ArgumentNullException), + typeof(ArgumentNullException), () => IntegerTheory.LeastCommonMultiple((BigInteger[])null)); } } diff --git a/src/UnitTests/NumberTheoryTests/IntegerTheoryTest.cs b/src/UnitTests/NumberTheoryTests/IntegerTheoryTest.cs index 4e3ff516..54afe6ca 100644 --- a/src/UnitTests/NumberTheoryTests/IntegerTheoryTest.cs +++ b/src/UnitTests/NumberTheoryTests/IntegerTheoryTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -231,12 +231,12 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void CeilingToPowerOfTwoThrowsWhenResultWouldOverflow32() { Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => Int32.MaxValue.CeilingToPowerOfTwo()); const int MaxPowerOfTwo = 0x40000000; Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => (MaxPowerOfTwo + 1).CeilingToPowerOfTwo()); Assert.DoesNotThrow( @@ -250,12 +250,12 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void CeilingToPowerOfTwoThrowsWhenResultWouldOverflow64() { Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => Int64.MaxValue.CeilingToPowerOfTwo()); const long MaxPowerOfTwo = 0x4000000000000000; Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => (MaxPowerOfTwo + 1).CeilingToPowerOfTwo()); Assert.DoesNotThrow( @@ -293,19 +293,19 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void PowerOfTwoThrowsWhenOutOfRange32() { Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => (-1).PowerOfTwo()); Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => 31.PowerOfTwo()); Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => Int32.MinValue.PowerOfTwo()); Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => Int32.MaxValue.PowerOfTwo()); Assert.DoesNotThrow( @@ -322,19 +322,19 @@ namespace MathNet.Numerics.UnitTests.NumberTheoryTests public void PowerOfTwoThrowsWhenOutOfRange64() { Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => ((long)-1).PowerOfTwo()); Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => ((long)63).PowerOfTwo()); Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => Int64.MinValue.PowerOfTwo()); Assert.Throws( - typeof(ArgumentOutOfRangeException), + typeof(ArgumentOutOfRangeException), () => Int64.MaxValue.PowerOfTwo()); Assert.DoesNotThrow( diff --git a/src/UnitTests/PermutationTest.cs b/src/UnitTests/PermutationTest.cs index f4de0f2b..c87dfccf 100644 --- a/src/UnitTests/PermutationTest.cs +++ b/src/UnitTests/PermutationTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,8 +39,12 @@ namespace MathNet.Numerics.UnitTests /// Can create permutation. /// /// Permutations index set. - [Test] - public void CanCreatePermutation([Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 })] int[] idx) + [TestCase(new[] { 0 })] + [TestCase(new[] { 0, 1, 2, 3, 4, 5 })] + [TestCase(new[] { 5, 4, 3, 2, 1, 0 })] + [TestCase(new[] { 0, 4, 3, 2, 1, 5 })] + [TestCase(new[] { 0, 3, 2, 1, 4, 5 })] + public void CanCreatePermutation(int[] idx) { new Permutation(idx); } @@ -49,8 +53,10 @@ namespace MathNet.Numerics.UnitTests /// Create permutation fails when given bad index set. /// /// Permutations index set. - [Test] - public void CreatePermutationFailsWhenGivenBadIndexSet([Values(new[] { -1 }, new[] { 0, 1, 2, 3, 4, 4 }, new[] { 5, 4, 3, 2, 1, 7 })] int[] idx) + [TestCase(new[] { -1 })] + [TestCase(new[] { 0, 1, 2, 3, 4, 4 })] + [TestCase(new[] { 5, 4, 3, 2, 1, 7 })] + public void CreatePermutationFailsWhenGivenBadIndexSet(int[] idx) { Assert.Throws(() => new Permutation(idx)); } @@ -59,7 +65,11 @@ namespace MathNet.Numerics.UnitTests /// Can invert permutation. /// /// Permutations index set. - [Test] + [TestCase(new[] { 0 })] + [TestCase(new[] { 0, 1, 2, 3, 4, 5 })] + [TestCase(new[] { 5, 4, 3, 2, 1, 0 })] + [TestCase(new[] { 0, 4, 3, 2, 1, 5 })] + [TestCase(new[] { 0, 3, 2, 1, 4, 5 })] public void CanInvertPermutation([Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 })] int[] idx) { var p = new Permutation(idx); @@ -78,10 +88,13 @@ namespace MathNet.Numerics.UnitTests /// /// Inverse permutations index set. /// Permutations index set. - [Test, Sequential] - public void CanCreatePermutationFromInversions( - [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 3, 4, 5 }, new[] { 0, 4, 3, 3, 4, 5 }, new[] { 0, 3, 2, 3, 4, 5 }, new[] { 2, 2, 2, 4, 4 })] int[] inv, - [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 }, new[] { 1, 2, 0, 4, 3 })] int[] idx) + [TestCase(new[] { 0 }, new[] { 0 })] + [TestCase(new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 1, 2, 3, 4, 5 })] + [TestCase(new[] { 5, 4, 3, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 })] + [TestCase(new[] { 0, 4, 3, 3, 4, 5 }, new[] { 0, 4, 3, 2, 1, 5 })] + [TestCase(new[] { 0, 3, 2, 3, 4, 5 }, new[] { 0, 3, 2, 1, 4, 5 })] + [TestCase(new[] { 2, 2, 2, 4, 4 }, new[] { 1, 2, 0, 4, 3 })] + public void CanCreatePermutationFromInversions(int[] inv, int[] idx) { var p = Permutation.FromInversions(inv); var q = new Permutation(idx); @@ -98,10 +111,13 @@ namespace MathNet.Numerics.UnitTests /// /// Inverse permutations index set. /// Permutations index set. - [Test, Sequential] - public void CanCreateInversionsFromPermutation( - [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 3, 4, 5 }, new[] { 0, 4, 3, 3, 4, 5 }, new[] { 0, 3, 2, 3, 4, 5 }, new[] { 2, 2, 2, 4, 4 })] int[] inv, - [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 }, new[] { 1, 2, 0, 4, 3 })] int[] idx) + [TestCase(new[] { 0 }, new[] { 0 })] + [TestCase(new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 1, 2, 3, 4, 5 })] + [TestCase(new[] { 5, 4, 3, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 })] + [TestCase(new[] { 0, 4, 3, 3, 4, 5 }, new[] { 0, 4, 3, 2, 1, 5 })] + [TestCase(new[] { 0, 3, 2, 3, 4, 5 }, new[] { 0, 3, 2, 1, 4, 5 })] + [TestCase(new[] { 2, 2, 2, 4, 4 }, new[] { 1, 2, 0, 4, 3 })] + public void CanCreateInversionsFromPermutation(int[] inv, int[] idx) { var q = new Permutation(idx); var p = q.ToInversions(); diff --git a/src/UnitTests/PrecisionTest.cs b/src/UnitTests/PrecisionTest.cs index f9496ae2..3c6025f3 100644 --- a/src/UnitTests/PrecisionTest.cs +++ b/src/UnitTests/PrecisionTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -316,11 +316,16 @@ namespace MathNet.Numerics.UnitTests /// Expected minimum. /// Expected maximum. /// Numbers are calculated with the UlpsCalculator program which can be found in UlpsCalculator.cs - [Test, Sequential] - public void RangeOfMatchingFloatingPointNumbersWithPositiveValue( - [Values(0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)] double input, - [Values(-10 * double.Epsilon, 0.99999999999999889, 1.9999999999999978, 2.9999999999999956, 3.9999999999999956, 4.9999999999999911, 5.9999999999999911, 6.9999999999999911, 7.9999999999999911)] double expectedMin, - [Values(10 * double.Epsilon, 1.0000000000000022, 2.0000000000000044, 3.0000000000000044, 4.0000000000000089, 5.0000000000000089, 6.0000000000000089, 7.0000000000000089, 8.0000000000000178)] double expectedMax) + [TestCase(0, -10 * double.Epsilon, 10 * double.Epsilon)] + [TestCase(1.0, 0.99999999999999889, 1.0000000000000022)] + [TestCase(2.0, 1.9999999999999978, 2.0000000000000044)] + [TestCase(3.0, 2.9999999999999956, 3.0000000000000044)] + [TestCase(4.0, 3.9999999999999956, 4.0000000000000089)] + [TestCase(5.0, 4.9999999999999911, 5.0000000000000089)] + [TestCase(6.0, 5.9999999999999911, 6.0000000000000089)] + [TestCase(7.0, 6.9999999999999911, 7.0000000000000089)] + [TestCase(8.0, 7.9999999999999911, 8.0000000000000178)] + public void RangeOfMatchingFloatingPointNumbersWithPositiveValue(double input, double expectedMin, double expectedMax) { double max; double min; @@ -337,11 +342,16 @@ namespace MathNet.Numerics.UnitTests /// Expected minimum. /// Expected maximum. /// Numbers are calculated with the UlpsCalculator program which can be found in UlpsCalculator.cs - [Test, Sequential] - public void RangeOfMatchingFloatingPointNumbersWithNegativeValue( - [Values(0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0)] double input, - [Values(-10 * double.Epsilon, -1.0000000000000022, -2.0000000000000044, -3.0000000000000044, -4.0000000000000089, -5.0000000000000089, -6.0000000000000089, -7.0000000000000089, -8.0000000000000178)] double expectedMin, - [Values(10 * double.Epsilon, -0.99999999999999889, -1.9999999999999978, -2.9999999999999956, -3.9999999999999956, -4.9999999999999911, -5.9999999999999911, -6.9999999999999911, -7.9999999999999911)] double expectedMax) + [TestCase(0, -10 * double.Epsilon, 10 * double.Epsilon)] + [TestCase(-1.0, -1.0000000000000022, -0.99999999999999889)] + [TestCase(-2.0, -2.0000000000000044, -1.9999999999999978)] + [TestCase(-3.0, -3.0000000000000044, -2.9999999999999956)] + [TestCase(-4.0, -4.0000000000000089, -3.9999999999999956)] + [TestCase(-5.0, -5.0000000000000089, -4.9999999999999911)] + [TestCase(-6.0, -6.0000000000000089, -5.9999999999999911)] + [TestCase(-7.0, -7.0000000000000089, -6.9999999999999911)] + [TestCase(-8.0, -8.0000000000000178, -7.9999999999999911)] + public void RangeOfMatchingFloatingPointNumbersWithNegativeValue(double input, double expectedMin, double expectedMax) { double max; double min; @@ -356,10 +366,16 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected maximum. - [Test, Sequential] - public void MaximumMatchingFloatingPointNumberWithPositiveValue( - [Values(0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)] double input, - [Values(10 * double.Epsilon, 1.0000000000000022, 2.0000000000000044, 3.0000000000000044, 4.0000000000000089, 5.0000000000000089, 6.0000000000000089, 7.0000000000000089, 8.0000000000000178)] double expectedMax) + [TestCase(0, 10 * double.Epsilon)] + [TestCase(1.0, 1.0000000000000022)] + [TestCase(2.0, 2.0000000000000044)] + [TestCase(3.0, 3.0000000000000044)] + [TestCase(4.0, 4.0000000000000089)] + [TestCase(5.0, 5.0000000000000089)] + [TestCase(6.0, 6.0000000000000089)] + [TestCase(7.0, 7.0000000000000089)] + [TestCase(8.0, 8.0000000000000178)] + public void MaximumMatchingFloatingPointNumberWithPositiveValue(double input, double expectedMax) { var max = input.MaximumMatchingFloatingPointNumber(10); Assert.AreEqual(expectedMax, max); @@ -370,10 +386,16 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected maximum. - [Test, Sequential] - public void MaximumMatchingFloatingPointNumberWithNegativeValue( - [Values(0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0)] double input, - [Values(10 * double.Epsilon, -0.99999999999999889, -1.9999999999999978, -2.9999999999999956, -3.9999999999999956, -4.9999999999999911, -5.9999999999999911, -6.9999999999999911, -7.9999999999999911)] double expectedMax) + [TestCase(0, 10 * double.Epsilon)] + [TestCase(-1.0, -0.99999999999999889)] + [TestCase(-2.0, -1.9999999999999978)] + [TestCase(-3.0, -2.9999999999999956)] + [TestCase(-4.0, -3.9999999999999956)] + [TestCase(-5.0, -4.9999999999999911)] + [TestCase(-6.0, -5.9999999999999911)] + [TestCase(-7.0, -6.9999999999999911)] + [TestCase(-8.0, -7.9999999999999911)] + public void MaximumMatchingFloatingPointNumberWithNegativeValue(double input, double expectedMax) { var max = input.MaximumMatchingFloatingPointNumber(10); Assert.AreEqual(expectedMax, max); @@ -384,10 +406,16 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected minimum. - [Test, Sequential] - public void MinimumMatchingFloatingPointNumberWithPositiveValue( - [Values(0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)] double input, - [Values(-10 * double.Epsilon, 0.99999999999999889, 1.9999999999999978, 2.9999999999999956, 3.9999999999999956, 4.9999999999999911, 5.9999999999999911, 6.9999999999999911, 7.9999999999999911)] double expectedMin) + [TestCase(0, -10 * double.Epsilon)] + [TestCase(1.0, 0.99999999999999889)] + [TestCase(2.0, 1.9999999999999978)] + [TestCase(3.0, 2.9999999999999956)] + [TestCase(4.0, 3.9999999999999956)] + [TestCase(5.0, 4.9999999999999911)] + [TestCase(6.0, 5.9999999999999911)] + [TestCase(7.0, 6.9999999999999911)] + [TestCase(8.0, 7.9999999999999911)] + public void MinimumMatchingFloatingPointNumberWithPositiveValue(double input, double expectedMin) { var min = input.MinimumMatchingFloatingPointNumber(10); Assert.AreEqual(expectedMin, min); @@ -398,10 +426,16 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected minimum. - [Test, Sequential] - public void MinimumMatchingFloatingPointNumberWithNegativeValue( - [Values(0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0)] double input, - [Values(-10 * double.Epsilon, -1.0000000000000022, -2.0000000000000044, -3.0000000000000044, -4.0000000000000089, -5.0000000000000089, -6.0000000000000089, -7.0000000000000089, -8.0000000000000178)] double expectedMin) + [TestCase(0, -10 * double.Epsilon)] + [TestCase(-1.0, -1.0000000000000022)] + [TestCase(-2.0, -2.0000000000000044)] + [TestCase(-3.0, -3.0000000000000044)] + [TestCase(-4.0, -4.0000000000000089)] + [TestCase(-5.0, -5.0000000000000089)] + [TestCase(-6.0, -6.0000000000000089)] + [TestCase(-7.0, -7.0000000000000089)] + [TestCase(-8.0, -8.0000000000000178)] + public void MinimumMatchingFloatingPointNumberWithNegativeValue(double input, double expectedMin) { var min = input.MinimumMatchingFloatingPointNumber(10); Assert.AreEqual(expectedMin, min); @@ -447,12 +481,16 @@ namespace MathNet.Numerics.UnitTests /// Relative difference value. /// Expected minimum. /// Expected maximum. - [Test, Sequential] - public void RangeOfMatchingUlpsWithPositiveValue( - [Values(0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)] double input, - [Values(10 * double.Epsilon, (1.0000000000000022 - 1.0) / 1.0, (2.0000000000000044 - 2.0) / 2.0, (3.0000000000000044 - 3.0) / 3.0, (4.0000000000000089 - 4.0) / 4.0, (5.0000000000000089 - 5.0) / 5.0, (6.0000000000000089 - 6.0) / 6.0, (7.0000000000000089 - 7.0) / 7.0, (8.0000000000000178 - 8.0) / 8.0)] double relativeDifference, - [Values(10, 20, 20, 10, 20, 10, 10, 10, 20)] long expectedMin, - [Values(10, 10, 10, 10, 10, 10, 10, 10, 10)] long expectedMax) + [TestCase(0, 10 * double.Epsilon, 10, 10)] + [TestCase(1.0, (1.0000000000000022 - 1.0) / 1.0, 20, 10)] + [TestCase(2.0, (2.0000000000000044 - 2.0) / 2.0, 20, 10)] + [TestCase(3.0, (3.0000000000000044 - 3.0) / 3.0, 10, 10)] + [TestCase(4.0, (4.0000000000000089 - 4.0) / 4.0, 20, 10)] + [TestCase(5.0, (5.0000000000000089 - 5.0) / 5.0, 10, 10)] + [TestCase(6.0, (6.0000000000000089 - 6.0) / 6.0, 10, 10)] + [TestCase(7.0, (7.0000000000000089 - 7.0) / 7.0, 10, 10)] + [TestCase(8.0, (8.0000000000000178 - 8.0) / 8.0, 20, 10)] + public void RangeOfMatchingUlpsWithPositiveValue(double input, double relativeDifference, long expectedMin, long expectedMax) { long min; long max; @@ -469,12 +507,16 @@ namespace MathNet.Numerics.UnitTests /// Relative difference value. /// Expected minimum. /// Expected maximum. - [Test, Sequential] - public void RangeOfMatchingUlpsWithNegativeValue( - [Values(0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0)] double input, - [Values(10 * double.Epsilon, (1.0000000000000022 - 1.0) / 1.0, (2.0000000000000044 - 2.0) / 2.0, (3.0000000000000044 - 3.0) / 3.0, (4.0000000000000089 - 4.0) / 4.0, (5.0000000000000089 - 5.0) / 5.0, (6.0000000000000089 - 6.0) / 6.0, (7.0000000000000089 - 7.0) / 7.0, (8.0000000000000178 - 8.0) / 8.0)] double relativeDifference, - [Values(10, 10, 10, 10, 10, 10, 10, 10, 10)] long expectedMin, - [Values(10, 20, 20, 10, 20, 10, 10, 10, 20)] long expectedMax) + [TestCase(0, 10 * double.Epsilon, 10, 10)] + [TestCase(-1.0, (1.0000000000000022 - 1.0) / 1.0, 10, 20)] + [TestCase(-2.0, (2.0000000000000044 - 2.0) / 2.0, 10, 20)] + [TestCase(-3.0, (3.0000000000000044 - 3.0) / 3.0, 10, 10)] + [TestCase(-4.0, (4.0000000000000089 - 4.0) / 4.0, 10, 20)] + [TestCase(-5.0, (5.0000000000000089 - 5.0) / 5.0, 10, 10)] + [TestCase(-6.0, (6.0000000000000089 - 6.0) / 6.0, 10, 10)] + [TestCase(-7.0, (7.0000000000000089 - 7.0) / 7.0, 10, 10)] + [TestCase(-8.0, (8.0000000000000178 - 8.0) / 8.0, 10, 20)] + public void RangeOfMatchingUlpsWithNegativeValue(double input, double relativeDifference, long expectedMin, long expectedMax) { long min; long max; diff --git a/src/UnitTests/Properties/AssemblyInfo.cs b/src/UnitTests/Properties/AssemblyInfo.cs index 901fbe63..006f665d 100644 --- a/src/UnitTests/Properties/AssemblyInfo.cs +++ b/src/UnitTests/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/UnitTests/Properties/Settings.Designer.cs b/src/UnitTests/Properties/Settings.Designer.cs index 8ea6bbd8..67f5520f 100644 --- a/src/UnitTests/Properties/Settings.Designer.cs +++ b/src/UnitTests/Properties/Settings.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.225 diff --git a/src/UnitTests/Random/Mcg31m1Tests.cs b/src/UnitTests/Random/Mcg31m1Tests.cs index 0922c25b..477aee40 100644 --- a/src/UnitTests/Random/Mcg31m1Tests.cs +++ b/src/UnitTests/Random/Mcg31m1Tests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/Mcg59Tests.cs b/src/UnitTests/Random/Mcg59Tests.cs index 9211cae4..7902c174 100644 --- a/src/UnitTests/Random/Mcg59Tests.cs +++ b/src/UnitTests/Random/Mcg59Tests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/MersenneTwisterTests.cs b/src/UnitTests/Random/MersenneTwisterTests.cs index 12aa563e..1d239ce8 100644 --- a/src/UnitTests/Random/MersenneTwisterTests.cs +++ b/src/UnitTests/Random/MersenneTwisterTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/Mrg32k3aTests.cs b/src/UnitTests/Random/Mrg32k3aTests.cs index cb3d88bf..258fb99b 100644 --- a/src/UnitTests/Random/Mrg32k3aTests.cs +++ b/src/UnitTests/Random/Mrg32k3aTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/PalfTests.cs b/src/UnitTests/Random/PalfTests.cs index a5517a73..abcb147c 100644 --- a/src/UnitTests/Random/PalfTests.cs +++ b/src/UnitTests/Random/PalfTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/RandomTests.cs b/src/UnitTests/Random/RandomTests.cs index f88651f2..5740bfc7 100644 --- a/src/UnitTests/Random/RandomTests.cs +++ b/src/UnitTests/Random/RandomTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/SystemCryptoTests.cs b/src/UnitTests/Random/SystemCryptoTests.cs index 59c11890..830f9a45 100644 --- a/src/UnitTests/Random/SystemCryptoTests.cs +++ b/src/UnitTests/Random/SystemCryptoTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/SystemRandomExtensionTests.cs b/src/UnitTests/Random/SystemRandomExtensionTests.cs index 58752e06..7e9bf07d 100644 --- a/src/UnitTests/Random/SystemRandomExtensionTests.cs +++ b/src/UnitTests/Random/SystemRandomExtensionTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/WH1982Tests.cs b/src/UnitTests/Random/WH1982Tests.cs index e115e369..539dc0df 100644 --- a/src/UnitTests/Random/WH1982Tests.cs +++ b/src/UnitTests/Random/WH1982Tests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/WH2006Tests.cs b/src/UnitTests/Random/WH2006Tests.cs index d940515d..07fff82c 100644 --- a/src/UnitTests/Random/WH2006Tests.cs +++ b/src/UnitTests/Random/WH2006Tests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Random/XorshiftTests.cs b/src/UnitTests/Random/XorshiftTests.cs index 8329af86..6703d193 100644 --- a/src/UnitTests/Random/XorshiftTests.cs +++ b/src/UnitTests/Random/XorshiftTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/Setup.cs b/src/UnitTests/Setup.cs index 8d588224..18231463 100644 --- a/src/UnitTests/Setup.cs +++ b/src/UnitTests/Setup.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/SortingTests.cs b/src/UnitTests/SortingTests.cs index 748f2f5a..7fe5133d 100644 --- a/src/UnitTests/SortingTests.cs +++ b/src/UnitTests/SortingTests.cs @@ -160,7 +160,7 @@ namespace MathNet.Numerics.UnitTests // default sorting (Ascending) list.Sort(); - + // just check that the order is as expected, not that the items are correct for (var i = 1; i < list.Count; i++) { diff --git a/src/UnitTests/SpecialFunctionsTests/ErfTests.cs b/src/UnitTests/SpecialFunctionsTests/ErfTests.cs index 8160126b..bca2f68d 100644 --- a/src/UnitTests/SpecialFunctionsTests/ErfTests.cs +++ b/src/UnitTests/SpecialFunctionsTests/ErfTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,10 +39,26 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input value. /// Function result. - [Test, Sequential] - public void ErfCanMatchLargePrecision( - [Values(double.NaN, -1.0, 0.0, 1e-15, 0.1, 0.2, 0.3, 0.4, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, double.PositiveInfinity, double.NegativeInfinity)] double x, - [Values(double.NaN, -0.84270079294971486934122063508260925929606699796630291, 0.0, 0.0000000000000011283791670955126615773132947717431253912942469337536, 0.1124629160182848984047122510143040617233925185058162, 0.22270258921047846617645303120925671669511570710081967, 0.32862675945912741618961798531820303325847175931290341, 0.42839235504666847645410962730772853743532927705981257, 0.5204998778130465376827466538919645287364515757579637, 0.84270079294971486934122063508260925929606699796630291, 0.96610514647531072706697626164594785868141047925763678, 0.99532226501895273416206925636725292861089179704006008, 0.99959304798255504106043578426002508727965132259628658, 0.99997790950300141455862722387041767962015229291260075, 0.99999998458274209971998114784032651311595142785474641, 0.99999999999846254020557196514981165651461662110988195, 0.99999999999999997848026328750108688340664960081261537, 1.0, -1.0)] double f) + [TestCase(double.NaN, double.NaN)] + [TestCase(-1.0, -0.84270079294971486934122063508260925929606699796630291)] + [TestCase(0.0, 0.0)] + [TestCase(1e-15, 0.0000000000000011283791670955126615773132947717431253912942469337536)] + [TestCase(0.1, 0.1124629160182848984047122510143040617233925185058162)] + [TestCase(0.2, 0.22270258921047846617645303120925671669511570710081967)] + [TestCase(0.3, 0.32862675945912741618961798531820303325847175931290341)] + [TestCase(0.4, 0.42839235504666847645410962730772853743532927705981257)] + [TestCase(0.5, 0.5204998778130465376827466538919645287364515757579637)] + [TestCase(1.0, 0.84270079294971486934122063508260925929606699796630291)] + [TestCase(1.5, 0.96610514647531072706697626164594785868141047925763678)] + [TestCase(2.0, 0.99532226501895273416206925636725292861089179704006008)] + [TestCase(2.5, 0.99959304798255504106043578426002508727965132259628658)] + [TestCase(3.0, 0.99997790950300141455862722387041767962015229291260075)] + [TestCase(4.0, 0.99999998458274209971998114784032651311595142785474641)] + [TestCase(5.0, 0.99999999999846254020557196514981165651461662110988195)] + [TestCase(6.0, 0.99999999999999997848026328750108688340664960081261537)] + [TestCase(double.PositiveInfinity, 1.0)] + [TestCase(double.NegativeInfinity, -1.0)] + public void ErfCanMatchLargePrecision(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.Erf(x), 15); } @@ -52,10 +68,31 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input value. /// Function result. - [Test, Sequential] - public void ErfcCanMatchLargePrecision( - [Values(double.NaN, -1.0, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 10.0, 15.0, 20.0, 30.0, 50.0, 80.0, double.PositiveInfinity, double.NegativeInfinity)] double x, - [Values(double.NaN, 1.8427007929497148693412206350826092592960669979663028, 1.0, 0.88753708398171510159528774898569593827660748149418343, 0.77729741078952153382354696879074328330488429289918085, 0.67137324054087258381038201468179696674152824068709621, 0.57160764495333152354589037269227146256467072294018715, 0.47950012218695346231725334610803547126354842424203654, 0.15729920705028513065877936491739074070393300203369719, 0.033894853524689272933023738354052141318589520742363247, 0.0046777349810472658379307436327470713891082029599399245, 0.00040695201744495893956421573997491272034867740371342016, 0.00002209049699858544137277612958232037984770708739924966, 0.000000015417257900280018852159673486884048572145253589191167, 0.0000000000015374597944280348501883434853833788901180503147233804, 2.1519736712498913116593350399187384630477514061688559e-17, 2.0884875837625447570007862949577886115608181193211634e-45, 7.2129941724512066665650665586929271099340909298253858e-100, 5.3958656116079009289349991679053456040882726709236071e-176, 2.5646562037561116000333972775014471465488897227786155e-393, 2.0709207788416560484484478751657887929322509209953988e-1088, 2.3100265595063985852034904366341042118385080919280966e-2782, 0.0, 2.0)] double f) + [TestCase(double.NaN, double.NaN)] + [TestCase(-1.0, 1.8427007929497148693412206350826092592960669979663028)] + [TestCase(0.0, 1.0)] + [TestCase(0.1, 0.88753708398171510159528774898569593827660748149418343)] + [TestCase(0.2, 0.77729741078952153382354696879074328330488429289918085)] + [TestCase(0.3, 0.67137324054087258381038201468179696674152824068709621)] + [TestCase(0.4, 0.57160764495333152354589037269227146256467072294018715)] + [TestCase(0.5, 0.47950012218695346231725334610803547126354842424203654)] + [TestCase(1.0, 0.15729920705028513065877936491739074070393300203369719)] + [TestCase(1.5, 0.033894853524689272933023738354052141318589520742363247)] + [TestCase(2.0, 0.0046777349810472658379307436327470713891082029599399245)] + [TestCase(2.5, 0.00040695201744495893956421573997491272034867740371342016)] + [TestCase(3.0, 0.00002209049699858544137277612958232037984770708739924966)] + [TestCase(4.0, 0.000000015417257900280018852159673486884048572145253589191167)] + [TestCase(5.0, 0.0000000000015374597944280348501883434853833788901180503147233804)] + [TestCase(6.0, 2.1519736712498913116593350399187384630477514061688559e-17)] + [TestCase(10.0, 2.0884875837625447570007862949577886115608181193211634e-45)] + [TestCase(15.0, 7.2129941724512066665650665586929271099340909298253858e-100)] + [TestCase(20.0, 5.3958656116079009289349991679053456040882726709236071e-176)] + [TestCase(30.0, 2.5646562037561116000333972775014471465488897227786155e-393)] + [TestCase(50.0, 2.0709207788416560484484478751657887929322509209953988e-1088)] + [TestCase(80.0, 2.3100265595063985852034904366341042118385080919280966e-2782)] + [TestCase(double.PositiveInfinity, 0.0)] + [TestCase(double.NegativeInfinity, 2.0)] + public void ErfcCanMatchLargePrecision(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.Erfc(x), 13); } @@ -65,10 +102,19 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input value. /// Function result. - [Test, Sequential] - public void ErfcInvCanMatchLargePrecision( - [Values(0.0, 1e-100, 1e-30, 1e-20, 1e-10, 1e-5, 0.1, 0.2, 0.5, 1.0, 1.5, 2.0)] double x, - [Values(double.PositiveInfinity, 15.065574702593, 8.1486162231699, 6.6015806223551, 4.5728249585449249378479309946884581365517663258840893, 3.1234132743415708640270717579666062107939039971365252, 1.1630871536766741628440954340547000483801487126688552, 0.90619380243682330953597079527631536107443494091638384, 0.47693627620446987338141835364313055980896974905947083, 0.0, -0.47693627620446987338141835364313055980896974905947083, double.NegativeInfinity)] double f) + [TestCase(0.0, double.PositiveInfinity)] + [TestCase(1e-100, 15.065574702593)] + [TestCase(1e-30, 8.1486162231699)] + [TestCase(1e-20, 6.6015806223551)] + [TestCase(1e-10, 4.5728249585449249378479309946884581365517663258840893)] + [TestCase(1e-5, 3.1234132743415708640270717579666062107939039971365252)] + [TestCase(0.1, 1.1630871536766741628440954340547000483801487126688552)] + [TestCase(0.2, 0.90619380243682330953597079527631536107443494091638384)] + [TestCase(0.5, 0.47693627620446987338141835364313055980896974905947083)] + [TestCase(1.0, 0.0)] + [TestCase(1.5, -0.47693627620446987338141835364313055980896974905947083)] + [TestCase(2.0, double.NegativeInfinity)] + public void ErfcInvCanMatchLargePrecision(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.ErfcInv(x), 8); } @@ -78,10 +124,25 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input value. /// Function result. - [Test, Sequential] - public void ErfInv( - [Values(double.NaN, -1.0, 0.0, 1e-15, 0.1, 0.2, 0.3, 0.4, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, double.PositiveInfinity, double.NegativeInfinity)] double x, - [Values(double.NaN, -0.84270079294971486934122063508260925929606699796630291, 0.0, 0.0000000000000011283791670955126615773132947717431253912942469337536, 0.1124629160182848984047122510143040617233925185058162, 0.22270258921047846617645303120925671669511570710081967, 0.32862675945912741618961798531820303325847175931290341, 0.42839235504666847645410962730772853743532927705981257, 0.5204998778130465376827466538919645287364515757579637, 0.84270079294971486934122063508260925929606699796630291, 0.96610514647531072706697626164594785868141047925763678, 0.99532226501895273416206925636725292861089179704006008, 0.99959304798255504106043578426002508727965132259628658, 0.99997790950300141455862722387041767962015229291260075, 0.99999998458274209971998114784032651311595142785474641, 0.99999999999846254020557196514981165651461662110988195, 1.0, -1.0)] double f) + [TestCase(double.NaN, double.NaN)] + [TestCase(-1.0, -0.84270079294971486934122063508260925929606699796630291)] + [TestCase(0.0, 0.0)] + [TestCase(1e-15, 0.0000000000000011283791670955126615773132947717431253912942469337536)] + [TestCase(0.1, 0.1124629160182848984047122510143040617233925185058162)] + [TestCase(0.2, 0.22270258921047846617645303120925671669511570710081967)] + [TestCase(0.3, 0.32862675945912741618961798531820303325847175931290341)] + [TestCase(0.4, 0.42839235504666847645410962730772853743532927705981257)] + [TestCase(0.5, 0.5204998778130465376827466538919645287364515757579637)] + [TestCase(1.0, 0.84270079294971486934122063508260925929606699796630291)] + [TestCase(1.5, 0.96610514647531072706697626164594785868141047925763678)] + [TestCase(2.0, 0.99532226501895273416206925636725292861089179704006008)] + [TestCase(2.5, 0.99959304798255504106043578426002508727965132259628658)] + [TestCase(3.0, 0.99997790950300141455862722387041767962015229291260075)] + [TestCase(4.0, 0.99999998458274209971998114784032651311595142785474641)] + [TestCase(5.0, 0.99999999999846254020557196514981165651461662110988195)] + [TestCase(double.PositiveInfinity, 1.0)] + [TestCase(double.NegativeInfinity, -1.0)] + public void ErfInv(double x, double f) { AssertHelpers.AlmostEqual(x, SpecialFunctions.ErfInv(f), 6); } diff --git a/src/UnitTests/SpecialFunctionsTests/GammaTests.cs b/src/UnitTests/SpecialFunctionsTests/GammaTests.cs index 60cc0277..690e8e83 100644 --- a/src/UnitTests/SpecialFunctionsTests/GammaTests.cs +++ b/src/UnitTests/SpecialFunctionsTests/GammaTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,10 +39,22 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input X value. /// Function result. - [Test, Sequential] - public void GammaLn( - [Values(Double.NaN, 0.1, 1.0, 1.5, Constants.Pi / 2, 2.0, 2.5, 3.0, Constants.Pi, 3.5, 4.0, 4.5, 5.0, 5.5, 10.1)] double x, - [Values(Double.NaN, 2.2527126517342059020062379568954763844479865649307379, 0.0, -0.12078223763524522234551844578164721225185272790259947, -0.11590380084550241329912089415904874214542604767006895, 0.0, 0.28468287047291915963249466968270192432013769555989498, 0.693147180559945309417232121458176568075500134360255, 0.82769459232343710152957855845235995115350173412073715, 1.2009736023470742248160218814507129957702389154681574, 1.7917594692280550008124773583807022727229906921830034, 2.4537365708424422205041425034357161573318235106897606, 3.1780538303479456196469416012970554088739909609035161, 3.9578139676187162938774008558225909985513044919750065, 13.02752673863323715481371189614224148681183971709386)] double f) + [TestCase(Double.NaN, Double.NaN)] + [TestCase(0.1, 2.2527126517342059020062379568954763844479865649307379)] + [TestCase(1.0, 0.0)] + [TestCase(1.5, -0.12078223763524522234551844578164721225185272790259947)] + [TestCase(Constants.Pi / 2, -0.11590380084550241329912089415904874214542604767006895)] + [TestCase(2.0, 0.0)] + [TestCase(2.5, 0.28468287047291915963249466968270192432013769555989498)] + [TestCase(3.0, 0.693147180559945309417232121458176568075500134360255)] + [TestCase(Constants.Pi, 0.82769459232343710152957855845235995115350173412073715)] + [TestCase(3.5, 1.2009736023470742248160218814507129957702389154681574)] + [TestCase(4.0, 1.7917594692280550008124773583807022727229906921830034)] + [TestCase(4.5, 2.4537365708424422205041425034357161573318235106897606)] + [TestCase(5.0, 3.1780538303479456196469416012970554088739909609035161)] + [TestCase(5.5, 3.9578139676187162938774008558225909985513044919750065)] + [TestCase(10.1, 13.02752673863323715481371189614224148681183971709386)] + public void GammaLn(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.GammaLn(x), 14); } @@ -52,10 +64,24 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input X value. /// Function result. - [Test, Sequential] - public void Gamma( - [Values(Double.NaN, -1.5, -0.5, 0.1, 1.0, 1.5, Constants.Pi / 2, 2.0, 2.5, 3.0, Constants.Pi, 3.5, 4.0, 4.5, 5.0, 5.5, 10.1)] double x, - [Values(Double.NaN, 2.3632718012073547030642233111215269103967326081631802, -3.544907701811032054596334966682290365595098912244773, 9.5135076986687312858079798958252325009137161063903012, 1.0, 0.88622692545275801364908374167057259139877472806119326, 0.89056089038153932801065963535912100593354196288475879, 1.0, 1.3293403881791370204736256125058588870981620920917912, 2.0, 2.2880377953400324179595889090602339228896881533562229, 3.3233509704478425511840640312646472177454052302294767, 6.0, 11.631728396567448929144224109426265262108918305803166, 24.0, 52.342777784553520181149008492418193679490132376114268, 454760.75144158558537612486797710217749925965322893332)] double f) + [TestCase(Double.NaN, Double.NaN)] + [TestCase(-1.5, 2.3632718012073547030642233111215269103967326081631802)] + [TestCase(-0.5, -3.544907701811032054596334966682290365595098912244773)] + [TestCase(0.1, 9.5135076986687312858079798958252325009137161063903012)] + [TestCase(1.0, 1.0)] + [TestCase(1.5, 0.88622692545275801364908374167057259139877472806119326)] + [TestCase(Constants.Pi / 2, 0.89056089038153932801065963535912100593354196288475879)] + [TestCase(2.0, 1.0)] + [TestCase(2.5, 1.3293403881791370204736256125058588870981620920917912)] + [TestCase(3.0, 2.0)] + [TestCase(Constants.Pi, 2.2880377953400324179595889090602339228896881533562229)] + [TestCase(3.5, 3.3233509704478425511840640312646472177454052302294767)] + [TestCase(4.0, 6.0)] + [TestCase(4.5, 11.631728396567448929144224109426265262108918305803166)] + [TestCase(5.0, 24.0)] + [TestCase(5.5, 52.342777784553520181149008492418193679490132376114268)] + [TestCase(10.1, 454760.75144158558537612486797710217749925965322893332)] + public void Gamma(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.Gamma(x), 13); } @@ -66,11 +92,20 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// Value of A parameter. /// Input X value. /// Function result. - [Test, Sequential] - public void GammaLowerRegularized( - [Values(double.NaN, 0.1, 0.1, 0.1, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5, 5.5, 5.5, 5.5)] double a, - [Values(Double.NaN, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0)] double x, - [Values(Double.NaN, 0.97587265627367222115949155252812057714751052498477013, 0.99432617602018847196075251078067514034772764693462125, 0.99999507519205198048686442150578226823401842046310854, 0.42759329552912016600095238564127189392715996802703368, 0.73853587005088937779717792402407879809718939080920993, 0.99886601571021467734329986257903021041757398191304284, 0.15085496391539036377410688601371365034788861473418704, 0.45058404864721976739416885516693969548484517509263197, 0.99315592607757956900093935107222761316136944145439676, 0.0015041182825838038421585211353488839717739161316985392, 0.030082976121226050615171484772387355162056796585883967, 0.85886911973294184646060071855669224657735916933487681)] double f) + [TestCase(double.NaN, Double.NaN, Double.NaN)] + [TestCase(0.1, 1.0, 0.97587265627367222115949155252812057714751052498477013)] + [TestCase(0.1, 2.0, 0.99432617602018847196075251078067514034772764693462125)] + [TestCase(0.1, 8.0, 0.99999507519205198048686442150578226823401842046310854)] + [TestCase(1.5, 1.0, 0.42759329552912016600095238564127189392715996802703368)] + [TestCase(1.5, 2.0, 0.73853587005088937779717792402407879809718939080920993)] + [TestCase(1.5, 8.0, 0.99886601571021467734329986257903021041757398191304284)] + [TestCase(2.5, 1.0, 0.15085496391539036377410688601371365034788861473418704)] + [TestCase(2.5, 2.0, 0.45058404864721976739416885516693969548484517509263197)] + [TestCase(2.5, 8.0, 0.99315592607757956900093935107222761316136944145439676)] + [TestCase(5.5, 1.0, 0.0015041182825838038421585211353488839717739161316985392)] + [TestCase(5.5, 2.0, 0.030082976121226050615171484772387355162056796585883967)] + [TestCase(5.5, 8.0, 0.85886911973294184646060071855669224657735916933487681)] + public void GammaLowerRegularized(double a, double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.GammaLowerRegularized(a, x), 14); } @@ -81,11 +116,20 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// Value of A parameter. /// Input X value. /// Function result. - [Test, Sequential] - public void GammaLowerIncomplete( - [Values(double.NaN, 0.1, 0.1, 0.1, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5, 5.5, 5.5, 5.5)] double a, - [Values(Double.NaN, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0)] double x, - [Values(Double.NaN, 9.2839720283798852469443229940217320532607158711056334, 9.4595297305559030536119885480983751098528458886962883, 9.5134608464704033372127589212547718314010339263844976, 0.37894469164098470380394366597039213790868855578083847, 0.65451037345177732033319477475056262302270310457635612, 0.88522195804210983776635107858848816480298923071075222, 0.20053759629003473411039172879412733941722170263949, 0.59897957413602228465664030130712917348327070206302442, 1.3202422842943799358198434659248530581833764879301293, 0.078729729026968321691794205337720556329618007004848672, 1.5746265342113649473739798668921124454837064926448459, 44.955595480196465884619737757794960132425035578313584)] double f) + [TestCase(double.NaN, Double.NaN, Double.NaN)] + [TestCase(0.1, 1.0, 9.2839720283798852469443229940217320532607158711056334)] + [TestCase(0.1, 2.0, 9.4595297305559030536119885480983751098528458886962883)] + [TestCase(0.1, 8.0, 9.5134608464704033372127589212547718314010339263844976)] + [TestCase(1.5, 1.0, 0.37894469164098470380394366597039213790868855578083847)] + [TestCase(1.5, 2.0, 0.65451037345177732033319477475056262302270310457635612)] + [TestCase(1.5, 8.0, 0.88522195804210983776635107858848816480298923071075222)] + [TestCase(2.5, 1.0, 0.20053759629003473411039172879412733941722170263949)] + [TestCase(2.5, 2.0, 0.59897957413602228465664030130712917348327070206302442)] + [TestCase(2.5, 8.0, 1.3202422842943799358198434659248530581833764879301293)] + [TestCase(5.5, 1.0, 0.078729729026968321691794205337720556329618007004848672)] + [TestCase(5.5, 2.0, 1.5746265342113649473739798668921124454837064926448459)] + [TestCase(5.5, 8.0, 44.955595480196465884619737757794960132425035578313584)] + public void GammaLowerIncomplete(double a, double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.GammaLowerIncomplete(a, x), 14); } @@ -96,11 +140,20 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// Value of A parameter. /// Input X value. /// Function result. - [Test, Sequential] - public void GammaUpperRegularized( - [Values(double.NaN, 0.1, 0.1, 0.1, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5, 5.5, 5.5, 5.5)] double a, - [Values(Double.NaN, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0)] double x, - [Values(Double.NaN, 0.024127343726327778840508447471879422852489475015229, 0.0056738239798115280392474892193248596522723530653781, 0.0000049248079480195131355784942177317659815795368919702, 0.57240670447087983399904761435872810607284003197297, 0.26146412994911062220282207597592120190281060919079, 0.0011339842897853226567001374209697895824260180869567, 0.84914503608460963622589311398628634965211138526581, 0.54941595135278023260583114483306030451515482490737, 0.0068440739224204309990606489277723868386305585456026, 0.9984958817174161961578414788646511160282260838683, 0.96991702387877394938482851522761264483794320341412, 0.14113088026705815353939928144330775342264083066512)] double f) + [TestCase(double.NaN, Double.NaN, Double.NaN)] + [TestCase(0.1, 1.0, 0.024127343726327778840508447471879422852489475015229)] + [TestCase(0.1, 2.0, 0.0056738239798115280392474892193248596522723530653781)] + [TestCase(0.1, 8.0, 0.0000049248079480195131355784942177317659815795368919702)] + [TestCase(1.5, 1.0, 0.57240670447087983399904761435872810607284003197297)] + [TestCase(1.5, 2.0, 0.26146412994911062220282207597592120190281060919079)] + [TestCase(1.5, 8.0, 0.0011339842897853226567001374209697895824260180869567)] + [TestCase(2.5, 1.0, 0.84914503608460963622589311398628634965211138526581)] + [TestCase(2.5, 2.0, 0.54941595135278023260583114483306030451515482490737)] + [TestCase(2.5, 8.0, 0.0068440739224204309990606489277723868386305585456026)] + [TestCase(5.5, 1.0, 0.9984958817174161961578414788646511160282260838683)] + [TestCase(5.5, 2.0, 0.96991702387877394938482851522761264483794320341412)] + [TestCase(5.5, 8.0, 0.14113088026705815353939928144330775342264083066512)] + public void GammaUpperRegularized(double a, double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.GammaUpperRegularized(a, x), 14); } @@ -111,11 +164,20 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// Value of A parameter. /// Input X value. /// Function result. - [Test, Sequential] - public void GammaUpperIncomplete( - [Values(double.NaN, 0.1, 0.1, 0.1, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5, 5.5, 5.5, 5.5)] double a, - [Values(Double.NaN, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0, 1.0, 2.0, 8.0)] double x, - [Values(Double.NaN, 0.22953567028884603886365690180350044765300023528467, 0.053977968112828232195991347726857391060870217694027, 0.000046852198327948595220974570460669512682180005810156, 0.50728223381177330984514007570018045349008617228036, 0.23171655200098069331588896692000996837607162348484, 0.0010049674106481758827326630820844265957854973504417, 1.1288027918891022863632338837117315476809403894523, 0.73036081404311473581698531119872971361489139002877, 0.0090981038847570846537821465810058289147856041616617, 52.264048055526551859457214287080473123160514369109, 50.768151250342155233775028625526081234006425883469, 7.3871823043570542965292707346232335470650967978006)] double f) + [TestCase(double.NaN, Double.NaN, Double.NaN)] + [TestCase(0.1, 1.0, 0.22953567028884603886365690180350044765300023528467)] + [TestCase(0.1, 2.0, 0.053977968112828232195991347726857391060870217694027)] + [TestCase(0.1, 8.0, 0.000046852198327948595220974570460669512682180005810156)] + [TestCase(1.5, 1.0, 0.50728223381177330984514007570018045349008617228036)] + [TestCase(1.5, 2.0, 0.23171655200098069331588896692000996837607162348484)] + [TestCase(1.5, 8.0, 0.0010049674106481758827326630820844265957854973504417)] + [TestCase(2.5, 1.0, 1.1288027918891022863632338837117315476809403894523)] + [TestCase(2.5, 2.0, 0.73036081404311473581698531119872971361489139002877)] + [TestCase(2.5, 8.0, 0.0090981038847570846537821465810058289147856041616617)] + [TestCase(5.5, 1.0, 52.264048055526551859457214287080473123160514369109)] + [TestCase(5.5, 2.0, 50.768151250342155233775028625526081234006425883469)] + [TestCase(5.5, 8.0, 7.3871823043570542965292707346232335470650967978006)] + public void GammaUpperIncomplete(double a, double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.GammaUpperIncomplete(a, x), 14); } diff --git a/src/UnitTests/SpecialFunctionsTests/SpecialFunctionsTests.cs b/src/UnitTests/SpecialFunctionsTests/SpecialFunctionsTests.cs index 526e6ad5..bc9ddb92 100644 --- a/src/UnitTests/SpecialFunctionsTests/SpecialFunctionsTests.cs +++ b/src/UnitTests/SpecialFunctionsTests/SpecialFunctionsTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -39,10 +39,24 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input X value. /// Function result. - [Test, Sequential] - public void DiGamma( - [Values(Double.NaN, -1.5, -0.5, 0.1, 1.0, 1.5, Constants.Pi / 2, 2.0, 2.5, 3.0, Constants.Pi, 3.5, 4.0, 4.5, 5.0, 5.5, 10.1)] double x, - [Values(Double.NaN, 0.70315664064524318722569033366791109947350706200623256, 0.036489973978576520559023667001244432806840395339565891, -10.423754940411076232100295314502760886768558023951363, -0.57721566490153286060651209008240243104215933593992359, 0.036489973978576520559023667001244432806840395339565888, 0.10067337642740238636795561404029690452798358068944001, 0.42278433509846713939348790991759756895784066406007641, 0.70315664064524318722569033366791109947350706200623255, 0.92278433509846713939348790991759756895784066406007641, 0.97721330794200673329206948640618234364083460999432603, 1.1031566406452431872256903336679110994735070620062326, 1.2561176684318004727268212432509309022911739973934097, 1.3888709263595289015114046193821968137592213477205183, 1.5061176684318004727268212432509309022911739973934097, 1.6110931485817511237336268416044190359814435699427405, 2.2622143570941481235561593642219403924532310597356171)] double f) + [TestCase(Double.NaN, Double.NaN)] + [TestCase(-1.5, 0.70315664064524318722569033366791109947350706200623256)] + [TestCase(-0.5, 0.036489973978576520559023667001244432806840395339565891)] + [TestCase(0.1, -10.423754940411076232100295314502760886768558023951363)] + [TestCase(1.0, -0.57721566490153286060651209008240243104215933593992359)] + [TestCase(1.5, 0.036489973978576520559023667001244432806840395339565888)] + [TestCase(Constants.Pi / 2, 0.10067337642740238636795561404029690452798358068944001)] + [TestCase(2.0, 0.42278433509846713939348790991759756895784066406007641)] + [TestCase(2.5, 0.70315664064524318722569033366791109947350706200623255)] + [TestCase(3.0, 0.92278433509846713939348790991759756895784066406007641)] + [TestCase(Constants.Pi, 0.97721330794200673329206948640618234364083460999432603)] + [TestCase(3.5, 1.1031566406452431872256903336679110994735070620062326)] + [TestCase(4.0, 1.2561176684318004727268212432509309022911739973934097)] + [TestCase(4.5, 1.3888709263595289015114046193821968137592213477205183)] + [TestCase(5.0, 1.5061176684318004727268212432509309022911739973934097)] + [TestCase(5.5, 1.6110931485817511237336268416044190359814435699427405)] + [TestCase(10.1, 2.2622143570941481235561593642219403924532310597356171)] + public void DiGamma(double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.DiGamma(x), 13); } @@ -52,10 +66,23 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input X value. /// Function result. - [Test, Sequential] - public void DiGammaInv( - [Values(Double.NaN, 0.0, 0.1, 1.0, 1.5, Constants.Pi / 2, 2.0, 2.5, 3.0, Constants.Pi, 3.5, 4.0, 4.5, 5.0, 5.5, 10.1)] double x, - [Values(Double.NaN, Double.NegativeInfinity, -10.423754940411076232100295314502760886768558023951363, -0.57721566490153286060651209008240243104215933593992359, 0.036489973978576520559023667001244432806840395339565888, 0.10067337642740238636795561404029690452798358068944001, 0.42278433509846713939348790991759756895784066406007641, 0.70315664064524318722569033366791109947350706200623255, 0.92278433509846713939348790991759756895784066406007641, 0.97721330794200673329206948640618234364083460999432603, 1.1031566406452431872256903336679110994735070620062326, 1.2561176684318004727268212432509309022911739973934097, 1.3888709263595289015114046193821968137592213477205183, 1.5061176684318004727268212432509309022911739973934097, 1.6110931485817511237336268416044190359814435699427405, 2.2622143570941481235561593642219403924532310597356171)] double f) + [TestCase(Double.NaN, Double.NaN)] + [TestCase(0.0, Double.NegativeInfinity)] + [TestCase(0.1, -10.423754940411076232100295314502760886768558023951363)] + [TestCase(1.0, -0.57721566490153286060651209008240243104215933593992359)] + [TestCase(1.5, 0.036489973978576520559023667001244432806840395339565888)] + [TestCase(Constants.Pi / 2, 0.10067337642740238636795561404029690452798358068944001)] + [TestCase(2.0, 0.42278433509846713939348790991759756895784066406007641)] + [TestCase(2.5, 0.70315664064524318722569033366791109947350706200623255)] + [TestCase(3.0, 0.92278433509846713939348790991759756895784066406007641)] + [TestCase(Constants.Pi, 0.97721330794200673329206948640618234364083460999432603)] + [TestCase(3.5, 1.1031566406452431872256903336679110994735070620062326)] + [TestCase(4.0, 1.2561176684318004727268212432509309022911739973934097)] + [TestCase(4.5, 1.3888709263595289015114046193821968137592213477205183)] + [TestCase(5.0, 1.5061176684318004727268212432509309022911739973934097)] + [TestCase(5.5, 1.6110931485817511237336268416044190359814435699427405)] + [TestCase(10.1, 2.2622143570941481235561593642219403924532310597356171)] + public void DiGammaInv(double x, double f) { AssertHelpers.AlmostEqual(x, SpecialFunctions.DiGammaInv(f), 13); } @@ -80,8 +107,17 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// Harmonic function. /// /// Input value. - [Test] - public void Harmonic([Values(1, 2, 4, 8, 16, 100, 1000, 10000, 100000, 1000000)] int i) + [TestCase(1)] + [TestCase(2)] + [TestCase(4)] + [TestCase(8)] + [TestCase(16)] + [TestCase(100)] + [TestCase(1000)] + [TestCase(10000)] + [TestCase(100000)] + [TestCase(1000000)] + public void Harmonic(int i) { AssertHelpers.AlmostEqual(ExactHarmonic(i), SpecialFunctions.Harmonic(i), 13); } @@ -113,12 +149,55 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// B parameter. /// Input X value. /// Function result. - [Test, Sequential] - public void BetaIncomplete( - [Values(0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000)] double a, - [Values(0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000)] double b, - [Values(0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000)] double x, - [Values(8.0117356206774655704238957309013421730449536344797, 9.8573197445250802696495512442154091185464210677262, 11.045931323774722512127911008108711428206559153167, 7.906686887040059574762793470136627722332467302241, 9.1012542128394916083902345366778109992938115490192, 9.368806890135865087467208304972858639790010273545, 7.8363997919172974609110616787835466667385876309684, 8.7385989355952880797816267602947881842609716646237, 8.8379245631995373736838511405978394101548418300997, 7.6464829466025722609741358285691936422732595850987, 8.0832162883698521112308593494639236817925940654185, 8.089843275520988350320569916795581670946930566783, 0.022303834332028031481145155068151014763064226606192, 0.33465159984030260689318592198561677643426763544959, 1.002080089012839104050394134134167486035896540574, 0.02043763859916055001568569052740016093388906615616, 0.19634954084936207740391521145496893026232308746094, 0.33678717944852264351783475904713816723851995610486, 0.019218819299580275673976660038794008316192763455412, 0.13984143709134770536862427239415113179782821039714, 0.18972692305759464976318019465615085035583828745353, 0.016056550082674778556355475820652277420877772570937, 0.061380263212265132490746506045997506787829048203228, 0.064403479961606576649564368278872635247235510624673, 0.001352753157951915161848451666929681258878645850634, 0.10756276379201896635529117527407904299772826375257, 0.5587192957063609402827988523062144494394362102048, 0.0012188192995802743417090304886061526176963027007477, 0.056508103758014372035290939060817798464494877063805, 0.14706025639092799375465456439098731688268166865133, 0.0011320572373426029655709496224583878329664195067652, 0.036815538909255389513234102147806674424185578898927, 0.067947596146597995171095886486269312250373204235372, 0.00091001787485888099434748885472859856478675247779447, 0.012036842116913956962302822724142322883106224614977, 0.0137861171346299807272679372975664758815098236357, 0.00000062268687636453588281206442354375188797585844216401, 0.0066577573700032687517874433540471831930305154614716, 0.15893826959760073090597940189540380779121963557728, 0.00000055008267477746389601958949824166456746390970113234, 0.0030469298789317991574131727126641734544957148698945, 0.029928813294939917230433606365228383142081556070117, 0.00000050358914459517094905570885392504304689450166185919, 0.0017689849740568141051599655812851800259633674721202, 0.010158231420344267874007806875642686140428489302542, 0.00000038687628134504851234251462244340434107233073666673, 0.00037750308451873202137593561772653328266987165863158, 0.00074361660080007708142054771607396897718180545812717)] double f) + [TestCase(0.100000, 0.100000, 0.100000, 8.0117356206774655704238957309013421730449536344797)] + [TestCase(0.100000, 0.100000, 0.500000, 9.8573197445250802696495512442154091185464210677262)] + [TestCase(0.100000, 0.100000, 0.800000, 11.045931323774722512127911008108711428206559153167)] + [TestCase(0.100000, 1.500000, 0.100000, 7.906686887040059574762793470136627722332467302241)] + [TestCase(0.100000, 1.500000, 0.500000, 9.1012542128394916083902345366778109992938115490192)] + [TestCase(0.100000, 1.500000, 0.800000, 9.368806890135865087467208304972858639790010273545)] + [TestCase(0.100000, 2.500000, 0.100000, 7.8363997919172974609110616787835466667385876309684)] + [TestCase(0.100000, 2.500000, 0.500000, 8.7385989355952880797816267602947881842609716646237)] + [TestCase(0.100000, 2.500000, 0.800000, 8.8379245631995373736838511405978394101548418300997)] + [TestCase(0.100000, 5.500000, 0.100000, 7.6464829466025722609741358285691936422732595850987)] + [TestCase(0.100000, 5.500000, 0.500000, 8.0832162883698521112308593494639236817925940654185)] + [TestCase(0.100000, 5.500000, 0.800000, 8.089843275520988350320569916795581670946930566783)] + [TestCase(1.500000, 0.100000, 0.100000, 0.022303834332028031481145155068151014763064226606192)] + [TestCase(1.500000, 0.100000, 0.500000, 0.33465159984030260689318592198561677643426763544959)] + [TestCase(1.500000, 0.100000, 0.800000, 1.002080089012839104050394134134167486035896540574)] + [TestCase(1.500000, 1.500000, 0.100000, 0.02043763859916055001568569052740016093388906615616)] + [TestCase(1.500000, 1.500000, 0.500000, 0.19634954084936207740391521145496893026232308746094)] + [TestCase(1.500000, 1.500000, 0.800000, 0.33678717944852264351783475904713816723851995610486)] + [TestCase(1.500000, 2.500000, 0.100000, 0.019218819299580275673976660038794008316192763455412)] + [TestCase(1.500000, 2.500000, 0.500000, 0.13984143709134770536862427239415113179782821039714)] + [TestCase(1.500000, 2.500000, 0.800000, 0.18972692305759464976318019465615085035583828745353)] + [TestCase(1.500000, 5.500000, 0.100000, 0.016056550082674778556355475820652277420877772570937)] + [TestCase(1.500000, 5.500000, 0.500000, 0.061380263212265132490746506045997506787829048203228)] + [TestCase(1.500000, 5.500000, 0.800000, 0.064403479961606576649564368278872635247235510624673)] + [TestCase(2.500000, 0.100000, 0.100000, 0.001352753157951915161848451666929681258878645850634)] + [TestCase(2.500000, 0.100000, 0.500000, 0.10756276379201896635529117527407904299772826375257)] + [TestCase(2.500000, 0.100000, 0.800000, 0.5587192957063609402827988523062144494394362102048)] + [TestCase(2.500000, 1.500000, 0.100000, 0.0012188192995802743417090304886061526176963027007477)] + [TestCase(2.500000, 1.500000, 0.500000, 0.056508103758014372035290939060817798464494877063805)] + [TestCase(2.500000, 1.500000, 0.800000, 0.14706025639092799375465456439098731688268166865133)] + [TestCase(2.500000, 2.500000, 0.100000, 0.0011320572373426029655709496224583878329664195067652)] + [TestCase(2.500000, 2.500000, 0.500000, 0.036815538909255389513234102147806674424185578898927)] + [TestCase(2.500000, 2.500000, 0.800000, 0.067947596146597995171095886486269312250373204235372)] + [TestCase(2.500000, 5.500000, 0.100000, 0.00091001787485888099434748885472859856478675247779447)] + [TestCase(2.500000, 5.500000, 0.500000, 0.012036842116913956962302822724142322883106224614977)] + [TestCase(2.500000, 5.500000, 0.800000, 0.0137861171346299807272679372975664758815098236357)] + [TestCase(5.500000, 0.100000, 0.100000, 0.00000062268687636453588281206442354375188797585844216401)] + [TestCase(5.500000, 0.100000, 0.500000, 0.0066577573700032687517874433540471831930305154614716)] + [TestCase(5.500000, 0.100000, 0.800000, 0.15893826959760073090597940189540380779121963557728)] + [TestCase(5.500000, 1.500000, 0.100000, 0.00000055008267477746389601958949824166456746390970113234)] + [TestCase(5.500000, 1.500000, 0.500000, 0.0030469298789317991574131727126641734544957148698945)] + [TestCase(5.500000, 1.500000, 0.800000, 0.029928813294939917230433606365228383142081556070117)] + [TestCase(5.500000, 2.500000, 0.100000, 0.00000050358914459517094905570885392504304689450166185919)] + [TestCase(5.500000, 2.500000, 0.500000, 0.0017689849740568141051599655812851800259633674721202)] + [TestCase(5.500000, 2.500000, 0.800000, 0.010158231420344267874007806875642686140428489302542)] + [TestCase(5.500000, 5.500000, 0.100000, 0.00000038687628134504851234251462244340434107233073666673)] + [TestCase(5.500000, 5.500000, 0.500000, 0.00037750308451873202137593561772653328266987165863158)] + [TestCase(5.500000, 5.500000, 0.800000, 0.00074361660080007708142054771607396897718180545812717)] + public void BetaIncomplete(double a, double b, double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.BetaIncomplete(a, b, x), 12); } @@ -130,12 +209,55 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// B parameter. /// Input X value. /// Function result. - [Test, Sequential] - public void BetaRegularized( - [Values(0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000, 5.500000)] double a, - [Values(0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000, 0.100000, 0.100000, 0.100000, 1.500000, 1.500000, 1.500000, 2.500000, 2.500000, 2.500000, 5.500000, 5.500000, 5.500000)] double b, - [Values(0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000, 0.100000, 0.500000, 0.800000)] double x, - [Values(0.40638509393627598963947434031370208398700911383034, 0.5, 0.56029080977665439586092261707431380702999082404228, 0.83793618164513694339361766577607270440777026543289, 0.96453423693668031005965611526662377555163072304903, 0.99288897919542998751072045939791723468184549496473, 0.88585310309894667823419197676046986281131524104959, 0.98784074184406228317625751436240720987391458581291, 0.99906884630106408932550166100889714490764416359312, 0.94519184147610137383076366494492317664691771837548, 0.99917702583101287494949180374093750006040749104055, 0.99999619645266501604882303584892931538704382134298, 0.0023637194748231330327322712604688049136736986021871, 0.03546576306331968994034388473337622444836927695097, 0.10619861080705813882414161079467267590245761692272, 0.052044019330913933551809009997594089261007490064035, 0.5, 0.85762151006735301922188173009147886735366387396138, 0.097880642941379793645839194076629344959184516635409, 0.71220659078919378102517835116335248271261286098728, 0.96627128455142020796603976406510565066301101575357, 0.2492200779249636429835386068413815093625886315581, 0.95270739368361339952038048248181862978690743677285, 0.99963193911681378117173263163355516583213310848701, 0.00015291978644767572330394885397661411972523657814463, 0.012159258155937716823742485637592790126085414187091, 0.063159516487818477363383984899205310365144861115492, 0.006207395720448073457778825918558833562830463492662, 0.28779340921080621897482164883664751728738713901272, 0.74897173558328583047772369611785208404431673216919, 0.015374720442541245985473611768528587536206924004576, 0.5, 0.92281137475779334211841505067903343661808086762039, 0.065915491253258347344782598110283193803051483319306, 0.87186678766868243532031253918149387446781682306342, 0.99857234512565487924356478796968439529913692090276, 0.000000076971146008440526509370378069895435149621047562911, 0.00082297416898712505050819625906249993959250895944939, 0.01964656911825443767408345737200950450690987324177, 0.0000085380512231662773545327104780279605728164994539023, 0.047292606316386600479619517518181370213092563227146, 0.46453697358156781101222907948783656601193056166297, 0.000036476564661926426853537763285519105619982887967225, 0.12813321233131756467968746081850612553218317693658, 0.73579303531824700577792236664278017906658620718916, 0.00051241472879389331855418481833750204851457778933154, 0.5, 0.98491460241721309518021565227501009891015897915977)] double f) + [TestCase(0.100000, 0.100000, 0.100000, 0.40638509393627598963947434031370208398700911383034)] + [TestCase(0.100000, 0.100000, 0.500000, 0.5)] + [TestCase(0.100000, 0.100000, 0.800000, 0.56029080977665439586092261707431380702999082404228)] + [TestCase(0.100000, 1.500000, 0.100000, 0.83793618164513694339361766577607270440777026543289)] + [TestCase(0.100000, 1.500000, 0.500000, 0.96453423693668031005965611526662377555163072304903)] + [TestCase(0.100000, 1.500000, 0.800000, 0.99288897919542998751072045939791723468184549496473)] + [TestCase(0.100000, 2.500000, 0.100000, 0.88585310309894667823419197676046986281131524104959)] + [TestCase(0.100000, 2.500000, 0.500000, 0.98784074184406228317625751436240720987391458581291)] + [TestCase(0.100000, 2.500000, 0.800000, 0.99906884630106408932550166100889714490764416359312)] + [TestCase(0.100000, 5.500000, 0.100000, 0.94519184147610137383076366494492317664691771837548)] + [TestCase(0.100000, 5.500000, 0.500000, 0.99917702583101287494949180374093750006040749104055)] + [TestCase(0.100000, 5.500000, 0.800000, 0.99999619645266501604882303584892931538704382134298)] + [TestCase(1.500000, 0.100000, 0.100000, 0.0023637194748231330327322712604688049136736986021871)] + [TestCase(1.500000, 0.100000, 0.500000, 0.03546576306331968994034388473337622444836927695097)] + [TestCase(1.500000, 0.100000, 0.800000, 0.10619861080705813882414161079467267590245761692272)] + [TestCase(1.500000, 1.500000, 0.100000, 0.052044019330913933551809009997594089261007490064035)] + [TestCase(1.500000, 1.500000, 0.500000, 0.5)] + [TestCase(1.500000, 1.500000, 0.800000, 0.85762151006735301922188173009147886735366387396138)] + [TestCase(1.500000, 2.500000, 0.100000, 0.097880642941379793645839194076629344959184516635409)] + [TestCase(1.500000, 2.500000, 0.500000, 0.71220659078919378102517835116335248271261286098728)] + [TestCase(1.500000, 2.500000, 0.800000, 0.96627128455142020796603976406510565066301101575357)] + [TestCase(1.500000, 5.500000, 0.100000, 0.2492200779249636429835386068413815093625886315581)] + [TestCase(1.500000, 5.500000, 0.500000, 0.95270739368361339952038048248181862978690743677285)] + [TestCase(1.500000, 5.500000, 0.800000, 0.99963193911681378117173263163355516583213310848701)] + [TestCase(2.500000, 0.100000, 0.100000, 0.00015291978644767572330394885397661411972523657814463)] + [TestCase(2.500000, 0.100000, 0.500000, 0.012159258155937716823742485637592790126085414187091)] + [TestCase(2.500000, 0.100000, 0.800000, 0.063159516487818477363383984899205310365144861115492)] + [TestCase(2.500000, 1.500000, 0.100000, 0.006207395720448073457778825918558833562830463492662)] + [TestCase(2.500000, 1.500000, 0.500000, 0.28779340921080621897482164883664751728738713901272)] + [TestCase(2.500000, 1.500000, 0.800000, 0.74897173558328583047772369611785208404431673216919)] + [TestCase(2.500000, 2.500000, 0.100000, 0.015374720442541245985473611768528587536206924004576)] + [TestCase(2.500000, 2.500000, 0.500000, 0.5)] + [TestCase(2.500000, 2.500000, 0.800000, 0.92281137475779334211841505067903343661808086762039)] + [TestCase(2.500000, 5.500000, 0.100000, 0.065915491253258347344782598110283193803051483319306)] + [TestCase(2.500000, 5.500000, 0.500000, 0.87186678766868243532031253918149387446781682306342)] + [TestCase(2.500000, 5.500000, 0.800000, 0.99857234512565487924356478796968439529913692090276)] + [TestCase(5.500000, 0.100000, 0.100000, 0.000000076971146008440526509370378069895435149621047562911)] + [TestCase(5.500000, 0.100000, 0.500000, 0.00082297416898712505050819625906249993959250895944939)] + [TestCase(5.500000, 0.100000, 0.800000, 0.01964656911825443767408345737200950450690987324177)] + [TestCase(5.500000, 1.500000, 0.100000, 0.0000085380512231662773545327104780279605728164994539023)] + [TestCase(5.500000, 1.500000, 0.500000, 0.047292606316386600479619517518181370213092563227146)] + [TestCase(5.500000, 1.500000, 0.800000, 0.46453697358156781101222907948783656601193056166297)] + [TestCase(5.500000, 2.500000, 0.100000, 0.000036476564661926426853537763285519105619982887967225)] + [TestCase(5.500000, 2.500000, 0.500000, 0.12813321233131756467968746081850612553218317693658)] + [TestCase(5.500000, 2.500000, 0.800000, 0.73579303531824700577792236664278017906658620718916)] + [TestCase(5.500000, 5.500000, 0.100000, 0.00051241472879389331855418481833750204851457778933154)] + [TestCase(5.500000, 5.500000, 0.500000, 0.5)] + [TestCase(5.500000, 5.500000, 0.800000, 0.98491460241721309518021565227501009891015897915977)] + public void BetaRegularized(double a, double b, double x, double f) { AssertHelpers.AlmostEqual(f, SpecialFunctions.BetaRegularized(a, b, x), 12); } @@ -145,10 +267,16 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Input value. /// Expected X value. - [Test, Sequential] - public void Logit( - [Values(0.000000, 0.000010, 0.001000, 0.100000, 0.500000, 0.900000, 0.999000, 0.999990, 1.000000)] double p, - [Values(Double.NegativeInfinity, -11.512915464920228103874353849992239636376994324587, -6.9067547786485535272274487616830597875179908939086, -2.1972245773362193134015514347727700402304323440139, 0.0, 2.1972245773362195801634726294284168954491240598975, 6.9067547786485526081487245019905638981131702804661, 11.512915464924779098232747799811946290419057060965, Double.PositiveInfinity)] double x) + [TestCase(0.000000, Double.NegativeInfinity)] + [TestCase(0.000010, -11.512915464920228103874353849992239636376994324587)] + [TestCase(0.001000, -6.9067547786485535272274487616830597875179908939086)] + [TestCase(0.100000, -2.1972245773362193134015514347727700402304323440139)] + [TestCase(0.500000, 0.0)] + [TestCase(0.900000, 2.1972245773362195801634726294284168954491240598975)] + [TestCase(0.999000, 6.9067547786485526081487245019905638981131702804661)] + [TestCase(0.999990, 11.512915464924779098232747799811946290419057060965)] + [TestCase(1.000000, Double.PositiveInfinity)] + public void Logit(double p, double x) { AssertHelpers.AlmostEqual(x, SpecialFunctions.Logit(p), 15); } @@ -158,10 +286,16 @@ namespace MathNet.Numerics.UnitTests.SpecialFunctionsTests /// /// Expected value. /// Input X value. - [Test, Sequential] - public void Logistic( - [Values(Double.NegativeInfinity, -11.512915464920228103874353849992239636376994324587, -6.9067547786485535272274487616830597875179908939086, -2.1972245773362193134015514347727700402304323440139, 0.0, 2.1972245773362195801634726294284168954491240598975, 6.9067547786485526081487245019905638981131702804661, 11.512915464924779098232747799811946290419057060965, Double.PositiveInfinity)] double p, - [Values(0.000000, 0.000010, 0.001000, 0.100000, 0.500000, 0.900000, 0.999000, 0.999990, 1.000000)] double x) + [TestCase(Double.NegativeInfinity, 0.000000)] + [TestCase(-11.512915464920228103874353849992239636376994324587, 0.000010)] + [TestCase(-6.9067547786485535272274487616830597875179908939086, 0.001000)] + [TestCase(-2.1972245773362193134015514347727700402304323440139, 0.100000)] + [TestCase(0.0, 0.500000)] + [TestCase(2.1972245773362195801634726294284168954491240598975, 0.900000)] + [TestCase(6.9067547786485526081487245019905638981131702804661, 0.999000)] + [TestCase(11.512915464924779098232747799811946290419057060965, 0.999990)] + [TestCase(Double.PositiveInfinity, 1.000000)] + public void Logistic(double p, double x) { AssertHelpers.AlmostEqual(x, SpecialFunctions.Logistic(p), 15); } diff --git a/src/UnitTests/StatisticsTests/CorrelationTests.cs b/src/UnitTests/StatisticsTests/CorrelationTests.cs index f1b99221..8e26cdd8 100644 --- a/src/UnitTests/StatisticsTests/CorrelationTests.cs +++ b/src/UnitTests/StatisticsTests/CorrelationTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -26,6 +26,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests { +#if !SILVERLIGHT using System; using System.Collections.Generic; using System.Linq; @@ -35,6 +36,8 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Correlation tests /// + /// NOTE: this class is not included into Silverlight version, because it uses data from local files. + /// In Silverlight access to local files is forbidden, except several cases. [TestFixture] public class CorrelationTests { @@ -78,4 +81,5 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests Assert.Throws(() => Correlation.Pearson(dataA, dataB)); } } +#endif } diff --git a/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs b/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs index 20036e06..bc2a216a 100644 --- a/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs +++ b/src/UnitTests/StatisticsTests/DescriptiveStatisticsTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -26,6 +26,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests { +#if !SILVERLIGHT using System; using System.Collections.Generic; using NUnit.Framework; @@ -34,6 +35,8 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Descriptive statistics tests. /// + /// NOTE: this class is not included into Silverlight version, because it uses data from local files. + /// In Silverlight access to local files is forbidden, except several cases. [TestFixture] public class DescriptiveStatisticsTests { @@ -91,16 +94,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Min value. /// Max value. /// Count value. - [Test, Sequential] - public void IEnumerableDouble( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(15, 15, 12, 12, 15, 13, 9, 8)] int digits, - [Values(-0.09333165310779, -0.050606638756334, 0.64492948110824, -0.0185388637725746, 0, 0, 0, 0)] double skewness, - [Values(-1.19256091074856, -1.49604979214447, -0.82052379677456, 0.33968459842539, 0, -2.003003003003, -2.003003003003, -2.00300300299913)] double kurtosis, - [Values(522.5, -162, 2.0018, 299.85, 10000002, 1.2, 1000000.2, 10000000.2)] double median, - [Values(4, -579, 2.0013, 299.62, 10000001, 1.1, 1000000.1, 10000000.1)] double min, - [Values(999, 300, 2.0027, 300.07, 10000003, 1.3, 1000000.3, 10000000.3)] double max, - [Values(218, 200, 50, 100, 3, 1001, 1001, 1001)] int count) + [TestCase("lottery", 15, -0.09333165310779, -1.19256091074856, 522.5, 4, 999, 218)] + [TestCase("lew", 15, -0.050606638756334, -1.49604979214447, -162, -579, 300, 200)] + [TestCase("mavro", 12, 0.64492948110824, -0.82052379677456, 2.0018, 2.0013, 2.0027, 50)] + [TestCase("michelso", 12, -0.0185388637725746, 0.33968459842539, 299.85, 299.62, 300.07, 100)] + [TestCase("numacc1", 15, 0, 0, 10000002, 10000001, 10000003, 3)] + [TestCase("numacc2", 13, 0, -2.003003003003, 1.2, 1.1, 1.3, 1001)] + [TestCase("numacc3", 9, 0, -2.003003003003, 1000000.2, 1000000.1, 1000000.3, 1001)] + [TestCase("numacc4", 8, 0, -2.00300300299913, 10000000.2, 10000000.1, 10000000.3, 1001)] + public void IEnumerableDouble(string dataSet, int digits, double skewness, double kurtosis, double median, double min, double max, int count) { var data = _data[dataSet]; var stats = new DescriptiveStatistics(data.Data); @@ -125,15 +127,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Min value. /// Max value. /// Count value. - [Test, Sequential] - public void IEnumerableDoubleHighAccuracy( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(-0.09333165310779, -0.050606638756334, 0.64492948110824, -0.0185388637725746, 0, 0, 0, 0)] double skewness, - [Values(-1.19256091074856, -1.49604979214447, -0.82052379677456, 0.33968459842539, 0, -2.003003003003, -2.003003003003, -2.00300300299913)] double kurtosis, - [Values(522.5, -162, 2.0018, 299.85, 10000002, 1.2, 1000000.2, 10000000.2)] double median, - [Values(4, -579, 2.0013, 299.62, 10000001, 1.1, 1000000.1, 10000000.1)] double min, - [Values(999, 300, 2.0027, 300.07, 10000003, 1.3, 1000000.3, 10000000.3)] double max, - [Values(218, 200, 50, 100, 3, 1001, 1001, 1001)] int count) + [TestCase("lottery", -0.09333165310779, -1.19256091074856, 522.5, 4, 999, 218)] + [TestCase("lew", -0.050606638756334, -1.49604979214447, -162, -579, 300, 200)] + [TestCase("mavro", 0.64492948110824, -0.82052379677456, 2.0018, 2.0013, 2.0027, 50)] + [TestCase("michelso", -0.0185388637725746, 0.33968459842539, 299.85, 299.62, 300.07, 100)] + [TestCase("numacc1", 0, 0, 10000002, 10000001, 10000003, 3)] + [TestCase("numacc2", 0, -2.003003003003, 1.2, 1.1, 1.3, 1001)] + [TestCase("numacc3", 0, -2.003003003003, 1000000.2, 1000000.1, 1000000.3, 1001)] + [TestCase("numacc4", 0, -2.00300300299913, 10000000.2, 10000000.1, 10000000.3, 1001)] + public void IEnumerableDoubleHighAccuracy(string dataSet, double skewness, double kurtosis, double median, double min, double max, int count) { var data = _data[dataSet]; var stats = new DescriptiveStatistics(data.Data, true); @@ -158,16 +160,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Min value. /// Max value. /// Count value. - [Test, Sequential] - public void IEnumerableDoubleLowAccuracy( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(15, 15, 12, 12, 15, 13, 9, 8)] int digits, - [Values(-0.09333165310779, -0.050606638756334, 0.64492948110824, -0.0185388637725746, 0, 0, 0, 0)] double skewness, - [Values(-1.19256091074856, -1.49604979214447, -0.82052379677456, 0.33968459842539, 0, -2.003003003003, -2.003003003003, -2.00300300299913)] double kurtosis, - [Values(522.5, -162, 2.0018, 299.85, 10000002, 1.2, 1000000.2, 10000000.2)] double median, - [Values(4, -579, 2.0013, 299.62, 10000001, 1.1, 1000000.1, 10000000.1)] double min, - [Values(999, 300, 2.0027, 300.07, 10000003, 1.3, 1000000.3, 10000000.3)] double max, - [Values(218, 200, 50, 100, 3, 1001, 1001, 1001)] int count) + [TestCase("lottery", 15, -0.09333165310779, -1.19256091074856, 522.5, 4, 999, 218)] + [TestCase("lew", 15, -0.050606638756334, -1.49604979214447, -162, -579, 300, 200)] + [TestCase("mavro", 12, 0.64492948110824, -0.82052379677456, 2.0018, 2.0013, 2.0027, 50)] + [TestCase("michelso", 12, -0.0185388637725746, 0.33968459842539, 299.85, 299.62, 300.07, 100)] + [TestCase("numacc1", 15, 0, 0, 10000002, 10000001, 10000003, 3)] + [TestCase("numacc2", 13, 0, -2.003003003003, 1.2, 1.1, 1.3, 1001)] + [TestCase("numacc3", 9, 0, -2.003003003003, 1000000.2, 1000000.1, 1000000.3, 1001)] + [TestCase("numacc4", 8, 0, -2.00300300299913, 10000000.2, 10000000.1, 10000000.3, 1001)] + public void IEnumerableDoubleLowAccuracy(string dataSet, int digits, double skewness, double kurtosis, double median, double min, double max, int count) { var data = _data[dataSet]; var stats = new DescriptiveStatistics(data.Data, false); @@ -192,16 +193,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Min value. /// Max value. /// Count value. - [Test, Sequential] - public void IEnumerableNullableDouble( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(15, 15, 12, 12, 15, 13, 9, 8)] int digits, - [Values(-0.09333165310779, -0.050606638756334, 0.64492948110824, -0.0185388637725746, 0, 0, 0, 0)] double skewness, - [Values(-1.19256091074856, -1.49604979214447, -0.82052379677456, 0.33968459842539, 0, -2.003003003003, -2.003003003003, -2.00300300299913)] double kurtosis, - [Values(522.5, -162, 2.0018, 299.85, 10000002, 1.2, 1000000.2, 10000000.2)] double median, - [Values(4, -579, 2.0013, 299.62, 10000001, 1.1, 1000000.1, 10000000.1)] double min, - [Values(999, 300, 2.0027, 300.07, 10000003, 1.3, 1000000.3, 10000000.3)] double max, - [Values(218, 200, 50, 100, 3, 1001, 1001, 1001)] int count) + [TestCase("lottery", 15, -0.09333165310779, -1.19256091074856, 522.5, 4, 999, 218)] + [TestCase("lew", 15, -0.050606638756334, -1.49604979214447, -162, -579, 300, 200)] + [TestCase("mavro", 12, 0.64492948110824, -0.82052379677456, 2.0018, 2.0013, 2.0027, 50)] + [TestCase("michelso", 12, -0.0185388637725746, 0.33968459842539, 299.85, 299.62, 300.07, 100)] + [TestCase("numacc1", 15, 0, 0, 10000002, 10000001, 10000003, 3)] + [TestCase("numacc2", 13, 0, -2.003003003003, 1.2, 1.1, 1.3, 1001)] + [TestCase("numacc3", 9, 0, -2.003003003003, 1000000.2, 1000000.1, 1000000.3, 1001)] + [TestCase("numacc4", 8, 0, -2.00300300299913, 10000000.2, 10000000.1, 10000000.3, 1001)] + public void IEnumerableNullableDouble(string dataSet, int digits, double skewness, double kurtosis, double median, double min, double max, int count) { var data = _data[dataSet]; var stats = new DescriptiveStatistics(data.DataWithNulls); @@ -225,15 +225,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Min value. /// Max value. /// Count value. - [Test, Sequential] - public void IEnumerableNullableDoubleHighAccuracy( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(-0.09333165310779, -0.050606638756334, 0.64492948110824, -0.0185388637725746, 0, 0, 0, 0)] double skewness, - [Values(-1.19256091074856, -1.49604979214447, -0.82052379677456, 0.33968459842539, 0, -2.003003003003, -2.003003003003, -2.00300300299913)] double kurtosis, - [Values(522.5, -162, 2.0018, 299.85, 10000002, 1.2, 1000000.2, 10000000.2)] double median, - [Values(4, -579, 2.0013, 299.62, 10000001, 1.1, 1000000.1, 10000000.1)] double min, - [Values(999, 300, 2.0027, 300.07, 10000003, 1.3, 1000000.3, 10000000.3)] double max, - [Values(218, 200, 50, 100, 3, 1001, 1001, 1001)] int count) + [TestCase("lottery", -0.09333165310779, -1.19256091074856, 522.5, 4, 999, 218)] + [TestCase("lew", -0.050606638756334, -1.49604979214447, -162, -579, 300, 200)] + [TestCase("mavro", 0.64492948110824, -0.82052379677456, 2.0018, 2.0013, 2.0027, 50)] + [TestCase("michelso", -0.0185388637725746, 0.33968459842539, 299.85, 299.62, 300.07, 100)] + [TestCase("numacc1", 0, 0, 10000002, 10000001, 10000003, 3)] + [TestCase("numacc2", 0, -2.003003003003, 1.2, 1.1, 1.3, 1001)] + [TestCase("numacc3", 0, -2.003003003003, 1000000.2, 1000000.1, 1000000.3, 1001)] + [TestCase("numacc4", 0, -2.00300300299913, 10000000.2, 10000000.1, 10000000.3, 1001)] + public void IEnumerableNullableDoubleHighAccuracy(string dataSet, double skewness, double kurtosis, double median, double min, double max, int count) { var data = _data[dataSet]; var stats = new DescriptiveStatistics(data.DataWithNulls, true); @@ -258,16 +258,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Min value. /// Max value. /// Count value. - [Test, Sequential] - public void IEnumerableNullableDoubleLowAccuracy( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(15, 15, 12, 12, 15, 13, 9, 8)] int digits, - [Values(-0.09333165310779, -0.050606638756334, 0.64492948110824, -0.0185388637725746, 0, 0, 0, 0)] double skewness, - [Values(-1.19256091074856, -1.49604979214447, -0.82052379677456, 0.33968459842539, 0, -2.003003003003, -2.003003003003, -2.00300300299913)] double kurtosis, - [Values(522.5, -162, 2.0018, 299.85, 10000002, 1.2, 1000000.2, 10000000.2)] double median, - [Values(4, -579, 2.0013, 299.62, 10000001, 1.1, 1000000.1, 10000000.1)] double min, - [Values(999, 300, 2.0027, 300.07, 10000003, 1.3, 1000000.3, 10000000.3)] double max, - [Values(218, 200, 50, 100, 3, 1001, 1001, 1001)] int count) + [TestCase("lottery", 15, -0.09333165310779, -1.19256091074856, 522.5, 4, 999, 218)] + [TestCase("lew", 15, -0.050606638756334, -1.49604979214447, -162, -579, 300, 200)] + [TestCase("mavro", 12, 0.64492948110824, -0.82052379677456, 2.0018, 2.0013, 2.0027, 50)] + [TestCase("michelso", 12, -0.0185388637725746, 0.33968459842539, 299.85, 299.62, 300.07, 100)] + [TestCase("numacc1", 15, 0, 0, 10000002, 10000001, 10000003, 3)] + [TestCase("numacc2", 13, 0, -2.003003003003, 1.2, 1.1, 1.3, 1001)] + [TestCase("numacc3", 9, 0, -2.003003003003, 1000000.2, 1000000.1, 1000000.3, 1001)] + [TestCase("numacc4", 8, 0, -2.00300300299913, 10000000.2, 10000000.1, 10000000.3, 1001)] + public void IEnumerableNullableDoubleLowAccuracy(string dataSet, int digits, double skewness, double kurtosis, double median, double min, double max, int count) { var data = _data[dataSet]; var stats = new DescriptiveStatistics(data.DataWithNulls, false); @@ -281,4 +280,5 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests Assert.AreEqual(stats.Count, count); } } +#endif } diff --git a/src/UnitTests/StatisticsTests/HistogramTests.cs b/src/UnitTests/StatisticsTests/HistogramTests.cs index df3805ea..f648ddc7 100644 --- a/src/UnitTests/StatisticsTests/HistogramTests.cs +++ b/src/UnitTests/StatisticsTests/HistogramTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -123,8 +123,12 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Point values. /// Expected result. - [Test, Sequential] - public void ValidateContains([Values(0.0, 1.0, 1.05, 2.0, -1.0)] double x, [Values(-1, 0, 0, 1, 0 - 1)] int r) + [TestCase(0.0, -1)] + [TestCase(1.0, 0)] + [TestCase(1.05, 0)] + [TestCase(2.0, 1)] + [TestCase(-1.0, 0 - 1)] + public void ValidateContains(double x, int r) { var b = new Bucket(0.0, 1.5, 10.0); Assert.AreEqual(r, b.Contains(x)); @@ -154,8 +158,11 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Point to check. /// Bucket index. - [Test, Sequential] - public void CanGetBucketIndexOf([Values(0.5, 1.0, 10.0, 10000.0)] double x, [Values(0, 0, 3, 4)] double i) + [TestCase(0.5, 0)] + [TestCase(1.0, 0)] + [TestCase(10.0, 3)] + [TestCase(10000.0, 4)] + public void CanGetBucketIndexOf(double x, double i) { var h = new Histogram(); h.AddBucket(new Bucket(0.0, 1.0)); diff --git a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs index c690128f..2dc21a9d 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisHastingsSamplerTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs index 75d78c72..7d098b2b 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/MetropolisSamplerTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs index 496ed7ac..0460859c 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs index 16116d7c..f2515ee6 100644 --- a/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs +++ b/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/StatisticsTests/PercentileTests.cs b/src/UnitTests/StatisticsTests/PercentileTests.cs index f1fad2c8..0cad934f 100644 --- a/src/UnitTests/StatisticsTests/PercentileTests.cs +++ b/src/UnitTests/StatisticsTests/PercentileTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/StatisticsTests/StatTestData.cs b/src/UnitTests/StatisticsTests/StatTestData.cs index 59cb4f8c..b1dafbd5 100644 --- a/src/UnitTests/StatisticsTests/StatTestData.cs +++ b/src/UnitTests/StatisticsTests/StatTestData.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics diff --git a/src/UnitTests/StatisticsTests/StatisticsTests.cs b/src/UnitTests/StatisticsTests/StatisticsTests.cs index 714b3f89..405e158b 100644 --- a/src/UnitTests/StatisticsTests/StatisticsTests.cs +++ b/src/UnitTests/StatisticsTests/StatisticsTests.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -26,6 +26,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests { +#if !SILVERLIGHT using System; using System.Collections.Generic; using System.IO; @@ -36,6 +37,8 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Statistics tests. /// + /// NOTE: this class is not included into Silverlight version, because it uses data from local files. + /// In Silverlight access to local files is forbidden, except several cases. [TestFixture] public class StatisticsTests { @@ -71,8 +74,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Validate mean. /// /// Dataset name. - [Test] - public void Mean([Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet) + [TestCase("lottery")] + [TestCase("lew")] + [TestCase("mavro")] + [TestCase("michelso")] + [TestCase("numacc1")] + [TestCase("numacc2")] + [TestCase("numacc3")] + [TestCase("numacc4")] + public void Mean(string dataSet) { var data = _data[dataSet]; AssertHelpers.AlmostEqual(data.Mean, data.Data.Mean(), 15); @@ -82,8 +92,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// Nullable mean. /// /// Dataset name. - [Test] - public void NullableMean([Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet) + [TestCase("lottery")] + [TestCase("lew")] + [TestCase("mavro")] + [TestCase("michelso")] + [TestCase("numacc1")] + [TestCase("numacc2")] + [TestCase("numacc3")] + [TestCase("numacc4")] + public void NullableMean(string dataSet) { var data = _data[dataSet]; AssertHelpers.AlmostEqual(data.Mean, data.DataWithNulls.Mean(), 15); @@ -104,10 +121,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Dataset name. /// Digits count. - [Test, Sequential] - public void StandardDeviation( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(15, 15, 12, 12, 15, 13, 9, 8)] int digits) + [TestCase("lottery", 15)] + [TestCase("lew", 15)] + [TestCase("mavro", 12)] + [TestCase("michelso", 12)] + [TestCase("numacc1", 15)] + [TestCase("numacc2", 13)] + [TestCase("numacc3", 9)] + [TestCase("numacc4", 8)] + public void StandardDeviation(string dataSet, int digits) { var data = _data[dataSet]; AssertHelpers.AlmostEqual(data.StandardDeviation, data.Data.StandardDeviation(), digits); @@ -118,10 +140,15 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests /// /// Dataset name. /// Digits count. - [Test, Sequential] - public void NullableStandardDeviation( - [Values("lottery", "lew", "mavro", "michelso", "numacc1", "numacc2", "numacc3", "numacc4")] string dataSet, - [Values(15, 15, 12, 12, 15, 13, 9, 8)] int digits) + [TestCase("lottery", 15)] + [TestCase("lew", 15)] + [TestCase("mavro", 12)] + [TestCase("michelso", 12)] + [TestCase("numacc1", 15)] + [TestCase("numacc2", 13)] + [TestCase("numacc3", 9)] + [TestCase("numacc4", 8)] + public void NullableStandardDeviation(string dataSet, int digits) { var data = _data[dataSet]; AssertHelpers.AlmostEqual(data.StandardDeviation, data.DataWithNulls.StandardDeviation(), digits); @@ -149,7 +176,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests } /// - /// Validate Order Statistics & Median on a short sequence. + /// Validate Order Statistics and Median on a short sequence. /// [Test] public void ShortOrderMedian() @@ -173,9 +200,9 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests { // Test around 10^9, potential stability issues var gaussian = new Distributions.Normal(1e+9, 2) - { - RandomSource = new Numerics.Random.MersenneTwister(100) - }; + { + RandomSource = new Numerics.Random.MersenneTwister(100) + }; AssertHelpers.AlmostEqual(1e+9, gaussian.Samples().Take(10000).Mean(), 11); AssertHelpers.AlmostEqual(4d, gaussian.Samples().Take(10000).Variance(), 1); @@ -183,7 +210,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests } /// - /// http://mathnetnumerics.codeplex.com/workitem/5667 + /// URL http://mathnetnumerics.codeplex.com/workitem/5667 /// [Test] public void Median_CodeplexIssue5667() @@ -192,4 +219,5 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests Assert.AreEqual(1.0, seq.Median()); } } +#endif } diff --git a/src/UnitTests/TrigonometryTest.cs b/src/UnitTests/TrigonometryTest.cs index d55ae7f3..ee4c7b08 100644 --- a/src/UnitTests/TrigonometryTest.cs +++ b/src/UnitTests/TrigonometryTest.cs @@ -1,4 +1,4 @@ -// +// // Math.NET Numerics, part of the Math.NET Project // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics @@ -43,12 +43,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexCosine( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -1.19209289550780998537e-7)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -8.388608e6)] double imag, - [Values(1.0, -0.90175467375875928, -0.90175467375875928, 0.99999999999999289, 0.99999999999999289, -0.90175467375876572, double.PositiveInfinity)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, -5.1528001100635277e-8, double.NegativeInfinity)] double expectedImag) + [TestCase(0.0, 0.0, 1.0, 0.0)] + [TestCase(8.388608e6, 0.0, -0.90175467375875928, 0.0)] + [TestCase(-8.388608e6, 0.0, -0.90175467375875928, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 0.99999999999999289, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, 0.99999999999999289, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, -0.90175467375876572, -5.1528001100635277e-8)] + [TestCase(-1.19209289550780998537e-7, -8.388608e6, double.PositiveInfinity, double.NegativeInfinity)] + public void CanComputeComplexCosine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).Cosine(); var expected = new Complex(expectedReal, expectedImag); @@ -62,12 +64,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexSine( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -1.19209289550780998537e-7)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -8.388608e6)] double imag, - [Values(0.0, 0.43224820225679778, -0.43224820225679778, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 0.43224820225680083, double.NegativeInfinity)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, -1.0749753400787824e-7, double.NegativeInfinity)] double expectedImag) + [TestCase(0.0, 0.0, 0.0, 0.0)] + [TestCase(8.388608e6, 0.0, 0.43224820225679778, 0.0)] + [TestCase(-8.388608e6, 0.0, -0.43224820225679778, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.19209289550780998537e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.19209289550780998537e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 0.43224820225680083, -1.0749753400787824e-7)] + [TestCase(-1.19209289550780998537e-7, -8.388608e6, double.NegativeInfinity, double.NegativeInfinity)] + public void CanComputeComplexSine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).Sine(); var expected = new Complex(expectedReal, expectedImag); @@ -81,12 +85,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexTangent( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double imag, - [Values(0.0, -0.47934123862654288, 0.47934123862654288, 1.1920928955078157e-7, -1.1920928955078157e-7, -0.47934123862653449, 0.47934123862653449)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.4659977233982276e-7, -1.4659977233982276e-7)] double expectedImag) + [TestCase(0.0, 0.0, 0.0, 0.0)] + [TestCase(8.388608e6, 0.0, -0.47934123862654288, 0.0)] + [TestCase(-8.388608e6, 0.0, 0.47934123862654288, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078157e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078157e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, -0.47934123862653449, 1.4659977233982276e-7)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 0.47934123862653449, -1.4659977233982276e-7)] + public void CanComputeComplexTangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).Tangent(); var expected = new Complex(expectedReal, expectedImag); @@ -98,10 +104,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeCosecant( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(double.PositiveInfinity, 2.3134856195559191, 8388608.0000000376, -2.3134856195559191, -8388608.0000000376)] double expected) + [TestCase(0.0, double.PositiveInfinity)] + [TestCase(8388608, 2.3134856195559191)] + [TestCase(1.19209289550780998537e-7, 8388608.0000000376)] + [TestCase(-8388608, -2.3134856195559191)] + [TestCase(-1.19209289550780998537e-7, -8388608.0000000376)] + public void CanComputeCosecant(double value, double expected) { var actual = Trig.Cosecant(value); AssertHelpers.AlmostEqual(expected, actual, 13); @@ -112,10 +120,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeCosine( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(1.0, -0.90175467375875928, 0.99999999999999289, -0.90175467375875928, 0.99999999999999289)] double expected) + [TestCase(0.0, 1.0)] + [TestCase(8388608, -0.90175467375875928)] + [TestCase(1.19209289550780998537e-7, 0.99999999999999289)] + [TestCase(-8388608, -0.90175467375875928)] + [TestCase(-1.19209289550780998537e-7, 0.99999999999999289)] + public void CanComputeCosine(double value, double expected) { var actual = Trig.Cosine(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -126,10 +136,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeCotangent( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(double.PositiveInfinity, -2.086196470108229, 8388607.999999978, 2.086196470108229, -8388607.999999978)] double expected) + [TestCase(0.0, double.PositiveInfinity)] + [TestCase(8388608, -2.086196470108229)] + [TestCase(1.19209289550780998537e-7, 8388607.999999978)] + [TestCase(-8388608, 2.086196470108229)] + [TestCase(-1.19209289550780998537e-7, -8388607.999999978)] + public void CanComputeCotangent(double value, double expected) { var actual = Trig.Cotangent(value); AssertHelpers.AlmostEqual(expected, actual, 13); @@ -140,10 +152,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeHyperbolicCosecant( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(double.PositiveInfinity, 1.3670377960148449e-3643126, 8388607.9999999978, -1.3670377960148449e-3643126, -8388607.9999999978)] double expected) + [TestCase(0.0, double.PositiveInfinity)] + [TestCase(8388608, 1.3670377960148449e-3643126)] + [TestCase(1.19209289550780998537e-7, 8388607.9999999978)] + [TestCase(-8388608, -1.3670377960148449e-3643126)] + [TestCase(-1.19209289550780998537e-7, -8388607.9999999978)] + public void CanComputeHyperbolicCosecant(double value, double expected) { var actual = Trig.HyperbolicCosecant(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -154,10 +168,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeHyperbolicCosine( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(1.0, double.PositiveInfinity, 1.0000000000000071, double.PositiveInfinity, 1.0000000000000071)] double expected) + [TestCase(0.0, 1.0)] + [TestCase(8388608, double.PositiveInfinity)] + [TestCase(1.19209289550780998537e-7, 1.0000000000000071)] + [TestCase(-8388608, double.PositiveInfinity)] + [TestCase(-1.19209289550780998537e-7, 1.0000000000000071)] + public void CanComputeHyperbolicCosine(double value, double expected) { var actual = Trig.HyperbolicCosine(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -168,10 +184,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeHyperbolicCotangent( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(double.PositiveInfinity, 1.0, 8388608.0000000574, -1.0, -8388608.0000000574)] double expected) + [TestCase(0.0, double.PositiveInfinity)] + [TestCase(8388608, 1.0)] + [TestCase(1.19209289550780998537e-7, 8388608.0000000574)] + [TestCase(-8388608, -1.0)] + [TestCase(-1.19209289550780998537e-7, -8388608.0000000574)] + public void CanComputeHyperbolicCotangent(double value, double expected) { var actual = Trig.HyperbolicCotangent(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -182,10 +200,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeHyperbolicSecant( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(1.0, 1.3670377960148449e-3643126, 0.99999999999999289, 1.3670377960148449e-3643126, 0.99999999999999289)] double expected) + [TestCase(0.0, 1.0)] + [TestCase(8388608, 1.3670377960148449e-3643126)] + [TestCase(1.19209289550780998537e-7, 0.99999999999999289)] + [TestCase(-8388608, 1.3670377960148449e-3643126)] + [TestCase(-1.19209289550780998537e-7, 0.99999999999999289)] + public void CanComputeHyperbolicSecant(double value, double expected) { var actual = Trig.HyperbolicSecant(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -196,10 +216,11 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeHyperbolicSine( - [Values(8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(double.PositiveInfinity, 1.1920928955078128e-7, double.NegativeInfinity, -1.1920928955078128e-7)] double expected) + [TestCase(8388608, double.PositiveInfinity)] + [TestCase(1.19209289550780998537e-7, 1.1920928955078128e-7)] + [TestCase(-8388608, double.NegativeInfinity)] + [TestCase(-1.19209289550780998537e-7, -1.1920928955078128e-7)] + public void CanComputeHyperbolicSine(double value, double expected) { var actual = Trig.HyperbolicSine(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -210,10 +231,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeHyperbolicTangent( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(0.0, 1.0, 1.1920928955078043e-7, -1.0, -1.1920928955078043e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(8388608, 1.0)] + [TestCase(1.19209289550780998537e-7, 1.1920928955078043e-7)] + [TestCase(-8388608, -1.0)] + [TestCase(-1.19209289550780998537e-7, -1.1920928955078043e-7)] + public void CanComputeHyperbolicTangent(double value, double expected) { var actual = Trig.HyperbolicTangent(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -224,10 +247,11 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseCosecant( - [Values(8388608, -8388608, 1, -1)] double value, - [Values(1.1920928955078097e-7, -1.1920928955078097e-7, 1.5707963267948966, -1.5707963267948966)] double expected) + [TestCase(8388608, 1.1920928955078097e-7)] + [TestCase(-8388608, -1.1920928955078097e-7)] + [TestCase(1, 1.5707963267948966)] + [TestCase(-1, -1.5707963267948966)] + public void CanComputeInverseCosecant(double value, double expected) { var actual = Trig.InverseCosecant(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -238,10 +262,11 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseCosine( - [Values(1, -1, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0, 3.1415926535897931, 1.570796207585607, 1.5707964460041861)] double expected) + [TestCase(1, 0)] + [TestCase(-1, 3.1415926535897931)] + [TestCase(1.19209289550780998537e-7, 1.570796207585607)] + [TestCase(-1.19209289550780998537e-7, 1.5707964460041861)] + public void CanComputeInverseCosine(double value, double expected) { var actual = Trig.InverseCosine(value); AssertHelpers.AlmostEqual(expected, actual, 15); @@ -252,10 +277,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseCotangent( - [Values(0.0, 8388608, -8388608, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(1.5707963267948966, 1.1920928955078069e-7, -1.1920928955078069e-7, 1.5707962075856071, -1.5707962075856071)] double expected) + [TestCase(0.0, 1.5707963267948966)] + [TestCase(8388608, 1.1920928955078069e-7)] + [TestCase(-8388608, -1.1920928955078069e-7)] + [TestCase(1.19209289550780998537e-7, 1.5707962075856071)] + [TestCase(-1.19209289550780998537e-7, -1.5707962075856071)] + public void CanComputeInverseCotangent(double value, double expected) { var actual = Trig.InverseCotangent(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -266,10 +293,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseHyperbolicCosecant( - [Values(0.0, 8388608, -8388608, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(double.PositiveInfinity, 1.1920928955078097e-7, -1.1920928955078097e-7, 16.635532333438693, -16.635532333438693)] double expected) + [TestCase(0.0, double.PositiveInfinity)] + [TestCase(8388608, 1.1920928955078097e-7)] + [TestCase(-8388608, -1.1920928955078097e-7)] + [TestCase(1.19209289550780998537e-7, 16.635532333438693)] + [TestCase(-1.19209289550780998537e-7, -16.635532333438693)] + public void CanComputeInverseHyperbolicCosecant(double value, double expected) { var actual = Trig.InverseHyperbolicCosecant(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -280,8 +309,9 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseHyperbolicCosine([Values(1.0, 8388608)] double value, [Values(0.0, 16.635532333438682)] double expected) + [TestCase(1.0, 0.0)] + [TestCase(8388608, 16.635532333438682)] + public void CanComputeInverseHyperbolicCosine(double value, double expected) { var actual = Trig.InverseHyperbolicCosine(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -292,8 +322,11 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseHyperbolicCotangent([Values(8388608, -8388608, 1, -1)] double value, [Values(1.1920928955078181e-7, -1.1920928955078181e-7, double.PositiveInfinity, double.NegativeInfinity)] double expected) + [TestCase(8388608, 1.1920928955078181e-7)] + [TestCase(-8388608, -1.1920928955078181e-7)] + [TestCase(1, double.PositiveInfinity)] + [TestCase(-1, double.NegativeInfinity)] + public void CanComputeInverseHyperbolicCotangent(double value, double expected) { var actual = Trig.InverseHyperbolicCotangent(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -304,8 +337,10 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseHyperbolicSecant([Values(0, 0.5, 1)] double value, [Values(double.PositiveInfinity, 1.3169578969248167, 0.0)] double expected) + [TestCase(0, double.PositiveInfinity)] + [TestCase(0.5, 1.3169578969248167)] + [TestCase(1, 0.0)] + public void CanComputeInverseHyperbolicSecant(double value, double expected) { var actual = Trig.InverseHyperbolicSecant(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -316,10 +351,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseHyperbolicSine( - [Values(0.0, 8388608, -8388608, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0.0, 16.63553233343869, -16.63553233343869, 1.1920928955078072e-7, -1.1920928955078072e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(8388608, 16.63553233343869)] + [TestCase(-8388608, -16.63553233343869)] + [TestCase(1.19209289550780998537e-7, 1.1920928955078072e-7)] + [TestCase(-1.19209289550780998537e-7, -1.1920928955078072e-7)] + public void CanComputeInverseHyperbolicSine(double value, double expected) { var actual = Trig.InverseHyperbolicSine(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -330,10 +367,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseHyperbolicTangent( - [Values(0.0, 1.0, -1.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0.0, double.PositiveInfinity, double.NegativeInfinity, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(1.0, double.PositiveInfinity)] + [TestCase(-1.0, double.NegativeInfinity)] + [TestCase(1.19209289550780998537e-7, 1.19209289550780998537e-7)] + [TestCase(-1.19209289550780998537e-7, -1.19209289550780998537e-7)] + public void CanComputeInverseHyperbolicTangent(double value, double expected) { var actual = Trig.InverseHyperbolicTangent(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -344,10 +383,11 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseSecant( - [Values(8388608, -8388608, 1.0, -1.0)] double value, - [Values(1.5707962075856071, 1.5707964460041862, 0.0, 3.1415926535897932)] double expected) + [TestCase(8388608, 1.5707962075856071)] + [TestCase(-8388608, 1.5707964460041862)] + [TestCase(1.0, 0.0)] + [TestCase(-1.0, 3.1415926535897932)] + public void CanComputeInverseSecant(double value, double expected) { var actual = Trig.InverseSecant(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -358,10 +398,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseSine( - [Values(0.0, 1.0, -1.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0.0, 1.5707963267948966, -1.5707963267948966, 1.1920928955078128e-7, -1.1920928955078128e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(1.0, 1.5707963267948966)] + [TestCase(-1.0, -1.5707963267948966)] + [TestCase(1.19209289550780998537e-7, 1.1920928955078128e-7)] + [TestCase(-1.19209289550780998537e-7, -1.1920928955078128e-7)] + public void CanComputeInverseSine(double value, double expected) { var actual = Trig.InverseSine(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -372,10 +414,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeInverseTangent( - [Values(0.0, 8388608, -8388608, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0.0, 1.570796207585607, -1.570796207585607, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(8388608, 1.570796207585607)] + [TestCase(-8388608, -1.570796207585607)] + [TestCase(1.19209289550780998537e-7, 1.19209289550780998537e-7)] + [TestCase(-1.19209289550780998537e-7, -1.19209289550780998537e-7)] + public void CanComputeInverseTangent(double value, double expected) { var actual = Trig.InverseTangent(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -386,10 +430,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeSecant( - [Values(0.0, 8388608, 1.19209289550780998537e-7, -8388608, -1.19209289550780998537e-7)] double value, - [Values(1.0, -1.1089490624226292, 1.0000000000000071, -1.1089490624226292, 1.0000000000000071)] double expected) + [TestCase(0.0, 1.0)] + [TestCase(8388608, -1.1089490624226292)] + [TestCase(1.19209289550780998537e-7, 1.0000000000000071)] + [TestCase(-8388608, -1.1089490624226292)] + [TestCase(-1.19209289550780998537e-7, 1.0000000000000071)] + public void CanComputeSecant(double value, double expected) { var actual = Trig.Secant(value); AssertHelpers.AlmostEqual(expected, actual, 14); @@ -400,10 +446,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeSine( - [Values(0.0, 8388608, -8388608, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0.0, 0.43224820225679778, -0.43224820225679778, 1.1920928955078072e-7, -1.1920928955078072e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(8388608, 0.43224820225679778)] + [TestCase(-8388608, -0.43224820225679778)] + [TestCase(1.19209289550780998537e-7, 1.1920928955078072e-7)] + [TestCase(-1.19209289550780998537e-7, -1.1920928955078072e-7)] + public void CanComputeSine(double value, double expected) { var actual = Trig.Sine(value); AssertHelpers.AlmostEqual(expected, actual, 13); @@ -414,10 +462,12 @@ namespace MathNet.Numerics.UnitTests /// /// Input value. /// Expected value. - [Test, Sequential] - public void CanComputeTangent( - [Values(0.0, 8388608, -8388608, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double value, - [Values(0.0, -0.47934123862654288, 0.47934123862654288, 1.1920928955078157e-7, -1.1920928955078157e-7)] double expected) + [TestCase(0.0, 0.0)] + [TestCase(8388608, -0.47934123862654288)] + [TestCase(-8388608, 0.47934123862654288)] + [TestCase(1.19209289550780998537e-7, 1.1920928955078157e-7)] + [TestCase(-1.19209289550780998537e-7, -1.1920928955078157e-7)] + public void CanComputeTangent(double value, double expected) { var actual = Trig.Tangent(value); AssertHelpers.AlmostEqual(expected, actual, 13); @@ -484,12 +534,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexCotangent( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double imag, - [Values(double.PositiveInfinity, -2.086196470108229, 2.086196470108229, 8388607.999999978, -8388607.999999978, -2.0861964701080704, 2.0861964701080704)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, -6.3803383253713457e-7, 6.3803383253713457e-7)] double expectedImag) + [TestCase(0.0, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(8.388608e6, 0.0, -2.086196470108229, 0.0)] + [TestCase(-8.388608e6, 0.0, 2.086196470108229, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 8388607.999999978, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -8388607.999999978, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, -2.0861964701080704, -6.3803383253713457e-7)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 2.0861964701080704, 6.3803383253713457e-7)] + public void CanComputeComplexCotangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).Cotangent(); var expected = new Complex(expectedReal, expectedImag); @@ -503,12 +555,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexSecant( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double imag, - [Values(1.0, -1.1089490624226292, -1.1089490624226292, 1.0000000000000071, 1.0000000000000071, -1.1089490624226177, -1.1089490624226177)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 6.3367488045143761e-8, 6.3367488045143761e-8)] double expectedImag) + [TestCase(0.0, 0.0, 1.0, 0.0)] + [TestCase(8.388608e6, 0.0, -1.1089490624226292, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.1089490624226292, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.0000000000000071, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, 1.0000000000000071, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, -1.1089490624226177, 6.3367488045143761e-8)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.1089490624226177, 6.3367488045143761e-8)] + public void CanComputeComplexSecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).Secant(); var expected = new Complex(expectedReal, expectedImag); @@ -522,12 +576,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexCosecant( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7)] double imag, - [Values(double.PositiveInfinity, 2.3134856195559191, -2.3134856195559191, 8388608.0000000376, -8388608.0000000376, 2.3134856195557596, -2.3134856195557596)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 5.7534999050657057e-7, -5.7534999050657057e-7)] double expectedImag) + [TestCase(0.0, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(8.388608e6, 0.0, 2.3134856195559191, 0.0)] + [TestCase(-8.388608e6, 0.0, -2.3134856195559191, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 8388608.0000000376, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -8388608.0000000376, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 2.3134856195557596, 5.7534999050657057e-7)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -2.3134856195557596, -5.7534999050657057e-7)] + public void CanComputeComplexCosecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).Cosecant(); var expected = new Complex(expectedReal, expectedImag); @@ -541,12 +597,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexHyperbolicSine( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(0.0, double.PositiveInfinity, double.NegativeInfinity, 1.1920928955078128e-7, -1.1920928955078128e-7, double.PositiveInfinity, double.NegativeInfinity, 0.45730415318424922)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, double.PositiveInfinity, double.NegativeInfinity, -0.54061268571315335)] double expectedImag) + [TestCase(0.0, 0.0, 0.0, 0.0)] + [TestCase(8.388608e6, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(-8.388608e6, 0.0, double.NegativeInfinity, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078128e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078128e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, double.PositiveInfinity, double.PositiveInfinity)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, double.NegativeInfinity, double.NegativeInfinity)] + [TestCase(0.5, -0.5, 0.45730415318424922, -0.54061268571315335)] + public void CanComputeComplexHyperbolicSine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).HyperbolicSine(); var expected = new Complex(expectedReal, expectedImag); @@ -560,12 +619,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexHyperbolicCosine( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.0, double.PositiveInfinity, double.PositiveInfinity, 1.0000000000000071, 1.0000000000000071, double.PositiveInfinity, double.PositiveInfinity, 0.9895848833999199)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, double.PositiveInfinity, double.PositiveInfinity, -0.24982639750046154)] double expectedImag) + [TestCase(0.0, 0.0, 1.0, 0.0)] + [TestCase(8.388608e6, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(-8.388608e6, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.0000000000000071, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, 1.0000000000000071, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, double.PositiveInfinity, double.PositiveInfinity)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, double.PositiveInfinity, double.PositiveInfinity)] + [TestCase(0.5, -0.5, 0.9895848833999199, -0.24982639750046154)] + public void CanComputeComplexHyperbolicCosine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).HyperbolicCosine(); var expected = new Complex(expectedReal, expectedImag); @@ -579,12 +641,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexHyperbolicTangent( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(0.0, 1.0, -1.0, 1.1920928955078043e-7, -1.1920928955078043e-7, 1.0, -1.0, 0.56408314126749848)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.40389645531602575)] double expectedImag) + [TestCase(0.0, 0.0, 0.0, 0.0)] + [TestCase(8.388608e6, 0.0, 1.0, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.0, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078043e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078043e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.0, 0.0)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.0, 0.0)] + [TestCase(0.5, -0.5, 0.56408314126749848, -0.40389645531602575)] + public void CanComputeComplexHyperbolicTangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).HyperbolicTangent(); var expected = new Complex(expectedReal, expectedImag); @@ -598,12 +663,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexHyperbolicCotangent( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(double.PositiveInfinity, 1.0, -1.0, 8388608.0000000574, -8388608.0000000574, 1.0, -1.0, 1.1719451445243514)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.8391395790248311)] double expectedImag) + [TestCase(0.0, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(8.388608e6, 0.0, 1.0, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.0, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 8388608.0000000574, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -8388608.0000000574, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.0, 0.0)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.0, 0.0)] + [TestCase(0.5, -0.5, 1.1719451445243514, -0.8391395790248311)] + public void CanComputeComplexHyperbolicCotangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).HyperbolicCotangent(); var expected = new Complex(expectedReal, expectedImag); @@ -617,12 +685,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexHyperbolicSecant( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.0, 0.0, 0.0, 0.99999999999999289, 0.99999999999999289, 0.0, -0.0, 0.94997886761549463)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.23982763093808804)] double expectedImag) + [TestCase(0.0, 0.0, 1.0, 0.0)] + [TestCase(8.388608e6, 0.0, 0.0, 0.0)] + [TestCase(-8.388608e6, 0.0, 0.0, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 0.99999999999999289, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, 0.99999999999999289, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 0.0, 0.0)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -0.0, 0.0)] + [TestCase(0.5, -0.5, 0.94997886761549463, 0.23982763093808804)] + public void CanComputeComplexHyperbolicSecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).HyperbolicSecant(); var expected = new Complex(expectedReal, expectedImag); @@ -636,12 +707,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexHyperbolicCosecant( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(double.PositiveInfinity, 0.0, 0.0, 8388607.9999999978, -8388607.9999999978, 0.0, 0.0, 0.91207426403881078)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0782296946540223)] double expectedImag) + [TestCase(0.0, 0.0, double.PositiveInfinity, 0.0)] + [TestCase(8.388608e6, 0.0, 0.0, 0.0)] + [TestCase(-8.388608e6, 0.0, 0.0, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 8388607.9999999978, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -8388607.9999999978, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 0.0, 0.0)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 0.0, 0.0)] + [TestCase(0.5, -0.5, 0.91207426403881078, 1.0782296946540223)] + public void CanComputeComplexHyperbolicCosecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).HyperbolicCosecant(); var expected = new Complex(expectedReal, expectedImag); @@ -655,12 +729,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseSine( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(0.0, 1.5707963267948966, -1.5707963267948966, 1.1920928955078128e-7, -1.1920928955078128e-7, 1.5707963267948966, -1.5707963267948966, 0.4522784471511907)] double expectedReal, - [Values(0.0, -16.635532333438682, 16.635532333438682, 0.0, 0.0, 16.635532333438682, -16.635532333438682, -0.53063753095251787)] double expectedImag) + [TestCase(0.0, 0.0, 0.0, 0.0)] + [TestCase(8.388608e6, 0.0, 1.5707963267948966, -16.635532333438682)] + [TestCase(-8.388608e6, 0.0, -1.5707963267948966, 16.635532333438682)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078128e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078128e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.5707963267948966, 16.635532333438682)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.5707963267948966, -16.635532333438682)] + [TestCase(0.5, -0.5, 0.4522784471511907, -0.53063753095251787)] + public void CanComputeComplexInverseSine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseSine(); var expected = new Complex(expectedReal, expectedImag); @@ -674,12 +751,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseCosine( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.5707963267948966, 0.0, 3.1415926535897931, 1.570796207585607, 1.5707964460041861, 1.4210854715202073e-14, 3.1415926535897789, 1.1185178796437059)] double expectedReal, - [Values(0.0, 16.635532333438682, -16.635532333438682, 0.0, 0.0, -16.635532333438682, 16.63553233343868, 0.53063753095251787)] double expectedImag) + [TestCase(0.0, 0.0, 1.5707963267948966, 0.0)] + [TestCase(8.388608e6, 0.0, 0.0, 16.635532333438682)] + [TestCase(-8.388608e6, 0.0, 3.1415926535897931, -16.635532333438682)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.570796207585607, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, 1.5707964460041861, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.4210854715202073e-14, -16.635532333438682)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 3.1415926535897789, 16.63553233343868)] + [TestCase(0.5, -0.5, 1.1185178796437059, 0.53063753095251787)] + public void CanComputeComplexInverseCosine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseCosine(); var expected = new Complex(expectedReal, expectedImag); @@ -693,12 +773,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseTangent( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(0.0, 1.570796207585607, -1.570796207585607, 1.1920928955078043e-7, -1.1920928955078043e-7, 1.570796207585607, -1.570796207585607, 0.5535743588970452)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.40235947810852507)] double expectedImag) + [TestCase(0.0, 0.0, 0.0, 0.0)] + [TestCase(8.388608e6, 0.0, 1.570796207585607, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.570796207585607, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078043e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078043e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.570796207585607, 0.0)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.570796207585607, 0.0)] + [TestCase(0.5, -0.5, 0.5535743588970452, -0.40235947810852507)] + public void CanComputeComplexInverseTangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseTangent(); var expected = new Complex(expectedReal, expectedImag); @@ -712,12 +795,15 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseCotangent( - [Values(0.0, 8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(Math.PI / 2.0, 1.1920928955078069e-7, -1.1920928955078069e-7, 1.5707962075856071, -1.5707962075856071, 1.1920928955078069e-7, -1.1920928955078069e-7, 1.0172219678978514)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 0.0, -1.6907571720583645e-21, 1.6907571720583645e-21, 0.40235947810852509)] double expectedImag) + [TestCase(0.0, 0.0, Math.PI / 2.0, 0.0)] + [TestCase(8.388608e6, 0.0, 1.1920928955078069e-7, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.1920928955078069e-7, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.5707962075856071, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.5707962075856071, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.1920928955078069e-7, -1.6907571720583645e-21)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.1920928955078069e-7, 1.6907571720583645e-21)] + [TestCase(0.5, -0.5, 1.0172219678978514, 0.40235947810852509)] + public void CanComputeComplexInverseCotangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseCotangent(); var expected = new Complex(expectedReal, expectedImag); @@ -731,12 +817,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseSecant( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.5707962075856071, 1.5707964460041862, 0.0, 3.1415926535897932, 1.5707962075856071, 1.5707964460041862, 0.90455689430238136)] double expectedReal, - [Values(0.0, 0.0, 16.635532333438686, -16.635532333438686, 1.6940658945086007e-21, -1.6940658945086007e-21, -1.0612750619050357)] double expectedImag) + [TestCase(8.388608e6, 0.0, 1.5707962075856071, 0.0)] + [TestCase(-8.388608e6, 0.0, 1.5707964460041862, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 0.0, 16.635532333438686)] + [TestCase(-1.19209289550780998537e-7, 0.0, 3.1415926535897932, -16.635532333438686)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.5707962075856071, 1.6940658945086007e-21)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 1.5707964460041862, -1.6940658945086007e-21)] + [TestCase(0.5, -0.5, 0.90455689430238136, -1.0612750619050357)] + public void CanComputeComplexInverseSecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseSecant(); var expected = new Complex(expectedReal, expectedImag); @@ -750,12 +838,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseCosecant( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.1920928955078153e-7, -1.1920928955078153e-7, 1.5707963267948966, -1.5707963267948966, 1.1920928955078153e-7, -1.1920928955078153e-7, 0.66623943249251526)] double expectedReal, - [Values(0.0, 0.0, -16.635532333438686, 16.635532333438686, -1.6940658945086007e-21, 1.6940658945086007e-21, 1.0612750619050357)] double expectedImag) + [TestCase(8.388608e6, 0.0, 1.1920928955078153e-7, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.1920928955078153e-7, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.5707963267948966, -16.635532333438686)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.5707963267948966, 16.635532333438686)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.1920928955078153e-7, -1.6940658945086007e-21)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.1920928955078153e-7, 1.6940658945086007e-21)] + [TestCase(0.5, -0.5, 0.66623943249251526, 1.0612750619050357)] + public void CanComputeComplexInverseCosecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseCosecant(); var expected = new Complex(expectedReal, expectedImag); @@ -769,12 +859,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseHyperbolicSine( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(16.63553233343869, -16.63553233343869, 1.1920928955078072e-7, -1.1920928955078072e-7, 16.63553233343869, -16.63553233343869, 0.53063753095251787)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, 1.4210854715201873e-14, -1.4210854715201873e-14, -0.4522784471511907)] double expectedImag) + [TestCase(8.388608e6, 0.0, 16.63553233343869, 0.0)] + [TestCase(-8.388608e6, 0.0, -16.63553233343869, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078072e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078072e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 16.63553233343869, 1.4210854715201873e-14)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -16.63553233343869, -1.4210854715201873e-14)] + [TestCase(0.5, -0.5, 0.53063753095251787, -0.4522784471511907)] + public void CanComputeComplexInverseHyperbolicSine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseHyperbolicSine(); var expected = new Complex(expectedReal, expectedImag); @@ -788,12 +880,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseHyperbolicCosine( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(16.635532333438682, 16.635532333438682, 0.0, 0.0, 16.635532333438682, 16.635532333438682, 0.53063753095251787)] double expectedReal, - [Values(0.0, 3.1415926535897931, 1.570796207585607, 1.5707964460041861, 1.4210854715202073e-14, -3.1415926535897789, -1.1185178796437059)] double expectedImag) + [TestCase(8.388608e6, 0.0, 16.635532333438682, 0.0)] + [TestCase(-8.388608e6, 0.0, 16.635532333438682, 3.1415926535897931)] + [TestCase(1.19209289550780998537e-7, 0.0, 0.0, 1.570796207585607)] + [TestCase(-1.19209289550780998537e-7, 0.0, 0.0, 1.5707964460041861)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 16.635532333438682, 1.4210854715202073e-14)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 16.635532333438682, -3.1415926535897789)] + [TestCase(0.5, -0.5, 0.53063753095251787, -1.1185178796437059)] + public void CanComputeComplexInverseHyperbolicCosine(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseHyperbolicCosine(); var expected = new Complex(expectedReal, expectedImag); @@ -807,12 +901,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseHyperbolicTangent( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.1920928955078125e-7, -1.1920928955078125e-7, 1.1920928955078157e-7, -1.1920928955078157e-7, 1.1920928955078125e-7, -1.1920928955078125e-7, 0.40235947810852509)] double expectedReal, - [Values(-1.5707963267948966, 1.5707963267948966, 0.0, 0.0, 1.5707963267948966, -1.5707963267948966, -0.55357435889704525)] double expectedImag) + [TestCase(8.388608e6, 0.0, 1.1920928955078125e-7, -1.5707963267948966)] + [TestCase(-8.388608e6, 0.0, -1.1920928955078125e-7, 1.5707963267948966)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078157e-7, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078157e-7, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.1920928955078125e-7, 1.5707963267948966)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.1920928955078125e-7, -1.5707963267948966)] + [TestCase(0.5, -0.5, 0.40235947810852509, -0.55357435889704525)] + public void CanComputeComplexInverseHyperbolicTangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseHyperbolicTangent(); var expected = new Complex(expectedReal, expectedImag); @@ -826,12 +922,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseHyperbolicCotangent( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.1920928955078181e-7, -1.1920928955078181e-7, 1.1920928955078157e-7, -1.1920928955078157e-7, 1.1920928955078181e-7, -1.1920928955078181e-7, 0.40235947810852509)] double expectedReal, - [Values(0.0, 0.0, -1.5707963267948966, 1.5707963267948966, -1.6940658945086212e-21, 1.6940658945086212e-21, 1.0172219678978514)] double expectedImag) + [TestCase(8.388608e6, 0.0, 1.1920928955078181e-7, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.1920928955078181e-7, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 1.1920928955078157e-7, -1.5707963267948966)] + [TestCase(-1.19209289550780998537e-7, 0.0, -1.1920928955078157e-7, 1.5707963267948966)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.1920928955078181e-7, -1.6940658945086212e-21)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.1920928955078181e-7, 1.6940658945086212e-21)] + [TestCase(0.5, -0.5, 0.40235947810852509, 1.0172219678978514)] + public void CanComputeComplexInverseHyperbolicCotangent(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseHyperbolicCotangent(); var expected = new Complex(expectedReal, expectedImag); @@ -845,12 +943,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseHyperbolicSecant( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(0.0, 0.0, 16.635532333438686, 16.635532333438686, 1.6940658945086007e-21, 1.6940658945086007e-21, 1.0612750619050357)] double expectedReal, - [Values(1.5707962075856071, 1.5707964460041862, 0.0, 3.1415926535897932, -1.5707962075856071, 1.5707964460041862, 0.90455689430238136)] double expectedImag) + [TestCase(8.388608e6, 0.0, 0.0, 1.5707962075856071)] + [TestCase(-8.388608e6, 0.0, 0.0, 1.5707964460041862)] + [TestCase(1.19209289550780998537e-7, 0.0, 16.635532333438686, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, 16.635532333438686, 3.1415926535897932)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.6940658945086007e-21, -1.5707962075856071)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, 1.6940658945086007e-21, 1.5707964460041862)] + [TestCase(0.5, -0.5, 1.0612750619050357, 0.90455689430238136)] + public void CanComputeComplexInverseHyperbolicSecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseHyperbolicSecant(); var expected = new Complex(expectedReal, expectedImag); @@ -864,12 +964,14 @@ namespace MathNet.Numerics.UnitTests /// Input complex imaginary part. /// Expected complex real part. /// Expected complex imaginary part. - [Test, Sequential] - public void CanComputeComplexInverseHyperbolicCosecant( - [Values(8.388608e6, -8.388608e6, 1.19209289550780998537e-7, -1.19209289550780998537e-7, 8.388608e6, -8.388608e6, 0.5)] double real, - [Values(0.0, 0.0, 0.0, 0.0, 1.19209289550780998537e-7, -1.19209289550780998537e-7, -0.5)] double imag, - [Values(1.1920928955078097e-7, -1.1920928955078097e-7, 16.635532333438693, -16.635532333438693, 1.1920928955078076e-7, -1.1920928955078076e-7, 1.0612750619050357)] double expectedReal, - [Values(0.0, 0.0, 0.0, 0.0, -1.6940658945085851e-21, 1.6940658945085851e-21, 0.66623943249251526)] double expectedImag) + [TestCase(8.388608e6, 0.0, 1.1920928955078097e-7, 0.0)] + [TestCase(-8.388608e6, 0.0, -1.1920928955078097e-7, 0.0)] + [TestCase(1.19209289550780998537e-7, 0.0, 16.635532333438693, 0.0)] + [TestCase(-1.19209289550780998537e-7, 0.0, -16.635532333438693, 0.0)] + [TestCase(8.388608e6, 1.19209289550780998537e-7, 1.1920928955078076e-7, -1.6940658945085851e-21)] + [TestCase(-8.388608e6, -1.19209289550780998537e-7, -1.1920928955078076e-7, 1.6940658945085851e-21)] + [TestCase(0.5, -0.5, 1.0612750619050357, 0.66623943249251526)] + public void CanComputeComplexInverseHyperbolicCosecant(double real, double imag, double expectedReal, double expectedImag) { var actual = new Complex(real, imag).InverseHyperbolicCosecant(); var expected = new Complex(expectedReal, expectedImag); diff --git a/src/UnitTests/UnitTests.csproj b/src/UnitTests/UnitTests.csproj index aea82eb1..12ca55fe 100644 --- a/src/UnitTests/UnitTests.csproj +++ b/src/UnitTests/UnitTests.csproj @@ -51,6 +51,7 @@ + Code