ARTS  2.3.1285(git:92a29ea9-dirty)
logic.h File Reference

Header file for logic.cc. More...

#include "arts.h"
#include "matpackVII.h"

Go to the source code of this file.

Functions

bool is_bool (const Index &x)
 Checks if a variable equals 0 or 1. More...
 
bool is_multiple (const Index &x, const Index &y)
 Checks if an integer is a multiple of another integer. More...
 
bool is_size (ConstVectorView x, const Index &l)
 Verifies that the size of x is l. More...
 
bool is_size (ConstMatrixView x, const Index &r, const Index &c)
 Verifies that the size of x is r by c. More...
 
bool is_size (ConstTensor3View x, const Index &p, const Index &r, const Index &c)
 Verifies that the size of x is [p,r,c]. More...
 
bool is_size (ConstTensor4View x, const Index &b, const Index &p, const Index &r, const Index &c)
 Verifies that the size of x is [b,p,r,c]. More...
 
bool is_size (ConstTensor5View x, const Index &s, const Index &b, const Index &p, const Index &r, const Index &c)
 Verifies that the size of x is [s,b,p,r,c]. More...
 
bool is_size (ConstTensor6View x, const Index &v, const Index &s, const Index &b, const Index &p, const Index &r, const Index &c)
 Verifies that the size of x is [v,s,b,p,r,c]. More...
 
bool is_size (ConstTensor7View x, const Index &l, const Index &v, const Index &s, const Index &b, const Index &p, const Index &r, const Index &c)
 Verifies that the size of x is [l,v,s,b,p,r,c]. More...
 
bool is_sorted (ConstVectorView x)
 Checks if a vector is sorted in ascending order. More...
 
bool is_increasing (ConstVectorView x)
 Checks if a vector is sorted and strictly increasing. More...
 
bool is_increasing (const ArrayOfIndex &x)
 Checks if an ArrayOfIndex is sorted and strictly increasing. More...
 
bool is_decreasing (ConstVectorView x)
 Checks if a vector is sorted in reversed order and is strictly decreasing. More...
 
bool is_unique (const ArrayOfIndex &x)
 Checks if an ArrayOfIndex is unique, i.e., has no duplicate values. More...
 
bool is_singular (ConstMatrixView A)
 Checks if a square matrix is singular. More...
 
bool is_diagonal (ConstMatrixView A)
 Checks if a square matrix is diagonal. More...
 
bool is_same_within_epsilon (const Numeric &a, const Numeric &b, const Numeric &epsilon)
 Check, if two numbers agree within a given epsilon. More...
 
bool is_lon_cyclic (ConstVectorView grid, const Numeric &epsilon=0.001)
 Check if the given longitude grid is cyclic. More...
 
template<class T >
bool is_size (const Array< T > &x, const Index &n)
 Verifies that the size of x is n. More...
 

Detailed Description

Header file for logic.cc.

Author
Stefan Buehler sbueh.nosp@m.ler@.nosp@m.ltu.s.nosp@m.e
Date
Fri May 3 19:10:04 2002

Definition in file logic.h.

Function Documentation

◆ is_bool()

bool is_bool ( const Index x)

Checks if a variable equals 0 or 1.

Returns
True if the variable is 0 or 1. Otherwise false.
Parameters
xA variable of type Index.

Definition at line 50 of file logic.cc.

Referenced by chk_if_bool().

◆ is_decreasing()

bool is_decreasing ( ConstVectorView  x)

Checks if a vector is sorted in reversed order and is strictly decreasing.

Duplicated values are not allowed.

Returns
True if strictly decreasing, otherwise false.
Parameters
xA vector.

Definition at line 252 of file logic.cc.

References i, and ConstVectorView::nelem().

Referenced by check_retrieval_grids(), chk_if_decreasing(), chk_interpolation_grids(), chk_interpolation_grids_loose_no_data_check(), gridpos(), jacobianCalcPointingZaInterp(), p_gridFromZRaw(), sensor_responseAntenna(), test44(), and VectorInsertGridPoints().

