ARTS  2.2.66
math_funcs.cc File Reference
#include <iostream>
#include <cmath>
#include <stdexcept>
#include "array.h"
#include "math_funcs.h"
#include "logic.h"
#include "mystring.h"
Include dependency graph for math_funcs.cc:

Go to the source code of this file.

Functions

Numeric fac (const Index n)
 fac More...
 
Index integer_div (const Index &x, const Index &y)
 integer_div More...
 
Numeric LagrangeInterpol4 (ConstVectorView x, ConstVectorView y, const Numeric a)
 Lagrange Interpolation (internal function). More...
 
Numeric last (ConstVectorView x)
 last More...
 
Index last (const ArrayOfIndex &x)
 last More...
 
void linspace (Vector &x, const Numeric start, const Numeric stop, const Numeric step)
 linspace More...
 
void nlinspace (Vector &x, const Numeric start, const Numeric stop, const Index n)
 nlinspace More...
 
void nlogspace (Vector &x, const Numeric start, const Numeric stop, const Index n)
 nlogspace More...
 
Numeric AngIntegrate_trapezoid (ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
 AngIntegrate_trapezoid. More...
 
Numeric AngIntegrate_trapezoid_opti (ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
 AngIntegrate_trapezoid_opti. More...
 
Numeric AngIntegrate_trapezoid (ConstVectorView Integrand, ConstVectorView za_grid)
 AngIntegrate_trapezoid. More...
 
Numeric sign (const Numeric &x)
 sign More...
 
Numeric gamma_func (Numeric xx)
 Gamma Function. More...
 
Numeric lgamma_func (Numeric xx)
 ln Gamma Function More...
 
void unitl (Vector &x)
 lunit More...
 

Variables

const Numeric DEG2RAD
 
const Numeric PI
 

Detailed Description

Author
Patrick Eriksson Patri.nosp@m.ck.E.nosp@m.rikss.nosp@m.on@c.nosp@m.halme.nosp@m.rs.s.nosp@m.e
Date
2000-09-18

Contains basic mathematical functions.

Definition in file math_funcs.cc.

Function Documentation

◆ AngIntegrate_trapezoid() [1/2]

Numeric AngIntegrate_trapezoid ( ConstMatrixView  Integrand,
ConstVectorView  za_grid,
ConstVectorView  aa_grid 
)

AngIntegrate_trapezoid.

Performs an integration of a matrix over all directions defined in angular grids using the trapezoidal integration method.

Parameters
IntegrandThe Matrix to be integrated
za_gridThe zenith angle grid
aa_gridThe azimuth angle grid
Returns
The resulting integral

Definition at line 327 of file math_funcs.cc.

References DEG2RAD, is_size(), and ConstVectorView::nelem().

Referenced by AngIntegrate_trapezoid_opti(), doit_scat_fieldNormalize(), and scat_data_arrayCheck().

◆ AngIntegrate_trapezoid() [2/2]

Numeric AngIntegrate_trapezoid ( ConstVectorView  Integrand,
ConstVectorView  za_grid 
)

AngIntegrate_trapezoid.

Performs an integration of a matrix over all directions defined in angular grids using the trapezoidal integration method. The integrand is independant of the azimuth angle. The integration over the azimuth angle gives a 2*PI

Parameters
IntegrandInput : The vector to be integrated
za_gridInput : The zenith angle grid
Author
Claas Teichmann
Date
2003-05-13
Returns
The resulting integral

Definition at line 438 of file math_funcs.cc.

References DEG2RAD, is_size(), ConstVectorView::nelem(), and PI.

◆ AngIntegrate_trapezoid_opti()

Numeric AngIntegrate_trapezoid_opti ( ConstMatrixView  Integrand,
ConstVectorView  za_grid,
ConstVectorView  aa_grid,
ConstVectorView  grid_stepsize 
)

AngIntegrate_trapezoid_opti.

Performs an integration of a matrix over all directions defined in angular grids using the trapezoidal integration method.

In addition to the "old fashined" integration method, it checks whether the stepsize is constant. If it is, it uses a faster method, if not, it uses the old one.

Parameters
IntegrandInput : The Matrix to be integrated
za_gridInput : The zenith angle grid
aa_gridInput : The azimuth angle grid
grid_stepsizeInput : stepsize of the grid
Returns
The resulting integral
Author
Claas Teichmann claas.nosp@m.@sat.nosp@m..phys.nosp@m.ik.u.nosp@m.ni-br.nosp@m.emen.nosp@m..de
Date
2003/05/28

Definition at line 377 of file math_funcs.cc.

References AngIntegrate_trapezoid(), DEG2RAD, is_size(), ConstVectorView::nelem(), and temp.

Referenced by doit_scat_fieldCalc(), doit_scat_fieldCalcLimb(), and test_AngIntegrate_trapezoid_opti().

◆ fac()

◆ gamma_func()

Numeric gamma_func ( Numeric  xx)

Gamma Function.

Returns gamma function of real argument 'x'. Returns error msg if argument is a negative integer or 0, or use lgamma function if argument exceeds 32.0.

Returns
gam Gamma function of x.
Parameters
xxNumeric
Author
Daniel Kreyling
Date
2010-12-13

Definition at line 497 of file math_funcs.cc.

References lgamma_func().

Referenced by IWCtopnd_MH97(), LWCtopnd(), and LWCtopnd2().

◆ integer_div()

Index integer_div ( const Index x,
const Index y 
)

integer_div

Performs an integer division.

The function asserts that the reminder of the division x/y is 0.

Returns
The quotient
Parameters
xNominator
yDenominator
Author
Patrick Eriksson
Date
2002-08-11

Definition at line 95 of file math_funcs.cc.

References is_multiple().

◆ LagrangeInterpol4()

Numeric LagrangeInterpol4 ( ConstVectorView  x,
ConstVectorView  y,
const Numeric  a 
)

Lagrange Interpolation (internal function).

This function calculates the Lagrange interpolation of four interpolation points as described in Lagrange Interpolating Polynomial.
The input are the four x-axis values [x0,x1,x2,x3] and their associated y-axis values [y0,y1,y2,y3]. Furthermore the x-axis point "a" at which the interpolation should be calculated must be given as input. NOTE that the relation x2 =< x < x3 MUST hold!

Parameters
xx-vector with four elements [x0,x1,x2,x3]
yy-vector with four elements: yj = y(xj), j=0,1,2,3
ainterpolation point on the x-axis with x1 =< a < x2
Returns
FIXME
Author
Thomas Kuhn
Date
2003-11-25

Definition at line 124 of file math_funcs.cc.

References ConstVectorView::nelem().

◆ last() [1/2]

Numeric last ( ConstVectorView  x)

last

Returns the last value of a vector.

Returns
The last value of x.
Parameters
xA vector.
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 183 of file math_funcs.cc.

References ConstVectorView::nelem().

Referenced by antenna2d_simplified(), chk_scat_data(), find_effective_channel_boundaries(), iyFOS(), mixer_matrix(), pos2refell_r(), refr_index_airFreeElectrons(), sensor_responseAntenna(), sensor_responseBackend(), sensor_responseMixer(), sensor_summation_vector(), and ySimpleSpectrometer().

◆ last() [2/2]

Index last ( const ArrayOfIndex x)

last

Returns the last value of an index array.

Returns
The last value of x.
Parameters
xAn index array.
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 201 of file math_funcs.cc.

References Array< base >::nelem().

◆ lgamma_func()

Numeric lgamma_func ( Numeric  xx)

ln Gamma Function

Returns ln of gamma function for real argument 'x'.

Returns
ln Gamma function of x.
Parameters
xxNumeric
Author
Daniel Kreyling
Date
2010-12-13

Definition at line 538 of file math_funcs.cc.

Referenced by gamma_func().

◆ linspace()

void linspace ( Vector x,
const Numeric  start,
const Numeric  stop,
const Numeric  step 
)

linspace

Linearly spaced vector with specified spacing.

The first element of x is always start. The next value is start+step etc. Note that the last value can deviate from stop. The step can be both positive and negative. (in Matlab notation: start:step:stop)

Size of result is adjusted within this function!

Parameters
xOutput: linearly spaced vector
startfirst value in x
stoplast value of x <= stop
stepdistance between values in x
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 228 of file math_funcs.cc.

References Vector::resize().

Referenced by VectorLinSpace(), VectorLogSpace(), and ySimpleSpectrometer().

◆ nlinspace()

void nlinspace ( Vector x,
const Numeric  start,
const Numeric  stop,
const Index  n 
)

nlinspace

Linearly spaced vector with specified length.

Returns a vector equally and linearly spaced between start and stop of length n. (equals the Matlab function linspace)

The length must be > 1.

Parameters
xOutput: linearly spaced vector
startfirst value in x
stoplast value of x <= stop
nlength of x
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 261 of file math_funcs.cc.

References Vector::resize().

Referenced by AntennaConstantGaussian1D(), calc_ssp_fixed_test(), calc_ssp_random_test(), doit_scat_fieldCalcLimb(), DoitAngularGridsSet(), DoitScatteringDataPrepare(), f_gridFromSensorAMSU(), f_gridFromSensorHIRS(), gaussian_response_autogrid(), pha_mat_sptFromDataDOITOpt(), pha_mat_sptFromMonoData(), pnd_fieldZero(), sensor_responseFillFgrid(), and VectorNLinSpace().

◆ nlogspace()

void nlogspace ( Vector x,
const Numeric  start,
const Numeric  stop,
const Index  n 
)

nlogspace

Logarithmically spaced vector with specified length.

Returns a vector logarithmically spaced vector between start and stop of length n (equals the Matlab function logspace)

The length must be > 1.

Parameters
xOutput: logarithmically spaced vector
startfirst value in x
stoplast value of x <= stop
nlength of x
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 294 of file math_funcs.cc.

References Vector::resize().

Referenced by VectorNLogSpace().

◆ sign()

Numeric sign ( const Numeric x)

sign

Returns the sign of a numeric value.

The function returns 1 if the value is greater than zero, 0 if it equals zero and -1 if it is less than zero.

Returns
The sign of x (see above).
Parameters
xA Numeric.
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 473 of file math_funcs.cc.

Referenced by binostream::float2ieee_double(), binostream::float2ieee_single(), geompath_from_r1_to_r2(), binistream::ieee_double2float(), binistream::ieee_single2float(), lat_crossing_3d(), poslos2cart(), r_crossing_2d(), raytrace_2d_linear_basic(), and specular_losCalc().

◆ unitl()

void unitl ( Vector x)

lunit

Normalises a vector to have unit length.

The standard Euclidean norm is used (2-norm).

param x In/Out: A vector.

Author
Patrick Eriksson
Date
2012-02-12

Definition at line 578 of file math_funcs.cc.

References ConstVectorView::nelem().

Variable Documentation

◆ DEG2RAD

◆ PI

const Numeric PI

Referenced by AngIntegrate_trapezoid().