There will be a webinar on pyGIMLi hosted by SEG on March 19, 2024 at 4 pm CET. Register for free here.

# pygimli.math#

Math functions and matrices.

## Overview#

Functions

 angle(p1, p2, p3) C++ signature : Caluculate modified Bessel function of the first kind See Abramowitz: Handbook of math. Caluculate modified Bessel function of the first kind See Abramowitz: Handbook of math. Caluculate modified Bessel function of the second kind See Abramowitz: Handbook of math. Caluculate modified Bessel function of the second kind See Abramowitz: Handbook of math. C++ signature : C++ signature : createCm05(*args, **kwargs) Return determinant for Matrix A. dot(A, B, c, ret) C++ signature : C++ signature : C++ signature : C++ signature : C++ signature : C++ signature : logMean(spec, model[, axis]) Compute log-mean (log-weighted mean) value of distribution. C++ signature : C++ signature : C++ signature : pow(v, p) Power function. rand(vec [[, min, max]) C++ signature : randn(vec) C++ signature : C++ signature : C++ signature : round(v, tol) C++ signature : rrms(a, b) C++ signature : C++ signature : C++ signature : C++ signature : Templates argue with python bindings symlog(x[, tol, linearSpread]) Symmetric bi-logarithmic transformation (as used in matplotlib). symlogInv(y[, tol, linearSpread]) Inverse symlog transformation. toComplex(re, im) C++ signature : C++ signature :

## Functions#

pygimli.math.angle((object)p1, (object)p2, (object)p3) object :#
C++ signature :

double angle(GIMLI::Pos,GIMLI::Pos,GIMLI::Pos)

angle( (object)z) -> object :

C++ signature :

GIMLI::Vector<double> angle(GIMLI::Vector<std::__1::complex<double>>)

angle( (object)b, (object)a) -> object :

C++ signature :

GIMLI::Vector<double> angle(GIMLI::Vector<double>,GIMLI::Vector<double>)

pygimli.math.besselI0((object)x) object :#

Caluculate modified Bessel function of the first kind See Abramowitz: Handbook of math. functions; DLLEXPORT double besselI0(double x);

C++ signature :

double besselI0(double)

pygimli.math.besselI1((object)x) object :#

Caluculate modified Bessel function of the first kind See Abramowitz: Handbook of math. functions DLLEXPORT double besselI1(double x);

C++ signature :

double besselI1(double)

pygimli.math.besselK0((object)x) object :#

Caluculate modified Bessel function of the second kind See Abramowitz: Handbook of math. functions DLLEXPORT double besselK0(double x);

C++ signature :

double besselK0(double)

Examples using pygimli.math.besselK0

Geoelectrics in 2.5D

Geoelectrics in 2.5D
pygimli.math.besselK1((object)x) object :#

Caluculate modified Bessel function of the second kind See Abramowitz: Handbook of math. functions DLLEXPORT double besselK1(double x);

C++ signature :

double besselK1(double)

Examples using pygimli.math.besselK1

Geoelectrics in 2.5D

Geoelectrics in 2.5D
pygimli.math.cos((object)a) object :#
C++ signature :

GIMLI::Vector<double> cos(GIMLI::Vector<double>)

pygimli.math.cot((object)a) object :#
C++ signature :

GIMLI::Vector<double> cot(GIMLI::Vector<double>)

cot( (object)a) -> object :

C++ signature :

double cot(double)

pygimli.math.createCm05(*args, **kwargs)#
pygimli.math.det((object)A) object :#

Return determinant for Matrix A. This function is a stub. Only Matrix dimensions of 2 and 3 are considered.

C++ signature :

double det(GIMLI::Matrix3<double>)

det( (object)A) -> object :

Return determinant for Matrix A. This function is a stub. Only Matrix dimensions of 2 and 3 are considered.

C++ signature :

double det(GIMLI::Matrix3<double>)

det( (object)A) -> object :

Return determinant for Matrix A. This function is a stub. Only Matrix dimensions of 2 and 3 are considered.

C++ signature :

double det(GIMLI::Matrix<double>)

pygimli.math.dot((object)A, (object)B, (object)c, (object)ret) object :#
C++ signature :

void* dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,double,GIMLI::ElementMatrix<double> {lvalue})

dot( (object)A, (object)B, (object)c, (object)ret) -> object :

C++ signature :

void* dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,GIMLI::Pos,GIMLI::ElementMatrix<double> {lvalue})

dot( (object)A, (object)B, (object)c, (object)ret) -> object :

C++ signature :

void* dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,GIMLI::Matrix<double>,GIMLI::ElementMatrix<double> {lvalue})

dot( (object)A, (object)B, (object)c, (object)ret) -> object :

C++ signature :

void* dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,GIMLI::FEAFunction,GIMLI::ElementMatrix<double> {lvalue})