◆ is_diagonal()

bool is_diagonal ( ConstMatrixView  A)

Checks if a square matrix is diagonal.

If one off diagonal element is nonzero the function returns false.

Due to numerical inaccuracies the values can deviate from 0. The value for the precision is defined in the file logic.cc.

Returns
True if matrix is diagonal.
Parameters
AA square matrix.

Definition at line 323 of file logic.cc.

References i, ConstMatrixView::ncols(), ConstMatrixView::nrows(), and precision.

Referenced by interpTArray().

◆ is_increasing() [1/2]

◆ is_increasing() [2/2]

bool is_increasing ( const ArrayOfIndex x)

Checks if an ArrayOfIndex is sorted and strictly increasing.

Duplicated values are not allowed. Clone of the similar funciton for vectors.

Returns
True if strictly increasing, otherwise false.
Parameters
xAn ArrayOfIndex.
Author
Stefan Buehler
Date
2007-05-18

Definition at line 236 of file logic.cc.

References i, and Array< base >::nelem().

◆ is_lon_cyclic()

bool is_lon_cyclic ( ConstVectorView  grid,
const Numeric epsilon 
)

Check if the given longitude grid is cyclic.

Checks whether the grid spans 0 to 360 degrees.

Parameters
gridLongitude grid.
epsilonThe epsilon of the required agreement.
Returns
True if the grid is cyclic.

Definition at line 369 of file logic.cc.

References is_same_within_epsilon(), and ConstVectorView::nelem().

Referenced by chk_atm_field(), GriddedFieldLatLonRegrid(), gridpos_poly_cyclic_longitudinal(), gridpos_poly_longitudinal(), and plevel_slope_3d().

◆ is_multiple()

bool is_multiple ( const Index x,
const Index y 
)

Checks if an integer is a multiple of another integer.

The function returns true if y * n = x, where n is an integer.

The choice of y = 0 is not allowed.

Returns
True if x is a multiple of y.
Parameters
xNominator of the integer division.
yDenominator of the integer division.
Author
Patrick Eriksson
Date
2002-08-11

Definition at line 65 of file logic.cc.

Referenced by integer_div(), and sensor_responseFrequencySwitching().

◆ is_same_within_epsilon()

bool is_same_within_epsilon ( const Numeric a,
const Numeric b,
const Numeric epsilon 
)

Check, if two numbers agree within a given epsilon.

This logical function verifies if two numbers are the same for the desired number of digits. The comparison statement comes from Oliver: ( abs(a-b) <= epsilon * max(a,b) )

Modified to make sure that negative numbers are also treated correctly.

The variable epsilon gives the number of digits used for the comparison. (epsilon = 0.0001 for a comparison up to the 5th digit)

Parameters
aA number.
bAnother number.
epsilonThe epsilon of the required agreement.
Returns
True if the two numbers are the same.

Definition at line 351 of file logic.cc.

References abs, and max.

Referenced by chk_atm_field(), chk_atm_surface(), ConvertAzimuthallyRandomSingleScatteringData(), GriddedFieldLatLonRegrid(), interp(), is_lon_cyclic(), iyInterpCloudboxField(), scat_data_checkedCalc(), scat_data_singleTmatrix(), scat_dataCalc(), and surf_albedoCalc().

◆ is_singular()

bool is_singular ( ConstMatrixView  A)

Checks if a square matrix is singular.

If one row of a matrix has only 0 values the matrix is singular.

Due to numerical inaccuracies the values can deviate from 0. The value for the precision is defined in the file logic.cc.

Returns
True if matrix is singular.
Parameters
AA square matrix.

Definition at line 295 of file logic.cc.

References i, ConstMatrixView::ncols(), ConstMatrixView::nrows(), precision, and temp.

Referenced by ext2trans().

◆ is_size() [1/8]

◆ is_size() [2/8]

