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.
Numeric last (ConstVectorView x)
 Gives the last value of a vector.
bool any (const ArrayOfIndex &x)
 True if any element of a boolean vector, b, is not 0.
void linspace (Vector &x, const Numeric start, const Numeric stop, const Numeric step)
 Linearly spaced vector with specified spacing.
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.
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.
Vector nlogspace (const Numeric start, const Numeric stop, const Index n)
 Logarithmically spaced vector with specified length (return version).
void interp_lin_vector (VectorView yi, ConstVectorView x, ConstVectorView y, ConstVectorView xi)
 Multiple linear interpolation of a vector.
void interp_lin_matrix (MatrixView Yi, ConstVectorView x, ConstMatrixView Y, ConstVectorView xi)
 Multiple linear interpolation of matrix rows.
Numeric interp_lin (ConstVectorView x, ConstVectorView y, const Numeric xi)
 Single linear interpolation of a vector (return version).
void check_if_bool (const Index &x, const String &x_name)
 Checks if an integer is 0 or 1.
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.
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.
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.
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.
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.


Detailed Description

Contains declerations of basic mathematical and vector/matrix functions.

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

Author:
Patrick Eriksson
Date:
2000-09-18

Definition in file math_funcs.h.


Function Documentation

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:
x a vector
Author:
Patrick Eriksson
Date:
2000-06-27

Definition at line 104 of file math_funcs.cc.

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:
x an integer
x_name the name of the integer
Author:
Patrick Eriksson
Date:
2001-09-19

Definition at line 467 of file math_funcs.cc.

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_low lower limit
x_high upper limit
x a numeric
x_name the name of the numeric
Author:
Patrick Eriksson
Date:
2001-09-26

Definition at line 494 of file math_funcs.cc.

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:
x a vector
x_name the name of the vector
A a matrix
A_name the name of the matrix
Author:
Patrick Eriksson
Date:
2001-09-19

Definition at line 591 of file math_funcs.cc.

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:
x a vector
x_name the name of the vector
A a matrix
A_name the name of the matrix
Author:
Patrick Eriksson
Date:
2001-09-19

Definition at line 558 of file math_funcs.cc.

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:
x1 vector 1
x1_name the name of vector1
x2 vector 2
x2_name the name of vector2
Author:
Patrick Eriksson
Date:
2001-09-19

Definition at line 526 of file math_funcs.cc.

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:
A first Matrix
A_name the name of the first Matrix
B second matrix
B_name the name of the second matrix
Author:
Stefan Buehler
Date:
2001-10-02

Definition at line 621 of file math_funcs.cc.

Numeric first ( ConstVectorView  x  ) 

Gives the first value of a vector.

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

Definition at line 70 of file math_funcs.cc.

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:
x the x grid
y the function to interpolate
xi interpolation point
Author:
Patrick Eriksson
Date:
2000-06-29

Definition at line 434 of file math_funcs.cc.

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:
Yi interpolated values (matrix)
Parameters:
x the x grid (vector)
Y the function to interpolate (matrix)
xi interpolation points (vector)
Date:
2001-01-06, 2003-08-06
Author:
Stefan Buehler, Stefan Buehler

Definition at line 382 of file math_funcs.cc.

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:
yi interpolated values
Parameters:
x the x grid
y the function to interpolate
xi interpolation points
Date:
2001-01-05, 2003-08-06
Author:
Stefan Buehler, Stefan Buehler

Definition at line 328 of file math_funcs.cc.

Numeric last ( ConstVectorView  x  ) 

Gives the last value of a vector.

Returns:
the last value of x
Parameters:
x a vector
Author:
Patrick Eriksson
Date:
2000-06-27

Definition at line 83 of file math_funcs.cc.

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

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:
x linearly spaced vector
Parameters:
start first value in x
stop last value of x <= stop
step distance between values in x
Author:
Patrick Eriksson
Date:
2000-06-27

Definition at line 139 of file math_funcs.cc.

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

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:
x linearly spaced vector
Parameters:
start first value in x
stop last value of x <= stop
n length of x
Author:
Patrick Eriksson
Date:
2000-06-27

Definition at line 168 of file math_funcs.cc.

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:
start first value in x
stop last value of x <= stop
n length of x
Author:
Patrick Eriksson
Date:
2000-06-27

Definition at line 234 of file math_funcs.cc.

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:
x logarithmically spaced vector
Parameters:
start first value in x
stop last value of x <= stop
n length of x
Author:
Patrick Eriksson
Date:
2000-06-27

Definition at line 198 of file math_funcs.cc.


Generated on Wed Feb 4 08:17:25 2009 for ARTS by  doxygen 1.5.6