MCPcopy Create free account
hub / github.com/numpy/numpy / logn

Function logn

numpy/lib/scimath.py:354–386  ·  view source on GitHub ↗

Take log base n of x. If `x` contains negative inputs, the answer is computed and returned in the complex domain. Parameters ---------- n : array_like The integer base(s) in which the log is taken. x : array_like The value(s) whose log base `n` is (are) r

(n, x)

Source from the content-addressed store, hash-verified

352
353@array_function_dispatch(_logn_dispatcher)
354def logn(n, x):
355 """
356 Take log base n of x.
357
358 If `x` contains negative inputs, the answer is computed and returned in the
359 complex domain.
360
361 Parameters
362 ----------
363 n : array_like
364 The integer base(s) in which the log is taken.
365 x : array_like
366 The value(s) whose log base `n` is (are) required.
367
368 Returns
369 -------
370 out : ndarray or scalar
371 The log base `n` of the `x` value(s). If `x` was a scalar, so is
372 `out`, otherwise an array is returned.
373
374 Examples
375 --------
376 >>> np.set_printoptions(precision=4)
377
378 >>> np.emath.logn(2, [4, 8])
379 array([2., 3.])
380 >>> np.emath.logn(2, [-4, -8, 8])
381 array([2.+4.5324j, 3.+4.5324j, 3.+0.j ])
382
383 """
384 x = _fix_real_lt_zero(x)
385 n = _fix_real_lt_zero(n)
386 return nx.log(x)/nx.log(n)
387
388
389@array_function_dispatch(_unary_dispatcher)

Callers

nothing calls this directly

Calls 1

_fix_real_lt_zeroFunction · 0.85

Tested by

no test coverage detected