bool is_size ( ConstMatrixView  x,
const Index r,
const Index c 
)

Verifies that the size of x is r by c.

Parameters
xThe Matrix to check.
rThe desired number of rows.
cThe desired number of columns.
Returns
True if the size of x is r x c.

Definition at line 88 of file logic.cc.

◆ is_size() [3/8]

bool is_size ( ConstTensor3View  x,
const Index p,
const Index r,
const Index c 
)

Verifies that the size of x is [p,r,c].

Parameters
xThe Tensor to check.
pThe desired number of pages.
rThe desired number of rows.
cThe desired number of columns.
Returns
True if the size of x is correct.

Definition at line 100 of file logic.cc.

◆ is_size() [4/8]

bool is_size ( ConstTensor4View  x,
const Index b,
const Index p,
const Index r,
const Index c 
)

Verifies that the size of x is [b,p,r,c].

Parameters
xThe Tensor to check.
bThe desired number of books.
pThe desired number of pages.
rThe desired number of rows.
cThe desired number of columns.
Returns
True if the size of x is correct.

Definition at line 116 of file logic.cc.

◆ is_size() [5/8]

bool is_size ( ConstTensor5View  x,
const Index s,
const Index b,
const Index p,
const Index r,
const Index c 
)

Verifies that the size of x is [s,b,p,r,c].

Parameters
xThe Tensor to check.
sThe desired number of shelves.
bThe desired number of books.
pThe desired number of pages.
rThe desired number of rows.
cThe desired number of columns.
Returns
True if the size of x is correct.

Definition at line 135 of file logic.cc.

◆ is_size() [6/8]

bool is_size ( ConstTensor6View  x,
const Index v,
const Index s,
const Index b,
const Index p,
const Index r,
const Index c 
)

Verifies that the size of x is [v,s,b,p,r,c].

Parameters
xThe Tensor to check.
vThe desired number of vitrines.
sThe desired number of shelves.
bThe desired number of books.
pThe desired number of pages.
rThe desired number of rows.
cThe desired number of columns.
Returns
True if the size of x is correct.

Definition at line 156 of file logic.cc.

◆ is_size() [7/8]

bool is_size ( ConstTensor7View  x,
const Index l,
const Index v,
const Index s,
const Index b,
const Index p,
const Index r,
const Index c 
)

Verifies that the size of x is [l,v,s,b,p,r,c].

Parameters
xThe Tensor to check.
lThe desired number of libraries.
vThe desired number of vitrines.
sThe desired number of shelves.
bThe desired number of books.
pThe desired number of pages.
rThe desired number of rows.
cThe desired number of columns.
Returns
True if the size of x is correct.

Definition at line 179 of file logic.cc.

◆ is_size() [8/8]

template<class T >
bool is_size ( const Array< T > &  x,
const Index n 
)

Verifies that the size of x is n.

This function is supposed to be used together with assert like this: assert(is_size(x,n)). It works for any array type.

Parameters
xThe Array to check.
nThe desired length.
Returns
True if the size of x is n.

Definition at line 109 of file logic.h.

References Array< base >::nelem().

◆ is_sorted()

bool is_sorted ( ConstVectorView  x)

Checks if a vector is sorted in ascending order.

Duplicated values are allowed.

Parameters
xA vector.
Returns
True if sorted.

Definition at line 199 of file logic.cc.

References i, and ConstVectorView::nelem().

Referenced by test44(), and ybatchTimeAveraging().

◆ is_unique()

bool is_unique ( const ArrayOfIndex x)

Checks if an ArrayOfIndex is unique, i.e., has no duplicate values.

This only returns true if the array does not contain any duplicate values.

Returns
True if unique, otherwise false.
Parameters
xAn ArrayOfIndex.
Author
Stefan Buehler
Date
2008-08-24

Definition at line 274 of file logic.cc.

References i, and Array< base >::nelem().

Referenced by abs_lookupCalc(), and GasAbsLookup::Adapt().