Try
singular('%s + %s'%(S.name(), S.name()))
Other comments:
1. Are you the John Palmieri that is a professor at Univ of Washington too?
If so, perhaps we should chat in person...
2. Using Singular as suggested above probably seems pretty awkward.
Don't worry -- if you find that it is doing the right thing for you,
we can design
some nice Sage classes that give a nice clean interface, then "secretly"
have Singular do all the real work behind the sences. This is how many
interesting things in Sage are (first) implemented.
-- William
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
No, that would not be reasonable. [[woah, John Palmieri just appeared
in my office... chat for a while...] Anyway, copy should return an exact
copy since that's the semantics of __copy__ in Python. However,
I strongly encourage you to write a method like you describe and
just call it something slightly different, e.g.,
def change_names(self, ...):
or
def copy_with_names_changed(...):
or whatever. Just anything but "copy".
> Then, John (and many others) could do
> S=R+copy(R)
> S.setring()
> which should be reasonably short.
>
> I think, without creating new variable names R+R doesn't make much
> sense.
>
> More generally, i believe it'd be a good idea to have a __copy__
> method for *any* Sage objects defined via the Singular interface.
>
> E.g., when one defines a matrix
> sage: D=singular.matrix(3,3,'a,b,c, a**2,b**2,c**2, a**3,b**3,c**3')
> then
> C=copy(D)
> should be a copy of D (in the same ring). Up to now, one obtains
> sage: C=copy(D)
> sage: C
> (invalid object -- defined in terms of closed session)
I would certainly be all for that too!
Any chance you could write it, or do I have to?
-- William
No, it is not a bug. It's a perfect example of how
Singular itself has a rather -- let's say old fashioned -- user
interface and language. That's what I was trying to convey
to you earlier today in my office: Singular best at doing
exactly one thing at a time, and no more.
That's why code that we've written that combines
Sage and Singular is vastly nicer to use than just
plain Singular. The main problem for you of course
is that nobody has written any such code that "wraps"
noncommutative functionality in Singular yet.
I would sit down and try to fix this right now, but I have too
many other things on my plate, and I've been jumping
into every basic thing that needs to get done in
Sage for 3 years; that has to stop or I won't have
enough time to do my own research.
-- William
--
Yes, that's a VERY GOOD idea. It's really crazy to use a compiled
spyx for the purposes of interfacing with the Singular interpreter
via pexpect.
> I get:
>
> sage: attach tensor.sage
> line 10
> for nr from Integer(0)<=nr<n-Integer(1):
>
> The same thing happens if I type the function definition directly into
> Sage.
That's as it should be. That's all that happens when you attached
a file. It's supposed to be the same as typing in the code.
>
> This is with Sage 2.10.1 on Mac OS X (although I can test it on a
> linux machine tomorrow). I'm probably doing something stupid,
> though...
>
> I have one question about the results of your computation; see below.
>
One trivial thing occurred to me. Sage includes Maxima and has a very
interface to it. Maybe Maxima can do the sort of noncommutative
calculations you want -- it's worth at least checking. The main reason
I suggest this is: (1) you're not going to do something that pushes the
limits of computation, so speed isn't of the utmost importance,
and (2) you (John's) main programming background is in lisp,
so you might feel very comfortable with Maxima, given that it
is written in lisp.
http://maxima.sourceforge.net/
sage: maxima('2+2')
4
-- William
--
Yes, that is correct. But when you're not working with pure C data structures
you're going to get no speed improvements by using
> for i from 1<=i<=len(L[2]):
instead of
> for i in range(1,len(L[2])+1)
You're just making things a little more difficult.
> @John, this would explain the new error message after renaming the
> file.
Yes, that would.
>
> However, i don't know why attaching the .spyx didn't work.
>
>
That's very suspicious:
"sage: attach tensorpower.spyx
Loading of file "/Users/palmieri/.sage/tensorpower.spy" has type not
implemented."
That suggests there is either a very very weird serious bug that got
magically fixed
or maybe the above log isn't what really happened -- notice that in
the error message
it says .spy not .spyx.
-- William
To attach files in a *local* notebook give the exact path to the file.
-- William