dot( (object)A, (object)B, (object)c) -> object :

C++ signature :

GIMLI::ElementMatrix<double> dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,double)

dot( (object)A, (object)B, (object)c) -> object :

C++ signature :

GIMLI::ElementMatrix<double> dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,GIMLI::Pos)

dot( (object)A, (object)B, (object)c) -> object :

C++ signature :

GIMLI::ElementMatrix<double> dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,GIMLI::Matrix<double>)

dot( (object)A, (object)B [, (object)c]) -> object :

C++ signature :

GIMLI::ElementMatrix<double> dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double> [,GIMLI::FEAFunction])

dot( (object)A, (object)B, (object)ret) -> object :

C++ signature :

void* dot(GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double>,GIMLI::ElementMatrix<double> {lvalue})

dot( (object)v1, (object)v2) -> object :

C++ signature :

double dot(GIMLI::Vector<double>,GIMLI::Vector<double>)

pygimli.math.exp((object)a) object :#
C++ signature :

GIMLI::Vector<double> exp(GIMLI::Vector<double>)

pygimli.math.exp10((object)a) object :#
C++ signature :

GIMLI::Vector<double> exp10(GIMLI::Vector<double>)

exp10( (object)a) -> object :

C++ signature :

double exp10(double)

pygimli.math.imag((object)A) object :#
C++ signature :

GIMLI::SparseMapMatrix<double, unsigned long> imag(GIMLI::SparseMapMatrix<std::__1::complex<double>, unsigned long>)

imag( (object)A) -> object :

C++ signature :

GIMLI::SparseMatrix<double> imag(GIMLI::SparseMatrix<std::__1::complex<double>>)

imag( (object)cv) -> object :

C++ signature :

GIMLI::Matrix<double> imag(GIMLI::Matrix<std::__1::complex<double>>)

imag( (object)A) -> object :

C++ signature :

GIMLI::Matrix<double> imag(GIMLI::Matrix<std::__1::complex<double>>)

imag( (object)cv) -> object :

C++ signature :

GIMLI::Vector<double> imag(GIMLI::Vector<std::__1::complex<double>>)

pygimli.math.log((object)a) object :#
C++ signature :

GIMLI::Vector<double> log(GIMLI::Vector<double>)

log( (object)type, (object)msg) -> object :

C++ signature :

void* log(GIMLI::LogType,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)

log( (object)type, (object)vs) -> object :

C++ signature :

void* log(GIMLI::LogType,char const*)

log( (object)type, (object)vs, (object)vs) -> object :

C++ signature :

void* log(GIMLI::LogType,char const*,char const*)

log( (object)type, (object)vs) -> object :

C++ signature :

void* log(GIMLI::LogType,std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>)

pygimli.math.log10((object)a) object :#
C++ signature :

GIMLI::Vector<double> log10(GIMLI::Vector<double>)

pygimli.math.logMean(spec, model, axis=0)[source]#

Compute log-mean (log-weighted mean) value of distribution.

specarray

abscissa values (spectral axis)

modelarray|array-2d

matrix of density values

axisint [0]

axis to sum over

pygimli.math.max((object)v) object :#
C++ signature :

int max(std::__1::vector<int, std::__1::allocator<int>>)

max( (object)v) -> object :

C++ signature :

std::__1::complex<double> max(GIMLI::Vector<std::__1::complex<double>>)

max( (object)v) -> object :

C++ signature :

unsigned long max(GIMLI::Vector<unsigned long>)

max( (object)v) -> object :

C++ signature :

double max(GIMLI::Vector<double>)

max( (object)a, (object)b) -> object :

C++ signature :

unsigned long max(unsigned long,unsigned long)

max( (object)a, (object)b) -> object :

C++ signature :

int max(int,unsigned long)

pygimli.math.median((object)a) object :#
C++ signature :

double median(GIMLI::Vector<double>)

pygimli.math.min((object)v) object :#
C++ signature :

std::__1::complex<double> min(GIMLI::Vector<std::__1::complex<double>>)

min( (object)v) -> object :

C++ signature :

double min(GIMLI::Vector<double>)

min( (object)a, (object)b) -> object :

C++ signature :

unsigned long min(unsigned long,unsigned long)

pygimli.math.pow(v, p)[source]#

Power function.

pow(v, int) is misinterpreted as pow(v, rvec(int)), so we need to fix this

Examples using pygimli.math.pow

Polyfit

Polyfit
pygimli.math.rand((object)vec[, (object)min=0.0[, (object)max=1.0]]) object :#
C++ signature :

void* rand(GIMLI::Vector<double> {lvalue} [,double=0.0 [,double=1.0]])

pygimli.math.randn((object)vec) object :#
C++ signature :

void* randn(GIMLI::Vector<double> {lvalue})

randn( (object)n) -> object :

Create a array of len n with normal distributed randomized values.

