On 10/17/07, Stochastix <[EMAIL PROTECTED]> wrote:
> I have the following problem : I need to create a random matrix
> (easily done under Octave),
What properties must the random matrix have?
How big is it? Are the entries double precision.
> make some transformations on it (Octave)
> to transform it in two integer valued matrices and then apply a Smith
> form reduction to these two matrices (easliy done in GAP).
> I know
> there is an interface between SAGE and Octave and SAGE and GAP, but i
> didn't find how to input the output of the Octave functions into GAP.
> In brief, I would like to do something like
>
> [M1,M2]=octave.eval("random_matrix(some param)")
This line doesn't make sense. octave.eval returns a string,
so you can't turn it into a list of length two with entries M1, M2.
It just doesn't make sense to do that.
> %%% I need to have the two matrices simultaneaously since they
> are based on a random algorithm and the alea %%%must be the same for
> the two
>
> N1=gap.eval(smith(M1))
> N2=gap.eval(smith(M2))
These lines don't really make sense either, since gap.eval takes
strings as input. Also there is no command "smith" in Gap; the
command to get the Smith form is
SmithNormalFormIntegerMat()
There is also a command
SmithNormalFormIntegerMatTransforms
> I didn't succeed even in the first line, any idea ?
I don't know if this will help, but here are some examples that actually work:
sage: o = octave.rand(10)
sage: o*o
4.14455 2.73225 3.90329 4.79322 3.79433 4.40587 4.48551 3.35537 3.90805 4.23024
2.40999 2.36626 3.2572 3.32619 2.44632 2.96312 3.09503 2.94464 2.16448 2.94741
3.52679 2.49248 3.89206 4.43024 2.96448 3.53156 3.94704 3.21713 3.23465 3.71658
3.23657 1.96081 2.99572 3.78086 1.99441 2.70276 3.39995 2.55635 2.70464 2.73741
2.51895 3.01907 3.47478 3.2962 3.41938 3.49991 3.72071 1.9491 3.41863 2.88998
2.36778 2.70028 3.36719 3.44544 3.02301 3.70154 3.27565 2.3034 3.13676 3.11006
2.54673 2.60277 3.66192 3.54719 2.96025 3.10305 3.38243 2.91102 2.71581 3.19995
2.6832 2.33206 2.6744 3.18768 2.95153 3.05092 3.00326 2.4802 2.98638 2.78367
1.66637 2.09931 2.40718 2.15225 2.04465 2.2088 2.27086 1.49336 2.60752 1.68445
2.5244 2.38207 3.66885 3.41169 2.58045 3.07769 3.05077 3.20573 2.81745 3.21822
sage: g = gap(matrix(ZZ, 3, [1,2,3,4,5,6,7,8,9]))
sage: g.SmithNormalFormIntegerMat()
[ [ 1, 0, 0 ], [ 0, 3, 0 ], [ 0, 0, 0 ] ]
sage: g.SmithNormalFormIntegerMatTransforms()
rec( normal := [ [ 1, 0, 0 ], [ 0, 3, 0 ], [ 0, 0, 0 ] ],
rowC := [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ],
rowQ := [ [ 1, 0, 0 ], [ 4, -1, 0 ], [ 1, -2, 1 ] ],
colC := [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ],
colQ := [ [ 1, -2, 1 ], [ 0, 1, -2 ], [ 0, 0, 1 ] ], rank := 2,
signdet := 0, rowtrans := [ [ 1, 0, 0 ], [ 4, -1, 0 ], [ 1, -2, 1 ] ],
coltrans := [ [ 1, -2, 1 ], [ 0, 1, -2 ], [ 0, 0, 1 ] ] )
---
General warning -- the Sage <--> Octave interface has,
as far as I know, hardly been used by anybody. It wouldn't
surprise me if it is buggy. Usually anybody doing anything
numerical would use numpy (or Sage RDF or CDF) matrices
and/or arrays instead of Octave, since it's much more powerful
for use from Sage.
See http://numpy.scipy.org/ for more about numpy, which is
included with Sage.
-- William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---