-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parent methods tensor vs. tensor_product #30373
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:6
A few other things to think about:
|
comment:7
Replying to @jhpalmieri:
+1. I don't have a strong opinion which one we choose. Multiple inputs feels more flexible (and doesn't need an additional bracket).
I like that behavior, too. However, it feels to me like this behavior was not intended and just works because the element provides a If we want to promote this, which I would agree with, the syntax should indeed be the same. This might also be a good opportunity to introduce the As for So, should we split the task into several pieces, and I provide the |
comment:8
Replying to @mjungmath:
-1 on this - as per discussion in #30244, |
comment:9
Replying to @mkoeppe:
But the idea in principle remains, doesn't it? What about Arrrg, that's commenting... |
comment:10
Python has only a fixed set of binary operators available. One can resort to overloading something that's rarely used otherwise. In #30244 I suggested |
comment:11
Replying to @mkoeppe:
It feels rather uncanonical. But tensor products seem to be used quite frequently, so if there's no better bet... What's your opinion on the syntax? Should I open another ticket to provide |
comment:12
We should make people use the unicode More seriously, if we can switch the syntax to |
comment:13
I've opened a ticket for the |
comment:14
Multiple inputs can also be really annoying when you want to create a list dynamically as you then have to add a The tensor unicode would be good, except it would depend on how the Python interpreter takes that. Most likely, we would need to implement another find-replace case in the preparser to go to some overloaded infix operator such as |
comment:15
Speaking of shortcuts for operations: what about using If that meets your approval, I'll open a ticket for this. |
comment:16
I find it too easily confused with the exponentiation operator, so I would not like to see it featured prominently in doctests. |
comment:17
So far, the
But I agree. One would rather expect Mh, one minute ago, I thought it was an ingenious idea. :D |
comment:18
Replying to @jhpalmieri:
However, I think it would be a nice syntactic sugar since |
comment:19
Replying to @tscrim:
How do we treat |
comment:20
Replying to @jhpalmieri:
A relevant ticket here: #30473 |
comment:21
Replying to @mjungmath:
+1 (and IMHO |
comment:22
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
comment:68
Mathematically an object is a tensor product if there exists a construction of it using the tensor functor. In an implementation, we generally cannot know if something exists. An object is marked as a tensor product when the implementation has marked it as such. Like everything, this is subject to the implementation restrictions. |
comment:69
Replying to Travis Scrimshaw:
No, as a user. Suppose there is no such specific implementation. What should the user do? |
comment:70
Replying to Matthias Köppe:
Then every object is a tensor product since we can always tensor with a 1-dimensional module. If we wanted to talk in that level of generality, there is no category of tensor products, Cartesean products, etc.
Indeed, the category also contains some implementation requirements. (I would argue the tensor products category is the category with a distinguished tensor product construction, parallel to More concretely, if I had code that does: T = tensor([V,W])
for F in T.tensor_factors():
print(F) This should work whenever |
comment:71
Replying to Matthias Köppe:
My guess is stop wishing for magical coding fairies and implement it. There is no generic way to give a tensor product the structure of a specific type of module. This essentially amounts to saying there is a canonical isomorphism between, e.g., R2 (x) R3 = R6. (Another version: How do you build a matrix from a tensor product of two matrices? There are two main ways to do this that are equivalent as they amount to choosing a different order of the isomorphism.) If a class |
comment:72
Replying to Travis Scrimshaw:
No, I think this is too strict to be useful. |
comment:73
Replying to Travis Scrimshaw:
No, no, users wouldn't like to be talked to like that. |
comment:74
We often want to identify 1-fold tensor products with the base module -- and the base module won't have the |
comment:75
Replying to Matthias Köppe:
That an object in the codomain of a functor (or any morphism) must support what is required by that codomain (and should be an object such that Consider the equivalent scenario: I have a function |
comment:76
Replying to Travis Scrimshaw:
There's always a tradeoff. Identifications such as the ones that I mentioned in comment:74 are also quite useful. |
comment:77
Replying to Matthias Köppe:
Of course I wouldn’t necessarily tell them in that way. However, unless somebody actually writes the code, then it doesn’t magically come into existence. Unfortunately, this is not the Dire Straights song “Money for Nothing”; Also Hell is full of 10 year olds who wished for exactly the same thing with the holophonor. In this case, I believe it is impossible to implement in the level of generality you want because it amounts to making a canonical choice where there is not one. |
comment:78
Replying to Travis Scrimshaw:
It does not have to be canonical to be useful. And in fact one wouldn't construct that but rather construct a free module whose basis is indexed by the cartesian product of the input index sets. |
comment:79
Replying to Matthias Köppe:
I agree that they are useful, but you need a canonical way to do it in general. The point is that you are making an identification based upon a specific choice of isomorphism. Individual classes are allowed to make that choice, which you are implicitly doing when you have either a |
comment:80
Replying to Matthias Köppe:
But that is doing what is mandated by the category. It is holding onto the knowledge of how it is constructed. What you are asking for is something to return the equivalent of R6. |
comment:81
I think in comment:79 you replied to the wrong comment. |
comment:82
Replying to Matthias Köppe:
It applies to both comment:76 and comment:74. I just chose the more recent one. |
comment:83
Replying to Travis Scrimshaw:
No, I don't think this resembles anything what I'm asking for. I think we've lost the context somewhere on the way here. |
comment:84
Replying to Travis Scrimshaw:
Wait, you are concerned about the identification of a module M with its 1-fold tensor product not being canonical? |
comment:85
For the question of 1-fold tensor products, there's by the way an old ticket: #18349 |
comment:86
Replying to Matthias Köppe:
Sorry, that was a bad phrasing on my part. You are asking for returning R6 to be okay, which you have had to make a (non-canonical) choice of a isomorphism that they user has no control over. The tensor product category has a special distinguished choice of construction as a tensor product, analogous to |
comment:87
Replying to Matthias Köppe:
Not specifically for the 1-fold tensor products, but more generally. This code is expected to work for arbitrary tensor products with no special cases, right? (I can also tell you about the troubles I’ve had with |
comment:88
Replying to Travis Scrimshaw:
No |
comment:89
Replying to Travis Scrimshaw:
I do appreciate the attempt to engage in intergenerational dialogue |
comment:90
Replying to Matthias Köppe:
Then if you rename the functor hook to |
comment:91
Replying to Matthias Köppe:
Actually, that is music I like. |
We unify the use of the methods
tensor
vs.tensor_product
in parent classes.Current situation:
Category
ModulesWithBasis
provides a parent methodtensor
to construct a tensor product of modules.It is not implemented completely for
FreeModule
In contrast,
FiniteRankFreeModule
(which is not inModulesWithBasis
) uses a parent methodtensor
to construct elements.FilteredVectorSpace
has bothtensor
(fromModulesWithBasis
) andtensor_product
, but only the latter works.The same is true for
FreeQuadraticModule_integer_symmetric
:The proposed solution in this ticket is to standardize on the method
tensor_product
, makingtensor
a deprecated alias.Modules
already has atensor_square
method, whichtensor_product
complements well.We also add
tensor_power
.No changes are made to the global
tensor
(unique instance ofTensorProductFunctor
).Tickets:
FiniteRankFreeModule
FiniteRankFreeModule
inModules().TensorProducts()
VectorFieldModule
,TensorFieldModule
,DiffFormModule
: Add methodstensor_product
,tensor_power
, update category ofTensorFieldModule
See also: #18349
CC: @tscrim @egourgoulhon @mjungmath @jhpalmieri @fchapoton
Component: linear algebra
Author: Matthias Koeppe
Branch/Commit: u/mkoeppe/parent_methods_tensor_vs__tensor_product @
ed6a13f
Issue created by migration from https://trac.sagemath.org/ticket/30373
The text was updated successfully, but these errors were encountered: