ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 12 Feb 2019 18:54:13 -0600Mapping 2-dimensional matrix index to a listhttp://ask.sagemath.org/question/45436/mapping-2-dimensional-matrix-index-to-a-list/Hi all,
I have a following matrix:
mat = matrix([[1,5,7],[3,10,12],[0,5,3]])
[ 1 5 7]
[ 3 10 12]
[ 0 5 3]
I got 3 parts from the matrix:
A = mat[[0,1,2],[0]]
[1]
[3]
[0]
B = mat[[1,2],[1,2]]
[10 12]
[ 5 3]
C = mat[[0],[1,2]]
[5 7]
To know that these 3 parts are not overlapping to each other, I have an idea to map the original matrix to 1-dimension array as IDs for each cell:
tt = copy(mat)
row = mat.nrows()
col = mat.ncols()
for x in range(row):
for y in range(col):
tt[x,y] = x*col+y
sage: tt
[0 1 2]
[3 4 5]
[6 7 8]
Then again I go over all coordinate that I took for A, B and C to collect these mapped ID.
Regarding to A,
cells_A = []
for i in range(0, 3):
for j in range(0, 1):
cells_A.append(tt[i, j])
sage: cells_A
[0, 3, 6]
Regarding to B:
cells_B = []
for i in range(1, 3):
for j in range(1, 3):
cells_B.append(tt[i, j])
sage: cells_B
[4, 5, 7, 8]
Regarding to C, similarly we have:
sage: cells_C = [1,2]
If size of union from these 3 cells is equal to the total size of A, B, and C, then I conclude no overlapping among them.
area = sum([A.nrows()*A.ncols(), B.nrows()*B.ncols(), C.nrows()*C.ncols()])
if len(set.union(*[set(cells_A), set(cells_B), set(cells_C)])) == area:
print("No overlapping parts")
However, this way requires lots of work and **SLOW**. Is there any already SageMath's Matrix feature supporting some steps above, especially a way to improve/avoid mapping index?imnvshTue, 12 Feb 2019 18:54:13 -0600http://ask.sagemath.org/question/45436/How to defining a twist on an elliptic curvehttp://ask.sagemath.org/question/39597/how-to-defining-a-twist-on-an-elliptic-curve/Hey,
I would like to do map points of the ellitptic curve $E(\mathbb F_{p^{k}})$ to its twist. I am able to define the twist on a mathematical way, but it returns always errors. I will give you a M(n)WE:
Aim: Get a generator of a r-torsion subgroup of E, lift that to E16 and twist it down to E4, to get a r-torsion subgroup-generator of E4.
#MWE
## Mathematical definition:
$E(\mathbb F_{p^{16}}): y^2=x^3+x$ and its quartic twist $E'(\mathbb F_{p^4}): y^2=x^3+2^{-1/4}x$. The point mapping is defined as $\psi: E\to E', (x,y,z)\mapsto (2^{-1/2}x, 2^{-3/4}y, z)$.
## Define the fields and curves
p= 13
r=5
R=GF(p)
_.<x> = PolynomialRing(R)
R4.<x> = R.extension(x^4 - 2, 'x')
_.<y> = PolynomialRing(R)
R16.<y> = R.extension(y^16 -2, 'y')
_.<z> = PolynomialRing(R4)
R16_over_R4.<z> = R4.extension(z^4-x, 'z')
E = EllipticCurve(R, [1,0]) # y^2 = x^3+x
E4 = EllipticCurve(R4, [x,0])
E16 = EllipticCurve(R16, [1,0])
## Defining the point and pre-computations
k= ZZ(E.order()/r) # since E.order()*P = (0:1:0), we can trick with that
b=R16(2^(-1)); b= sqrt(sqrt(2)) #the twisting parameter, that is a square in R4 and R16
P= E.gens()[0]
Q=k*P # check if Q != E((0,1,0)), if yes its a r-torsion point.
Q16 = E16(Q) #raise Q
## The not working twist
#twist
E4( (Q16[0]*b^2, Q16[1]*b^3))
Sage is able to compute the quartic twist of its own, but I do not recieve the right twist, that I had computed by hand ( $E'$ ). Using
E4.quartic_twist(v^-1)ShalecThu, 16 Nov 2017 04:43:57 -0600http://ask.sagemath.org/question/39597/Is it better practice to show SAGE code on a web use of SAGE?http://ask.sagemath.org/question/10305/is-it-better-practice-to-show-sage-code-on-a-web-use-of-sage/If you go to my page for The Sensible Calculus Book http://users.humboldt.edu/flashman/senscalca_x.html you will find how I've added SAGE to this page- with interacts for graphs, direction fields and Euler's Method for DE's as well as one of the mapping diagram interacts I am developing from the assistance of Jeff Denny, Jason Grout, and others at Sage Edu Days 5 . I would like feedback on this if you have suggestions- I have currently hidden the code from the users using the interact buttons. Is it better practice to show the Sage code?Martin FlashmanMon, 01 Jul 2013 06:27:00 -0500http://ask.sagemath.org/question/10305/Is there some way to have Geogebra and SAGE interact?http://ask.sagemath.org/question/10306/is-there-some-way-to-have-geogebra-and-sage-interact/ On my page for [The Sensible Calculus Book](http://users.humboldt.edu/flashman/senscalca_x.html) you will find how I've added SAGE to this page- with interacts for graphs and one of the mapping diagram interacts I am developing from the assistance of Jeff Denny, Jason Grout, and others at Sage 5 Edu.
ALSO- I have a new demo using Geogebra on the same page to do similar things with graphs and mapping diagrams dynamically. Is there some way to have Geogebra and SAGE interact? Martin FlashmanMon, 01 Jul 2013 06:32:41 -0500http://ask.sagemath.org/question/10306/