HOw to transform a N x 1 or 1 x N matrix into a list?

792 views
Skip to first unread message

Rex

unread,
Mar 19, 2012, 12:37:48 PM3/19/12
to maca...@googlegroups.com

Is there any efficient way or command to transform a "N x 1" or "1 x N " matrix into a list?


Thanks.

Douglas Leonard

unread,
Mar 19, 2012, 12:42:30 PM3/19/12
to maca...@googlegroups.com
I am always having to use

flatten entries

to change what M2 thinks should be a matrix into what I think should be a list
or a set of generators or a Gr\"obner basis or...

Doug

From: maca...@googlegroups.com [maca...@googlegroups.com] on behalf of Rex [aoi...@gmail.com]
Sent: Monday, March 19, 2012 11:37 AM
To: maca...@googlegroups.com
Subject: [Macaulay2] HOw to transform a N x 1 or 1 x N matrix into a list?

Is there any efficient way or command to transform a "N x 1" or "1 x N " matrix into a list?


Thanks.

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To view this discussion on the web visit https://groups.google.com/d/msg/macaulay2/-/qSpo8tBwAc8J.
To post to this group, send email to maca...@googlegroups.com.
To unsubscribe from this group, send email to macaulay2+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/macaulay2?hl=en.

Rex

unread,
Mar 19, 2012, 12:56:58 PM3/19/12
to maca...@googlegroups.com

Dear Doug,

Thank you very much for your quick reply.

But from the Macaulay2 document online,
http://www.math.uiuc.edu/Macaulay2/doc/Macaulay2-1.4/share/doc/Macaulay2/Macaulay2Doc/html/_flatten_lp__Matrix_rp.html

it seems that flatten(Matrix) transforms a matrix into a matrix, not into a list. Did I miss any point here?

I wish to appy unique command on a list or sequence.

Thanks again.

Best,

Rex

Douglas Leonard

unread,
Mar 19, 2012, 3:31:31 PM3/19/12
to maca...@googlegroups.com

i1 : M=matrix{{2,3},{4,5},{6,7}}

o1 = | 2  3 |
     |      |
     | 4  5 |
     |      |
     | 6  7 |

              3        2
o1 : Matrix ZZ  <--- ZZ

i2 : entries M

o2 = {{2, 3}, {4, 5}, {6, 7}}

o2 : List

i3 : flatten entries M

o3 = {2, 3, 4, 5, 6, 7}

o3 : List

i4 :

Sent: Monday, March 19, 2012 11:56 AM
To: maca...@googlegroups.com
Subject: Re: [Macaulay2] HOw to transform a N x 1 or 1 x N matrix into a list?

To view this discussion on the web visit https://groups.google.com/d/msg/macaulay2/-/IbDC4_18PkgJ.

Rex

unread,
Mar 19, 2012, 3:52:40 PM3/19/12
to maca...@googlegroups.com

Nice. Thanks, Doug. :)

Hope you have a nice day.

Thomas Kahle

unread,
Mar 19, 2012, 4:28:09 PM3/19/12
to maca...@googlegroups.com
On 09:37 Mon 19 Mar 2012, Rex wrote:
>
>
> Is there any efficient way or command to transform a "N x 1" or "1 x N "
> matrix into a list?

Again, the underscore operator can facilitate this in the Nx1 case:

i20 : M = matrix {{1},{2},{3}}

o20 = | 1 |
| 2 |
| 3 |

3 1
o20 : Matrix ZZ <--- ZZ

i21 : M_0

o21 = | 1 |
| 2 |
| 3 |

3
o21 : ZZ

i22 : entries M_0

o22 = {1, 2, 3}


--
Thomas Kahle

signature.asc

Isaac Burke

unread,
Dec 3, 2013, 2:14:56 PM12/3/13
to maca...@googlegroups.com
Hi there, 


I'm wondering how I can change list into a matrix; for example, when I define a matrix A and compute ker(A) this returns a list of column vectors of which the image is ker(A). I want to quickly form the matrix which has these column vectors as columns. 

Any help appreciated. 

Thanks



Isaac 

Frank Moore

unread,
Dec 3, 2013, 3:41:32 PM12/3/13
to maca...@googlegroups.com
I think ker(A) returns a module, given as the image of a matrix, so I may not understand your question.  However, the following may help:

If M is the matrix that you would like to do this to, then the command

apply(numgens source M, i -> M_{i})

should create a list consisting of the column vectors of M.  If you want a list of generators of the kernel of M, then replace M with "gens ker M" in the above code.

Frank 


--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.

To post to this group, send email to maca...@googlegroups.com.



--
Dr. W. Frank Moore
Assistant Professor
Department of Mathematics, Wake Forest University

email: moo...@wfu.edu

Michael Stillman

unread,
Dec 4, 2013, 8:19:09 AM12/4/13
to maca...@googlegroups.com
If A is a matrix, then
  ker A
returns a submodule, and
  gens ker A
returns a matrix whose columns generate the kernel.

An alternate notation, for a matrix A between free modules, is:
  syz A
which is essentially ‘gens ker A’.

If you want an actual Macaulay2 list of entries of a matrix, use ‘entries’, or ‘flatten entries’.

— Mike

Example:

i1 : R = QQ[a..d]

o1 = R

o1 : PolynomialRing

i2 : A = matrix{{a*b-c^2, a*d-b*c, a^3-c^3}}

o2 = | ab-c2 -bc+ad a3-c3 |

             1       3
o2 : Matrix R  <--- R                                                                                                                                                                                                                

i3 : ker A

o3 = image {2} | bc-ad 0     a2b-c2d  a3-c3  |
           {2} | ab-c2 a3-c3 -a2c+bc2 0      |
           {3} | 0     bc-ad -b2+cd   -ab+c2 |

                             3
o3 : R-module, submodule of R

i4 : gens ker A

o4 = {2} | bc-ad 0     a2b-c2d  a3-c3  |
     {2} | ab-c2 a3-c3 -a2c+bc2 0      |
     {3} | 0     bc-ad -b2+cd   -ab+c2 |

             3       4
o4 : Matrix R  <--- R                                                                                                                                                                                                                

i5 : syz A

o5 = {2} | bc-ad 0     a2b-c2d  a3-c3  |
     {2} | ab-c2 a3-c3 -a2c+bc2 0      |
     {3} | 0     bc-ad -b2+cd   -ab+c2 |

             3       4
o5 : Matrix R  <--- R                                                                                                                                                                                                                


i6 : entries A

              2                3    3
o6 = {{a*b - c , - b*c + a*d, a  - c }}

o6 : List

Isaac Burke

unread,
Dec 11, 2013, 10:36:32 AM12/11/13
to maca...@googlegroups.com
Thanks Frank, Michael, that answers my question. 

-Isaac 


--
You received this message because you are subscribed to a topic in the Google Groups "Macaulay2" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/macaulay2/dX0xkcjrUZc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to macaulay2+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages