<commit_before>'use strict';

// TODO: implementation

/**
* Evaluates the natural logarithm.
*
* @param {number} x - input value
* @returns {number} function value
*
* @example
* var v = ln( 4.0 );
* // returns ~1.386
* @example
* var v = ln( 0.0 );
* // returns Number.NEGATIVE_INFINITY
* @example
* var v = ln( Number.POSITIVE_INFINITY );
* // returns Number.POSITIVE_INFINITY
* @example
* var v = ln( NaN );
* // returns NaN
* @example
* var v = ln( -4.0 );
* // returns NaN
*/
var ln = Math.log;


// EXPORTS //

module.exports = ln;<commit_msg>Provide custom ln implementation<commit_after>'use strict';

// MODULES //

var getHighWord = require( '@stdlib/math/base/utils/float64-get-high-word' );
var setHighWord = require( '@stdlib/math/base/utils/float64-set-high-word' );
var toWords = require( '@stdlib/math/base/utils/float64-to-words' );
var isnan = require( '@stdlib/math/base/utils/is-nan' );
var NINF = require( '@stdlib/math/constants/float64-ninf' );


// CONSTANTS //

var LN2_HI  =  6.93147180369123816490e-01; // 3fe62e42 fee00000
var LN2_LO  =  1.90821492927058770002e-10; // 3dea39ef 35793c76
var TWO54 =  1.80143985094819840000e+16; // 0x43500000, 0x00000000
var LG1 = 6.666666666666735130e-01;  // 3FE55555 55555593
var LG2 = 3.999999999940941908e-01;  // 3FD99999 9997FA04
var LG3 = 2.857142874366239149e-01;  // 3FD24924 94229359
var LG4 = 2.222219843214978396e-01;  // 3FCC71C5 1D8E78AF
var LG5 = 1.818357216161805012e-01;  // 3FC74664 96CB03DE
var LG6 = 1.531383769920937332e-01;  // 3FC39A09 D078C69F
var LG7 = 1.479819860511658591e-01;  // 3FC2F112 DF3E5244


// LN //

/**
* Evaluates the natural logarithm.
*
* @param {number} x - input value
* @returns {number} function value
*
* @example
* var v = ln( 4.0 );
* // returns ~1.386
* @example
* var v = ln( 0.0 );
* // returns Number.NEGATIVE_INFINITY
* @example
* var v = ln( Number.POSITIVE_INFINITY );
* // returns Number.POSITIVE_INFINITY
* @example
* var v = ln( NaN );
* // returns NaN
* @example
* var v = ln( -4.0 );
* // returns NaN
*/
function ln( x ) {
	var words;
	var hfsq;
	var hx;
	var k;
	var lx;
	var t2;
	var t1;
	var R;
	var f;
	var i;
	var j;
	var s;
	var w;
	var z;

	if ( x === 0.0 ) {
		return NINF;
	}
	if ( isnan( x ) || x < 0.0 ) {
		return NaN;
	}

	words = toWords( x );
	hx = words[ 0 ];
	lx = words[ 1 ];

	k=0;
	if (hx < 0x00100000) {
		// Case: 0 < x < 2**-1022
		k -= 54;
		// Subnormal number, scale up x:
		x *= TWO54;
		hx = getHighWord( x );
	}
	if ( hx >= 0x7ff00000 ) {
		return x+x;
	}
	k += ( hx>>20 ) - 1023;
	hx &= 0x000fffff;
	i = (hx+0x95f64) & 0x100000;
	// Normalize x or x/2...
	x = setHighWord( x, hx|(i^0x3ff00000) );
	k += ( i>>20 );
	f = x - 1.0;
	if ( (0x000fffff&(2+hx)) < 3 ) {
		// Case: -2**-20 <= f < 2**-20
		if ( f === 0.0 ) {
			if ( k === 0.0 ) {
				return 0.0;
			} else {
				return k * LN2_HI + k * LN2_LO;
			}
		}
		R = f * f * ( 0.5 - 0.33333333333333333*f );
		if (k === 0.0) {
			return f - R;
		} else {
			return k * LN2_HI - ( (R-k*LN2_LO) - f );
		}
	}
 	s = f / (2.0 + f );
	z = s * s;
	i = hx - 0x6147a;
	w = z * z;
	j = 0x6b851 - hx;
	t1 = w * (LG2+w*(LG4+w*LG6));
	t2 = z * (LG1+w*(LG3+w*(LG5+w*LG7)));
	i |= j;
	R = t2 + t1;
	if ( i > 0 ) {
		hfsq = 0.5 * f * f;
		if( k === 0.0 ) {
			return f-(hfsq-s*(hfsq+R));
		} else {
			return k * LN2_HI - ( hfsq - (s*(hfsq+R)+k*LN2_LO) - f );
		}
	} else {
		if ( k === 0 ) {
			return f - s * ( f - R );
		} else {
			return k * LN2_HI - ( (s*(f-R)-k*LN2_LO) - f );
		}
	}
} // end FUNCTION ln()


// EXPORTS //

module.exports = ln;
{'fraction_non_alphanumeric': 0.18728813559322033, 'fraction_numerical': 0.146045197740113, 'mean_word_length': 2.5268924302788847, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2399653', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1629, 'n_words': 386}