ARTS  1.0.222
Functions
math_funcs.h File Reference

Contains declerations of basic mathematical and vector/matrix functions. More...

#include "matpackI.h"
#include "mystring.h"

Go to the source code of this file.

Functions

Numeric first (ConstVectorView x)
 Gives the first value of a vector. More...
 
Numeric last (ConstVectorView x)
 Gives the last value of a vector. More...
 
bool any (const ArrayOfIndex &x)
 True if any element of a boolean vector, b, is not 0. More...
 
void linspace (Vector &x, const Numeric start, const Numeric stop, const Numeric step)
 Linearly spaced vector with specified spacing. More...
 
Vector linspace (const Numeric start, const Numeric stop, const Numeric step)
 
void nlinspace (Vector &x, const Numeric start, const Numeric stop, const Index n)
 Linearly spaced vector with specified length. More...
 
Vector nlinspace (const Numeric start, const Numeric stop, const Index n)
 
void nlogspace (Vector &x, const Numeric start, const Numeric stop, const Index n)
 Logarithmically spaced vector with specified length. More...
 
Vector nlogspace (const Numeric start, const Numeric stop, const Index n)
 Logarithmically spaced vector with specified length (return version). More...
 
void interp_lin_vector (VectorView yi, ConstVectorView x, ConstVectorView y, ConstVectorView xi)
 Multiple linear interpolation of a vector. More...
 
void interp_lin_matrix (MatrixView Yi, ConstVectorView x, ConstMatrixView Y, ConstVectorView xi)
 Multiple linear interpolation of matrix rows. More...
 
Numeric interp_lin (ConstVectorView x, ConstVectorView y, const Numeric xi)
 Single linear interpolation of a vector (return version). More...
 
void check_if_bool (const Index &x, const String &x_name)
 Checks if an integer is 0 or 1. More...
 
void check_if_in_range (const Numeric &x_low, const Numeric &x_high, const Numeric &x, const String &x_name)
 Checks if a numeric variable is inside a specified range. More...
 
void check_lengths (const Vector &x1, const String &x1_name, const Vector &x2, const String &x2_name)
 Checks that two vectors have the same length. More...
 
void check_length_nrow (const Vector &x, const String &x_name, const Matrix &A, const String &A_name)
 Checks that the length of a vector and the number of rows of a matrix match. More...
 
void check_length_ncol (const Vector &x, const String &x_name, const Matrix &A, const String &A_name)
 Checkss that the length of a vector and the number of columns of a matrix match. More...
 
void check_ncol_nrow (const Matrix &A, const String &A_name, const Matrix &B, const String &B_name)
 Checks that the number of columns of the first matrix is the same as the number of rows of the second matrix. More...
 

Detailed Description

Contains declerations of basic mathematical and vector/matrix functions.

Example on types of functions: \begin{enumerate} \item Element-wise application of common scalar functions \item Boolean functions
\item Creation of common vectors
\item Interpolation routines
\item Integration routines
\item Conversion between vector and matrix types \end{enumerate}

Author
Patrick Eriksson
Date
2000-09-18

Definition in file math_funcs.h.

Function Documentation

◆ any()

bool any ( const ArrayOfIndex x)

True if any element of a boolean vector, b, is not 0.

Returns
a boolean, true if any x is != 0
Parameters
xa vector
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 104 of file math_funcs.cc.

◆ check_if_bool()

void check_if_bool ( const Index x,
const String x_name 
)

Checks if an integer is 0 or 1.

A runtime error is thrown if the integer is not a boolean.

Parameters
xan integer
x_namethe name of the integer
Author
Patrick Eriksson
Date
2001-09-19

Definition at line 468 of file math_funcs.cc.

◆ check_if_in_range()

void check_if_in_range ( const Numeric x_low,
const Numeric x_high,
const Numeric x,
const String x_name 
)

Checks if a numeric variable is inside a specified range.

A runtime error is thrown if the variable is outside the range.

Parameters
x_lowlower limit
x_highupper limit
xa numeric
x_namethe name of the numeric
Author
Patrick Eriksson
Date
2001-09-26

Definition at line 495 of file math_funcs.cc.

◆ check_length_ncol()

void check_length_ncol ( const Vector x,
const String x_name,
const Matrix A,
const String A_name 
)

Checkss that the length of a vector and the number of columns of a matrix match.

A runtime error is thrown if the length of the vectors differs from the number of columns.

Parameters
xa vector
x_namethe name of the vector
Aa matrix
A_namethe name of the matrix
Author
Patrick Eriksson
Date
2001-09-19

