Skip to content

Commit

Permalink
Improve complex log
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmasson committed Jan 23, 2025
1 parent 88b535b commit 81a44bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions build/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -3354,11 +3354,11 @@ function logisticSigmoid( x ) { return inv( add( 1, exp(neg(x)) ) ); }

function log( x, base ) {

if ( isComplex(x) ) {
if ( isComplex(x) || isComplex(base) ) {

if ( isComplex(base) ) return div( log(x), log(base) );
if ( base === undefined ) return { re: Math.log( abs(x) ), im: arg(x) };

return { re: log( abs(x), base ), im: log( Math.E, base ) * arg(x) };
return div( log(x), log(base) );

}

Expand Down
6 changes: 3 additions & 3 deletions src/functions/logarithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function logisticSigmoid( x ) { return inv( add( 1, exp(neg(x)) ) ); }

function log( x, base ) {

if ( isComplex(x) ) {
if ( isComplex(x) || isComplex(base) ) {

if ( isComplex(base) ) return div( log(x), log(base) );
if ( base === undefined ) return { re: Math.log( abs(x) ), im: arg(x) };

return { re: log( abs(x), base ), im: log( Math.E, base ) * arg(x) };
return div( log(x), log(base) );

}

Expand Down

0 comments on commit 81a44bb

Please sign in to comment.