Ejemplo n.º 1
0
        /// <summary>
        /// Creates a <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="row">The number of rows.</param>
        /// <param name="col">The number of columns.</param>
        /// <returns>A <c>UserDefinedMatrix</c> with the given dimensions and random values.</returns>
        public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
            {
                RandomSource = new MersenneTwister(1)
            };
            var matrixA = new UserDefinedMatrix(row, col);

            for (var i = 0; i < row; i++)
            {
                for (var j = 0; j < col; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            return(matrixA);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a positive definite <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="order">The order of the matrix.</param>
        /// <returns>A positive definite <c>UserDefinedMatrix</c> with the given order and random values.</returns>
        public static Matrix <Complex> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
            {
                RandomSource = new MersenneTwister(1)
            };
            var matrixA = new UserDefinedMatrix(order);

            for (var i = 0; i < order; i++)
            {
                for (var j = 0; j < order; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            // Generate a Hermitian matrix which is positive definite.
            return(matrixA.ConjugateTranspose() * matrixA);
        }
Ejemplo n.º 3
0
        public static Matrix <Complex> GenerateRandomUserDefinedMatrix(int row, int col)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Distributions.Normal
            {
                RandomSource = new Numerics.Random.MersenneTwister(1)
            };
            var matrixA = new UserDefinedMatrix(row, col);

            for (var i = 0; i < row; i++)
            {
                for (var j = 0; j < col; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            // Generate a matrix which is positive definite.
            return(matrixA);
        }
        /// <summary>
        /// Creates a positive definite <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="order">The order of the matrix.</param>
        /// <returns>A positive definite <c>UserDefinedMatrix</c> with the given order and random values.</returns>
        public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                {
                    RandomSource = new MersenneTwister(1)
                };
            var matrixA = new UserDefinedMatrix(order);
            for (var i = 0; i < order; i++)
            {
                for (var j = 0; j < order; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            // Generate a Hermitian matrix which is positive definite.
            return matrixA.ConjugateTranspose()*matrixA;
        }
        /// <summary>
        /// Creates a <c>UserDefinedMatrix</c> with random values.
        /// </summary>
        /// <param name="row">The number of rows.</param>
        /// <param name="col">The number of columns.</param>
        /// <returns>A <c>UserDefinedMatrix</c> with the given dimensions and random values.</returns>
        public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Normal
                {
                    RandomSource = new MersenneTwister(1)
                };
            var matrixA = new UserDefinedMatrix(row, col);
            for (var i = 0; i < row; i++)
            {
                for (var j = 0; j < col; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            return matrixA;
        }
Ejemplo n.º 6
0
        public static Matrix<Complex> GenerateRandomUserDefinedMatrix(int row, int col)
        {
            // Fill a matrix with standard random numbers.
            var normal = new Distributions.Normal
                         {
                             RandomSource = new Random.MersenneTwister(1)
                         };
            var matrixA = new UserDefinedMatrix(row, col);
            for (var i = 0; i < row; i++)
            {
                for (var j = 0; j < col; j++)
                {
                    matrixA[i, j] = new Complex(normal.Sample(), normal.Sample());
                }
            }

            // Generate a matrix which is positive definite.
            return matrixA;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a square matrix with all zero's except for ones on the diagonal.
        /// </summary>
        /// <param name="order">the size of the square matrix.</param>
        /// <returns>A identity matrix.</returns>
        public static UserDefinedMatrix Identity(int order)
        {
            var m = new UserDefinedMatrix(order, order);
            for (var i = 0; i < order; i++)
            {
                m[i, i] = 1.0;
            }

            return m;
        }