ISOpure.util.matlab_log: Modified logarithm function

Description Usage Arguments Value Author(s) Examples

Description

Logarithm function that matches Matlab behaviour on negative entries (i.e. returns a complex number)

Usage

1

Arguments

x

A numeric or complex value, vector, or matrix.

Value

Returns log(x) if all entries of x > 0. For complex or negative input, x, where x = a + bi, the function returns log(z) = log(abs(z)) + 1i*atan2(b,a) where atan(b,a) is on the half-closed interval, (-pi, pi], as for the Matlab log function.

Author(s)

Catalina Anghel

Examples

1
2
3
4
5
6
7
8
9
ISOpure.util.matlab_log(5)
#[1] 1.609438
ISOpure.util.matlab_log(-5)
#[1] 1.609438+3.141593i
ISOpure.util.matlab_log(complex(real=3, imaginary=4))
#[1] 1.609438+0.927295i
ISOpure.util.matlab_log(c(2,3,4,-7,1))
#[1] 0.6931472+0.000000i 1.0986123+0.000000i 1.3862944+0.000000i
#[4] 1.9459101+3.141593i 0.0000000+0.000000i

ISOpureR documentation built on May 11, 2019, 1:02 a.m.