sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 481 forks source link

Random symmetric, skew symmetric etc. matrices #18143

Open f29946bc-ee7b-48cd-9abc-3445948c551d opened 9 years ago

f29946bc-ee7b-48cd-9abc-3445948c551d commented 9 years ago

Add a function to generate random matrices that are, for example, symmetric, skew symmetric, upper/lower triangular etc.

Vincent Delecroix (is sage-devel -list) suggests having several keywords:

bilinear forms: skew-symmetric, symmetric, orthogonal, ... shape: upper triangular, lower triangular, diagonal, max_width, ... conjugacy class invariants: determinant, trace, characteristic polynomial, ...

Even if we don't implement many of those, we should have interface that is easy to expand later.

CC: @videlec @kalvotom @pelegm

Component: linear algebra

Issue created by migration from https://trac.sagemath.org/ticket/18143

orlitzky commented 9 years ago
comment:1

I needed this once for a few special classes of matrices. A few things turned out to be necessary that I initially didn't consider. The ability to specify,

I have random_psd() here:

http://michael.orlitzky.com/git/?p=sage.d.git;a=blob;f=mjo/cone/symmetric_psd.py;h=bb46fc926ec8dc23588ef08ea49a974060a02841;hb=HEAD

and you can feel free to steal that code.

What I really wanted, in that case, was a doubly-non-negative matrix. I implemented random_doubly_nonnegative() too if you promise not to laugh at my algorithm.

http://michael.orlitzky.com/git/?p=sage.d.git;a=blob;f=mjo/cone/doubly_nonnegative.py;h=56a655e52c5cd60cbf1073c351e65833e5f54500;hb=HEAD

Per the docstrings, "random" is a bit of a euphemism.

videlec commented 9 years ago
comment:2

Hello,

I think we should change the keyword algorithm. The fact that output satisfies such and such properties (=specification) is not the way it is generated (=algorithm). I suggest to move the properties to separated keywords as we might want combination of keywords here.

Anyway, having only one function handling all of this looks like too much to me.

Vincent

f29946bc-ee7b-48cd-9abc-3445948c551d commented 9 years ago
comment:3

Replying to @videlec:

Anyway, having only one function handling all of this looks like too much to me.

Then what should be names for functions, if we split this? One for random general matrix and another for square matrix? Or something for integer matrices only?

kalvotom commented 9 years ago
comment:4

Replying to @orlitzky:

Per the docstrings, "random" is a bit of a euphemism.

It might be useful to have generators of random matrix ensembles (e.g. see http://en.wikipedia.org/wiki/Random_matrix, or section 4.3 in http://web.eecs.umich.edu/~rajnrao/Acta05rmt.pdf). Then the word "random" would get a better meaning...

f29946bc-ee7b-48cd-9abc-3445948c551d commented 9 years ago

Description changed:

--- 
+++ 
@@ -1 +1,9 @@
 Add a function to generate random matrices that are, for example, symmetric, skew symmetric, upper/lower triangular etc.
+
+Vincent Delecroix (is sage-devel -list) suggests having several keywords:
+
+bilinear forms: skew-symmetric, symmetric, orthogonal, ...
+shape: upper triangular, lower triangular, diagonal, max_width, ...
+conjugacy class invariants: determinant, trace, characteristic polynomial, ...
+
+Even if we don't implement many of those, we should have interface that is easy to expand later.
f29946bc-ee7b-48cd-9abc-3445948c551d commented 9 years ago
comment:7

Can we start by adding keyword shape with possible values upper-triangular, lower-triangular, diagonal, symmetric and skew-symmetric? For now it could raise an exception when used together with algorithm -option.

videlec commented 9 years ago
comment:8

Replying to @jm58660:

Can we start by adding keyword shape with possible values upper-triangular, lower-triangular, diagonal, symmetric and skew-symmetric? For now it could raise an exception when used together with algorithm -option.

Adding the shape keyword Looks good to me. But what would we do with random_matrix(algorithm='echelon_form')? A deprecation?