John,

On Sunday, July 19, 2020 at 1:00:21 AM UTC+2 John H Palmieri wrote:

> Can you give a specific example of a computation in which you care about 
> the degree where your zero element lives? Or where you can't just recover 
> it from its component elements (if ab=0, then you have an element in degree 
> = deg(a) + deg(b)). I'm struggling to understand this.
>

It's more that I would like to avoid checking for the special case 0.  The 
case we are discussing is similar to the use of pointers vs. references in 
C++:  If a function returns a pointer to an object, the recipient have to 
check that it is not NULL before dereferencing it.  On the other hand, if 
the function returns a reference to an object, you don't have to.  The 
latter leads to cleaner code, and is preferred if one has a choice since it 
relieves the user from the responsibility of guarding against the null case.

This is what Christian mentions too:

> In practical terms this just shifts the responsibilities a bit: the 
result of a computation (e.g. multiplication) will not in general know its 
degree; therefore the piece of user code that triggered the multiplication 
must keep a memory of the grading that it's workign at.
If we treated graded objects like Bob suggests, we would relieve the user 
of this responsibility.

At this point I think it's clear that what I would like requires some work 
to get done right,  so I guess I will let this rest for now.  Thanks so 
much to all for your input!

Best regards,
Sverre

 

>
> If you are doing the same check repeatedly, then write a little function 
> to do it and then you have a one-line call to that function scattered 
> around your code, which doesn't seem like that big a deal to me. 
> Alternatively, and I know this isn't how we like to think about these 
> things, but what goes wrong if you allow nonhomogeneous elements? That 
> could be another way to simplify things.
>

> - John
>
>
>
>
> On Saturday, July 18, 2020 at 3:28:56 PM UTC-7, Sverre Lunøe-Nielsen wrote:
>>
>>
>> On Saturday, July 18, 2020 at 11:31:43 PM UTC+2, John H Palmieri wrote:
>>>
>>> In any case where the degree matters, you should first test whether an 
>>> element is zero (in which case it won't have a degree) and then perhaps 
>>> whether it is homogeneous. If not, you can raise an error (to keep someone 
>>> from multiplying a module element by Sq(1) + Sq(2), for example). If it is 
>>> homogeneous, you can proceed the way you want.
>>>
>>
>> This is indeed what we do in the current version.  However, I have come 
>> to think of this as some kind of anti-pattern, so I am seeking ways to 
>> avoid it. 
>>
>> On Saturday, July 18, 2020 at 11:57:21 PM UTC+2, Christian Nassau wrote:
>> > I don't think it's a good idea to have different zeroes in an algebraic 
>> structure that is also categorized as an abelian group, unless you take the 
>> point that a "graded abelian group" should not be an "abelian group". 
>>
>> Yes, as I outlined, they should definitely be living in a category where 
>> the objects are sequences of k-vectorspaces with the structure maps that 
>> make them k-algebras.  But the data that goes into defining an algebra this 
>> way is no different from usual.
>>
>>
>> - Sverre
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/fa3bdb5e-3052-4fb2-b23c-66932e804569n%40googlegroups.com.

Reply via email to