[Macaulay2] Defining a new Type of Ring

28 views
Skip to first unread message

Andrew Critch

unread,
Dec 16, 2011, 1:05:32 AM12/16/11
to maca...@googlegroups.com
Hi all,

I want to define a new type of Ring called StateRing, but when I make a new StateRing from a Ring, some methods defined for Rings don't work for StateRings.  For example, maps don't work anymore: 

R=QQ[x,y]
map(R,R)
S=newClass(StateRing,R)
map(S,S) -- returns "error: map: expected a matrix over the target ring, or promotable to it"
T=new StateRing from R
map(T,T)  -- returns "error: map: expected a matrix over the target ring, or promotable to it"

What should I do here, to make all methods/functions that work for Rings continue to work for StateRings?

Thanks for any help!

--
Critch, Andrew
UC Berkeley
http://math.berkeley.edu/~critch/

Grayson, Daniel R.

unread,
Dec 18, 2011, 1:13:31 PM12/18/11
to maca...@googlegroups.com
The problem is that Macaulay2 is an interpreted language, and many initializations
are done when a new ring is created, none of which are done for the new ring S that
you have created. Those initializations include the installation of various methods
for computing promotions of matrices.

Perhaps there is another way. In what way should your state rings be different from rings?

> --
> You received this message because you are subscribed to the Google Groups "Macaulay2" group.
> 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.

Andrew Critch

unread,
Dec 18, 2011, 2:55:52 PM12/18/11
to maca...@googlegroups.com

So far I think my StateRings will just be rings with extra hash keys. For example I will write things like

R.cards = {2,2,3}

to install a list of "state cardinalities" associated with the ring. I was thinking I might eventually write a distribution package for manipulating such rings, and would like to have it carefully typed, but it's not strictly necessary at the moment... so far any method that requires the StateRing structure will just return an "error: key not found in hash table".

Andrew Critch

unread,
Dec 18, 2011, 3:01:59 PM12/18/11
to maca...@googlegroups.com
... is it possible to simply change the type of a ring R, without changing anything else about it?  Is there a big hash table somewhere like TYPE where I can do 

TYPE.R = StateRing

?

Grayson, Daniel R.

unread,
Dec 19, 2011, 9:28:06 AM12/19/11
to maca...@googlegroups.com

On Dec 18, 2011, at 2:01 PM, Andrew Critch wrote:

> ... is it possible to simply change the type of a ring R, without changing anything else about it? Is there a big hash table somewhere like TYPE where I can do
>
> TYPE.R = StateRing
>
> ?
>

No, there's nothing like that.

>
> On Sun, Dec 18, 2011 at 11:55 AM, Andrew Critch <cri...@gmail.com> wrote:
> So far I think my StateRings will just be rings with extra hash keys. For example I will write things like
>
> R.cards = {2,2,3}
>
> to install a list of "state cardinalities" associated with the ring. I was thinking I might eventually write a distribution package for manipulating such rings, and would like to have it carefully typed, but it's not strictly necessary at the moment... so far any method that requires the StateRing structure will just return an "error: key not found in hash table".
>

Perhaps it will suffice for your purposes just to add keys (or better, a single key, such as StateRing) to "R", as you suggest, and not to try to introduce a new subtype. If not, let us know. A better error message would be "expected ring to be a state ring", by the way, and you could implement that by testing for the presence of the key before using it.

Andrew Critch

unread,
Dec 20, 2011, 10:07:13 PM12/20/11
to maca...@googlegroups.com
Okay, thank you very much for your feedback!  Even though the answers were mostly negative, I can move forward with more confidence knowing that I'm not overlooking some important built-in functionality that I should know about.

Cheers,

--
Critch

Reply all
Reply to author
Forward
0 new messages