Definition at line 592 of file math_funcs.cc.

◆ check_length_nrow()

void check_length_nrow ( const Vector x,
const String x_name,
const Matrix A,
const String A_name 
)

Checks that the length of a vector and the number of rows of a matrix match.

A runtime error is thrown if the length of the vectors differs from the number of rows.

Parameters
xa vector
x_namethe name of the vector
Aa matrix
A_namethe name of the matrix
Author
Patrick Eriksson
Date
2001-09-19

Definition at line 559 of file math_funcs.cc.

◆ check_lengths()

void check_lengths ( const Vector x1,
const String x1_name,
const Vector x2,
const String x2_name 
)

Checks that two vectors have the same length.

A runtime error is thrown if the lengths of the vectors differ.

Parameters
x1vector 1
x1_namethe name of vector1
x2vector 2
x2_namethe name of vector2
Author
Patrick Eriksson
Date
2001-09-19

Definition at line 527 of file math_funcs.cc.

◆ check_ncol_nrow()

void check_ncol_nrow ( const Matrix A,
const String A_name,
const Matrix B,
const String B_name 
)

Checks that the number of columns of the first matrix is the same as the number of rows of the second matrix.

A runtime error is thrown otherwise.

Parameters
Afirst Matrix
A_namethe name of the first Matrix
Bsecond matrix
B_namethe name of the second matrix
Author
Stefan Buehler
Date
2001-10-02

Definition at line 622 of file math_funcs.cc.

◆ first()

Numeric first ( ConstVectorView  x)

Gives the first value of a vector.

Returns
the first value of x
Parameters
xa vector
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 70 of file math_funcs.cc.

◆ interp_lin()

Numeric interp_lin ( ConstVectorView  x,
ConstVectorView  y,
const Numeric  xi 
)

Single linear interpolation of a vector (return version).

The vector x specifies the points at which the data y is given.

Returns
interpolated value
Parameters
xthe x grid
ythe function to interpolate
xiinterpolation point
Author
Patrick Eriksson
Date
2000-06-29

Definition at line 435 of file math_funcs.cc.

◆ interp_lin_matrix()

void interp_lin_matrix ( MatrixView  Yi,
ConstVectorView  x,
ConstMatrixView  Y,
ConstVectorView  xi 
)

Multiple linear interpolation of matrix rows.

Works with subranges inside the argument. Use the transpose(A) function if you want to interpolate columns of A instead of rows.

The vector x specifies the points at which the data y is given.

Interpolation works also for new grid points just outside the original grid range.

Return values
Yiinterpolated values (matrix)
Parameters
xthe x grid (vector)
Ythe function to interpolate (matrix)
xiinterpolation points (vector)
Date
2001-01-06, 2003-08-06
Author
Stefan Buehler, Stefan Buehler

Definition at line 383 of file math_funcs.cc.

◆ interp_lin_vector()

void interp_lin_vector ( VectorView  yi,
ConstVectorView  x,
ConstVectorView  y,
ConstVectorView  xi 
)

Multiple linear interpolation of a vector.

Because Views are used, you can use matrix rows or columns, or vector sub-ranges inside the argument of this function.

The vector x specifies the points at which the data y is given. It must be strictly monotonically increasing. (No two x values must be the same.)

The size of yi has to be the same as for xi.

Interpolation works also for new grid points just outside the original grid range.

Return values
yiinterpolated values
Parameters
xthe x grid
ythe function to interpolate
xiinterpolation points
Date
2001-01-05, 2003-08-06
Author
Stefan Buehler, Stefan Buehler

Definition at line 329 of file math_funcs.cc.

◆ last()

Numeric last ( ConstVectorView  x)

Gives 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 83 of file math_funcs.cc.

◆ linspace() [1/2]

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

◆ linspace() [2/2]

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

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!

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

Definition at line 139 of file math_funcs.cc.

◆ nlinspace() [1/2]

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

◆ nlinspace() [2/2]

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

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.

Return values
xlinearly spaced vector
Parameters
startfirst value in x
stoplast value of x <= stop
nlength of x
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 168 of file math_funcs.cc.

◆ nlogspace() [1/2]

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

Logarithmically spaced vector with specified length (return version).

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

The length must be > 1.

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

Definition at line 234 of file math_funcs.cc.

◆ nlogspace() [2/2]

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

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.

Return values
xlogarithmically spaced vector
Parameters
startfirst value in x
stoplast value of x <= stop
nlength of x
Author
Patrick Eriksson
Date
2000-06-27

Definition at line 198 of file math_funcs.cc.