diff --git a/src/Numerics/LinearAlgebra/Builder.cs b/src/Numerics/LinearAlgebra/Builder.cs index 955ede5d..77fafe93 100644 --- a/src/Numerics/LinearAlgebra/Builder.cs +++ b/src/Numerics/LinearAlgebra/Builder.cs @@ -34,8 +34,8 @@ using System.Linq; using MathNet.Numerics.Distributions; using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Storage; - // TODO: split up and move to proper folders +using MathNet.Numerics.Random; namespace MathNet.Numerics.LinearAlgebra.Double { @@ -442,6 +442,34 @@ namespace MathNet.Numerics.LinearAlgebra /// public abstract Matrix Random(int rows, int columns, IContinuousDistribution distribution); + /// + /// Create a new dense matrix with values sampled from the standard distribution with a mersenne twister random source. + /// + public Matrix Random(int rows, int columns) + { + return Random(rows, columns, new Normal(MersenneTwister.Default)); + } + + /// + /// Create a new positive definite dense matrix where each value is the product + /// of two samples from the provided random distribution. + /// + public Matrix RandomPositiveDefinite(int order, IContinuousDistribution distribution) + { + var a = Random(order, order, distribution); + return a.TransposeThisAndMultiply(a); + } + + /// + /// Create a new positive definite dense matrix where each value is the product + /// of two samples from the standard distribution with a mersenne twister random source. + /// + public Matrix RandomPositiveDefinite(int order) + { + var a = Random(order, order, new Normal(MersenneTwister.Default)); + return a.TransposeThisAndMultiply(a); + } + /// /// Create a new dense matrix straight from an initialized matrix storage instance. /// The storage is used directly without copying. @@ -1344,6 +1372,14 @@ namespace MathNet.Numerics.LinearAlgebra /// public abstract Vector Random(int length, IContinuousDistribution distribution); + /// + /// Create a new dense vector with values sampled from the standard distribution with a mersenne twister random source. + /// + public Vector Random(int length) + { + return Random(length, new Normal(MersenneTwister.Default)); + } + /// /// Create a new dense vector straight from an initialized vector storage instance. /// The storage is used directly without copying.