[GAP Forum] GAP to MATLAB?
dmitrii.pasechnik at cs.ox.ac.uk
dmitrii.pasechnik at cs.ox.ac.uk
Wed Oct 16 21:59:17 BST 2019
Dear Joey,
On Wed, Oct 16, 2019 at 06:31:46PM +0000, Iverson, Joseph W [MATH] wrote:
>
> >> What kind of task are do going to do on these matrices?
>
> Usually when I need to export to MATLAB it's because I need to do stuff with eigenvalues or with non-cyclotomic numbers. For instance, right now I need to convert this non-unitary representation to a unitary one (using the square root of a positive matrix) and then find a matrix for orthogonal projection onto an invariant subspace (with the aid of a spectral decomposition).
SageMath can do linear algebra on matrices of general algebraic numbers.
By the way, our GAP package should be able to do unitarization. We
figured out a procedure for this, described in the MSc thesis (which I
supervised) of the main author of the package, see Sect. A.1 of
http://users.ox.ac.uk/~coml0531/kaashif-thesis.pdf
but implementation isn't quite done yet (not tests ready, for sure).
The procedure involves taking square roots of a positive diagonal
matrix of cyclotomics (unsuprisingly) - probably this means that it might get slow.
I guess one can do an "incomplete
unitarisation" - the invariant sesquilinear form will be diagonal, but
not scalar, this would avoid taking roots.
>
> >> I believe you can do a lot in SageMath
>
> Yes, I always have that in the back of my mind as a last resort, but I would like to avoid learning a whole new system if I can. In addition, many of my collaborators use MATLAB and I would like to stay on the same page as them.
<rant>
I honestly wish my university did not have a campus Matlab license - it has a side
effect that any non-Matlab software effort gets zero university funding :-(
Matlab for software is akin to Elsevier for maths journals - a huge
access-restricting costpost for little gain.
</rant>
>
> Still, I wonder if a person could use Sage as a bridge to MATLAB. Does anybody know if it has a method to export .mat files, and if so, whether that method is compatible with the interface to GAP?
*.mat files are snapshots of Matlab memory, I don't see how one can
produce them outside of Matlab. (They are akin to Python's or GAP's IO
package serialisation).
What one can do is to create a MEX-file extension for Matlab, which
would embed libGAP and allow for efficient copying of data in memory:
https://en.wikipedia.org/wiki/MEX_file
(this is a kind of interface to (lib)GAP done in SageMath, and, IIRC, in a new
Julia-language based system Oscar https://oscar.computeralgebra.de/)
HTH
Dima
>
> Dima, thanks also for pointing me to your package about block diagonalization. That is closely related to what I am doing, yes.
>
> All the best,
> Joey Iverson
>
> Assistant Professor
> Department of Mathematics
> Iowa State University
>
>
>
>
> On 10/16/19, 9:11 AM, "dmitrii.pasechnik at cs.ox.ac.uk" <dmitrii.pasechnik at cs.ox.ac.uk> wrote:
>
> Dear Joey,
> On Wed, Oct 16, 2019 at 12:06:16PM +0000, Iverson, Joseph W [MATH] wrote:
> >
> > Does anybody know of a way to efficiently get matrices (say with cyclotomic entries) from GAP to MATLAB? For instance, is there a package to export matrices as .mat files?
> >
> > I have been getting by with a jerry-rigged solution where I make GAP print a matrix like
> > A:=[[1,0],[0,1]];;
> > to a file "A.m" containing a single string like
> > "A=[1,0;0,1];".
> > Then I have MATLAB read the file as a script. That works fine for small matrices, but for large ones (or for 3-tensors consisting of lots of matrices) it is prohibitively slow, both for GAP to print to the file and for MATLAB to interpret the result.
> >
> > For a sense of scale, at the moment I would like to export 95040 matrices each of size 540x540 to MATLAB, preferably as a 3-tensor so that I can easily iterate through the list. (The matrices are the image of a representation of M12 having degree 540.)
>
> What kind of task are do going to do on these matrices?
> I believe you can do a lot in SageMath, which has a fast (lib)GAP
> interface, and many more numerical
> and matrix tools than GAP. E.g. we recently have been working on solving
> semidefinite optimisation problems using GAP output (needed to
> block-diagonalise certain combinatorial data).
>
> We (mostly, my former student) also have a GAP package that would block-diagonalise for you your
> representation (into block-diagonal matrix with irredicible blocks).
> https://gitlab.com/kaashif/decomp
> which might help a lot with whatever linear algebra tasks you might want
> to do with your representation of degree 540.
>
> HTH
> Dima
>
>
> >
> > Best regards,
> > Joey Iverson
> >
> > Assistant Professor
> > Department of Mathematics
> > Iowa State University
> >
> > _______________________________________________
> > Forum mailing list
> > Forum at gap-system.org
> > https://mail.gap-system.org/mailman/listinfo/forum
>
>
More information about the Forum
mailing list