# Question:How to create random matrices with constraints?

## Question:How to create random matrices with constraints?

Hello Maple insiders, I'm still learning to get along with Maple (version 10.01). Currently, I would like to have a small procedure which creates a random matrix of arbitrary dimension with complex floats. However, the generated matix, say A, has to fulfill the following conditions (because it should be a valid physical density operator): 1.) A is hermitian 2.) A is positive semidefinite, together with 1.) this should mean that A has only real and nonnegative eigenvalues 3.) A should have trace equal 1 With the randomly generated matrices I would like to cover (reasonably uniformly) the set of all possible matrices with the above constraints. I messed around with the RandomMatrix command from the LinearAlgebra package and and the Generate command from the RandomTools package. However, if I use the shape=hermitian option for the genrated matrices, I often get matrices with all diagonal entries 0 so that a trace normalization is not possible any more. On the other hand, if I come up with more complicated creation procedures (e.g. creating some random positive diagonal matrix and then do some random unitary transfomation) Maple begins to allocate large amounts of memory when I repeat this procedure in order to create several hundred random matrices. Depending on the number of repetitions this even crashes Maple (I'm using Windows XP). I'm sure there must be a simple and efficient solution for this so help is greatly appreciated. Thanks in advance! Thomas
﻿