C++ signature :

GIMLI::Vector<double> randn(unsigned long)

pygimli.math.real((object)A) object :#
C++ signature :

GIMLI::SparseMapMatrix<double, unsigned long> real(GIMLI::SparseMapMatrix<std::__1::complex<double>, unsigned long>)

real( (object)A) -> object :

C++ signature :

GIMLI::SparseMatrix<double> real(GIMLI::SparseMatrix<std::__1::complex<double>>)

real( (object)cv) -> object :

C++ signature :

GIMLI::Matrix<double> real(GIMLI::Matrix<std::__1::complex<double>>)

real( (object)A) -> object :

C++ signature :

GIMLI::Matrix<double> real(GIMLI::Matrix<std::__1::complex<double>>)

real( (object)cv) -> object :

C++ signature :

GIMLI::Vector<double> real(GIMLI::Vector<std::__1::complex<double>>)

pygimli.math.rms((object)a) object :#
C++ signature :

double rms(GIMLI::Vector<double>)

rms( (object)a, (object)b) -> object :

C++ signature :

double rms(GIMLI::Vector<double>,GIMLI::Vector<double>)

pygimli.math.round((object)v, (object)tol) object :#
C++ signature :

GIMLI::Vector<double> round(GIMLI::Vector<double>,double)

pygimli.math.rrms((object)a, (object)b) object :#
C++ signature :

double rrms(GIMLI::Vector<double>,GIMLI::Vector<double>)

pygimli.math.sign((object)a) object :#
C++ signature :

GIMLI::Vector<double> sign(GIMLI::Vector<double>)

sign( (object)a) -> object :

C++ signature :

double sign(double)

pygimli.math.sin((object)a) object :#
C++ signature :

GIMLI::Vector<double> sin(GIMLI::Vector<double>)

pygimli.math.sqrt((object)a) object :#
C++ signature :

GIMLI::Vector<double> sqrt(GIMLI::Vector<double>)

pygimli.math.sum((object)c) object :#

Templates argue with python bindings

C++ signature :

std::__1::complex<double> sum(GIMLI::Vector<std::__1::complex<double>>)

sum( (object)r) -> object :

C++ signature :

double sum(GIMLI::Vector<double>)

sum( (object)i) -> object :

C++ signature :

long sum(GIMLI::Vector<long>)

Symmetric bi-logarithmic transformation (as used in matplotlib).

Transforms a signed values in a logarithmic way preserving the sign. All absolute values below a certain threshold are treated zero or linearly distributed (if linearSpread>0).

$f(x) = sign(x) * (log10(1 + abs(x)/tol) + s/2)$
Parameters:
• x (iterable) – array to be transformed

• tol (float [None]) – tolerance for minimum values to be treated zero (or linear)

• linearSpread (float) – define how wide linear transformation is done (0-not, 1-one decade)

Returns:

y – transformed array of same size

Return type:

np.array

Inverse symlog transformation.

$f(y) = sign(y) * (10^(abs(y)-s/2) - 1) * tol$
Parameters:
• y (iterable) – array to be transformed

• tol (float [None]) – tolerance for minimum values to be treated zero (or linear)

• linearSpread (float) – define how wide linear transformation is done (0-not, 1-one decade)

Returns:

x – transformed array of same size

Return type:

np.array

pygimli.math.toComplex((object)re, (object)im) object :#
C++ signature :

GIMLI::Vector<std::__1::complex<double>> toComplex(GIMLI::Vector<double>,GIMLI::Vector<double>)

toComplex( (object)re [, (object)im=0.0]) -> object :

C++ signature :

GIMLI::Vector<std::__1::complex<double>> toComplex(GIMLI::Vector<double> [,double=0.0])

toComplex( (object)re, (object)im) -> object :

C++ signature :

GIMLI::Vector<std::__1::complex<double>> toComplex(double,GIMLI::Vector<double>)

pygimli.math.unique((object)a) object :#
C++ signature :

std::__1::vector<long, std::__1::allocator<long>> unique(std::__1::vector<long, std::__1::allocator<long>>)

unique( (object)a) -> object :

Returning a copy of the vector and replacing all consecutive occurrences of a value by a single instance of that value. e.g. [0 1 1 2 1 1] -> [0 1 2 1]. To remove all double values from the vector use an additionally sorting. e.g. unique(sort(v)) gets you [0 1 2].

C++ signature :

GIMLI::Vector<double> unique(GIMLI::Vector<double>)

unique( (object)a) -> object :

Returning a copy of the vector and replacing all consecutive occurrences of a value by a single instance of that value. e.g. [0 1 1 2 1 1] -> [0 1 2 1]. To remove all double values from the vector use an additionally sorting. e.g. unique(sort(v)) gets you [0 1 2].

C++ signature :

GIMLI::Vector<long> unique(GIMLI::Vector<long>)