Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmasson committed Jan 19, 2024
1 parent bc0c3ec commit f2e2e38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions build/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -1351,21 +1351,21 @@ function weierstrassHalfPeriods( g2, g3 ) {
var m = div( sub(e2,e3), sub(e1,e3) );

var w1 = div( ellipticK(m), lambda );
var w3 = div( mul( complex(0,1), ellipticK( sub(1,m) ) ), lambda );
var w2 = div( mul( complex(0,1), ellipticK( sub(1,m) ) ), lambda );

return [ w1, w3 ];
return [ w1, w2 ];

}

function weierstrassInvariants( w1, w3 ) {
function weierstrassInvariants( w1, w2 ) {

if ( !isComplex(w1) ) w1 = complex(w1);
if ( !isComplex(w3) ) w3 = complex(w3);
if ( !isComplex(w2) ) w2 = complex(w2);

// order half periods by complex slope
if ( w3.im/w3.re < w1.im/w1.re ) [ w1, w3 ] = [ w3, w1 ];
if ( w2.im/w2.re < w1.im/w1.re ) [ w1, w2 ] = [ w2, w1 ];

var ratio = div( w3, w1 ), conjugate;
var ratio = div( w2, w1 ), conjugate;

if ( ratio.im < 0 ) {
ratio.im = -ratio.im;
Expand Down
4 changes: 2 additions & 2 deletions docs/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ <h1>Elliptic Functions</h1>

<p><b>weierstrassRoots( <i>g</i><sub>2</sub>, <i>g</i><sub>3</sub> )</b> &mdash; Weierstrass roots <i>e</i><sub>1</sub>, <i>e</i><sub>2</sub> and <i>e</i><sub>3</sub> for real or complex invariants. Returned as an array.</p>

<p><b>weierstrassHalfPeriods( <i>g</i><sub>2</sub>, <i>g</i><sub>3</sub> )</b> &mdash; Weierstrass half periods <i>w</i><sub>1</sub> and <i>w</i><sub>3</sub> for real or complex invariants. Returned as an array. Consistent with evaluation of Weierstrass elliptic function in terms of Jacobi elliptic sine.</p>
<p><b>weierstrassHalfPeriods( <i>g</i><sub>2</sub>, <i>g</i><sub>3</sub> )</b> &mdash; Weierstrass half periods <i>w</i><sub>1</sub> and <i>w</i><sub>2</sub> for real or complex invariants. Returned as an array. Consistent with evaluation of Weierstrass elliptic function in terms of Jacobi elliptic sine.</p>

<p><b>weierstrassInvariants( <i>w</i><sub>1</sub>, <i>w</i><sub>3</sub> )</b> &mdash; Weierstrass invariants <i>g</i><sub>2</sub> and <i>g</i><sub>3</sub> for real or complex half periods. Returned as an array.</p>
<p><b>weierstrassInvariants( <i>w</i><sub>1</sub>, <i>w</i><sub>2</sub> )</b> &mdash; Weierstrass invariants <i>g</i><sub>2</sub> and <i>g</i><sub>3</sub> for real or complex half periods. Returned as an array.</p>

<p><b>weierstrassP( <i>x</i>, <i>g</i><sub>2</sub>, <i>g</i><sub>3</sub> )</b> &mdash; Weierstrass elliptic function &weierp; of a real or complex number with real or complex invariants. Returned as a complex number for consistency.</p>

Expand Down
12 changes: 6 additions & 6 deletions src/functions/elliptic-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,21 +395,21 @@ function weierstrassHalfPeriods( g2, g3 ) {
var m = div( sub(e2,e3), sub(e1,e3) );

var w1 = div( ellipticK(m), lambda );
var w3 = div( mul( complex(0,1), ellipticK( sub(1,m) ) ), lambda );
var w2 = div( mul( complex(0,1), ellipticK( sub(1,m) ) ), lambda );

return [ w1, w3 ];
return [ w1, w2 ];

}

function weierstrassInvariants( w1, w3 ) {
function weierstrassInvariants( w1, w2 ) {

if ( !isComplex(w1) ) w1 = complex(w1);
if ( !isComplex(w3) ) w3 = complex(w3);
if ( !isComplex(w2) ) w2 = complex(w2);

// order half periods by complex slope
if ( w3.im/w3.re < w1.im/w1.re ) [ w1, w3 ] = [ w3, w1 ];
if ( w2.im/w2.re < w1.im/w1.re ) [ w1, w2 ] = [ w2, w1 ];

var ratio = div( w3, w1 ), conjugate;
var ratio = div( w2, w1 ), conjugate;

if ( ratio.im < 0 ) {
ratio.im = -ratio.im;
Expand Down

0 comments on commit f2e2e38

Please sign in to comment.