ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 16 Jan 2024 09:34:58 +0100Vector as function from a finite sethttps://ask.sagemath.org/question/75437/vector-as-function-from-a-finite-set/ Hi,
I want to represent a vector as a function from a finite set (where its size is the dimension) instead of a list(the application is semantics of linear logic).
So for example, a one dimensional vector over a a finite field of size 3 would be implemented as this:
<br>One = Set(['ball'])
<br>Ex1 = GF(3) ^ One
<br>instead of
<br>Ex 2 = GF(3) ^ 1.
<br>Unfortunately. Sagemath considers Ex2 as a vectorspace( Vector space of dimension 1 over Finite Field of size 3), but Ex1 is just a free module (Free module generated by {'ball'} over Finite Field of size 3). So for example the Hom function does not return vector space of linear transformations. But from a mathematical point of view, of course both Ex1 an Ex2 are vector spaces.
How to get around this? I need to retain the structure of the finite set that indexes the vector. My intuition (that comes from programming) is that I need to implement some kind of datatype which when used in operations that requires a vector returns a representation as a list and uses the size of the index set when creating the vector space. But perhaps there is already support for this. Please suggest a Sagemath native way to implement this. Pointers to already implemented code that does something similar would be great!Thu, 11 Jan 2024 10:19:49 +0100https://ask.sagemath.org/question/75437/vector-as-function-from-a-finite-set/Comment by FrรฉdรฉricC for <p>Hi,
I want to represent a vector as a function from a finite set (where its size is the dimension) instead of a list(the application is semantics of linear logic).
So for example, a one dimensional vector over a a finite field of size 3 would be implemented as this:
<br>One = Set(['ball'])
<br>Ex1 = GF(3) ^ One
<br>instead of
<br>Ex 2 = GF(3) ^ 1.
<br>Unfortunately. Sagemath considers Ex2 as a vectorspace( Vector space of dimension 1 over Finite Field of size 3), but Ex1 is just a free module (Free module generated by {'ball'} over Finite Field of size 3). So for example the Hom function does not return vector space of linear transformations. But from a mathematical point of view, of course both Ex1 an Ex2 are vector spaces. </p>
<p>How to get around this? I need to retain the structure of the finite set that indexes the vector. My intuition (that comes from programming) is that I need to implement some kind of datatype which when used in operations that requires a vector returns a representation as a list and uses the size of the index set when creating the vector space. But perhaps there is already support for this. Please suggest a Sagemath native way to implement this. Pointers to already implemented code that does something similar would be great!</p>
https://ask.sagemath.org/question/75437/vector-as-function-from-a-finite-set/?comment=75490#post-id-75490Something like that ?
sage: M=CombinatorialFreeModule(ZZ,["a", "poire", "๐"])
sage: M
Free module generated by {'a', 'poire', '๐'} over Integer Ring
sage: a,b,c=M.gens()
sage: 3*a+c
3*B['a'] + B['๐']
sage: unicode_art(_)
3*B + B
a ๐Tue, 16 Jan 2024 09:34:58 +0100https://ask.sagemath.org/question/75437/vector-as-function-from-a-finite-set/?comment=75490#post-id-75490Comment by Max Alekseyev for <p>Hi,
I want to represent a vector as a function from a finite set (where its size is the dimension) instead of a list(the application is semantics of linear logic).
So for example, a one dimensional vector over a a finite field of size 3 would be implemented as this:
<br>One = Set(['ball'])
<br>Ex1 = GF(3) ^ One
<br>instead of
<br>Ex 2 = GF(3) ^ 1.
<br>Unfortunately. Sagemath considers Ex2 as a vectorspace( Vector space of dimension 1 over Finite Field of size 3), but Ex1 is just a free module (Free module generated by {'ball'} over Finite Field of size 3). So for example the Hom function does not return vector space of linear transformations. But from a mathematical point of view, of course both Ex1 an Ex2 are vector spaces. </p>
<p>How to get around this? I need to retain the structure of the finite set that indexes the vector. My intuition (that comes from programming) is that I need to implement some kind of datatype which when used in operations that requires a vector returns a representation as a list and uses the size of the index set when creating the vector space. But perhaps there is already support for this. Please suggest a Sagemath native way to implement this. Pointers to already implemented code that does something similar would be great!</p>
https://ask.sagemath.org/question/75437/vector-as-function-from-a-finite-set/?comment=75443#post-id-75443What you are planing to do with these objects? Can you provide a small example with the expected outcome?Thu, 11 Jan 2024 16:54:01 +0100https://ask.sagemath.org/question/75437/vector-as-function-from-a-finite-set/?comment=75443#post-id-75443