ARTS
2.2.66
|
Logical functions. More...
Go to the source code of this file.
Macros | |
#define | precision 0. |
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 &n) |
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) |
Check if the given longitude grid is cyclic. More... | |
Logical functions.
All functions here have return type bool. They all check whether some condition is fullfilled and return true if that is the case.
These functions are intended to be used either inside "if" statements or inside "assert" statements.
The condition should have a simple and intuitive meaning!
Definition in file logic.cc.
bool is_bool | ( | const Index & | x | ) |
Checks if a variable equals 0 or 1.
x | A variable of type Index. |
Definition at line 54 of file logic.cc.
Referenced by chk_if_bool().
bool is_decreasing | ( | ConstVectorView | x | ) |
Checks if a vector is sorted in reversed order and is strictly decreasing.
Duplicated values are not allowed.
x | A vector. |
Definition at line 324 of file logic.cc.
References ConstVectorView::nelem().
Referenced by check_retrieval_grids(), chk_if_decreasing(), chk_interpolation_grids(), chk_interpolation_grids_loose_no_data_check(), get_perturbation_limit(), gridpos(), p_gridFromZRaw(), sensor_integration_vector(), sensor_integration_vector2(), sensor_responseInit(), test44(), VectorInsertGridPoints(), and yCloudRadar().
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.
A | A square matrix. |
Definition at line 411 of file logic.cc.
References ConstMatrixView::ncols(), ConstMatrixView::nrows(), and precision.
Referenced by interpTArray(), iyRadioLink(), iyTransmissionStandard(), mcPathTraceGeneral(), and mcPathTraceIPA().
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.
x | An ArrayOfIndex. |
Definition at line 302 of file logic.cc.
References Array< base >::nelem().
bool is_increasing | ( | ConstVectorView | x | ) |
Checks if a vector is sorted and strictly increasing.
Duplicated values are not allowed.
x | A vector. |
Definition at line 275 of file logic.cc.
References ConstVectorView::nelem().
Referenced by check_retrieval_grids(), chk_if_increasing(), chk_interpolation_grids(), chk_interpolation_grids_loose_no_data_check(), DoitInit(), find_effective_channel_boundaries(), gridpos(), p_gridFromZRaw(), sensor_integration_vector(), sensor_integration_vector2(), sensor_responseBackend(), sensor_responseInit(), sensor_responseMixer(), test44(), VectorInsertGridPoints(), and yCloudRadar().
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.
grid | Longitude grid. |
epsilon | The epsilon of the required agreement. |
Definition at line 466 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().
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.
x | Nominator of the integer division. |
y | Denominator of the integer division. |
Definition at line 74 of file logic.cc.
Referenced by integer_div(), and sensor_responseFrequencySwitching().
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)
a | A number. |
b | Another number. |
epsilon | The epsilon of the required agreement. |
Definition at line 446 of file logic.cc.
Referenced by chk_atm_field(), chk_atm_surface(), GriddedFieldLatLonRegrid(), interp(), and is_lon_cyclic().
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.
A | A square matrix. |
Definition at line 377 of file logic.cc.
References ConstMatrixView::ncols(), ConstMatrixView::nrows(), precision, and temp.
Referenced by cloud_ppath_update1D_planeparallel(), cloud_RT_no_background(), ext2trans(), and rte_step_doit().
bool is_size | ( | ConstMatrixView | x, |
const Index & | r, | ||
const Index & | c | ||
) |
Verifies that the size of x is r by c.
x | The Matrix to check. |
r | The desired number of rows. |
c | The desired number of columns. |
Definition at line 106 of file logic.cc.
References ConstMatrixView::ncols(), and ConstMatrixView::nrows().
bool is_size | ( | ConstTensor3View | x, |
const Index & | p, | ||
const Index & | r, | ||
const Index & | c | ||
) |
Verifies that the size of x is [p,r,c].
x | The Tensor to check. |
p | The desired number of pages. |
r | The desired number of rows. |
c | The desired number of columns. |
Definition at line 124 of file logic.cc.
References ConstTensor3View::ncols(), ConstTensor3View::npages(), and ConstTensor3View::nrows().
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].
x | The Tensor to check. |
b | The desired number of books. |
p | The desired number of pages. |
r | The desired number of rows. |
c | The desired number of columns. |
Definition at line 145 of file logic.cc.
References ConstTensor4View::nbooks(), ConstTensor4View::ncols(), ConstTensor4View::npages(), and ConstTensor4View::nrows().
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].
x | The Tensor to check. |
s | The desired number of shelves. |
b | The desired number of books. |
p | The desired number of pages. |
r | The desired number of rows. |
c | The desired number of columns. |
Definition at line 169 of file logic.cc.
References ConstTensor5View::nbooks(), ConstTensor5View::ncols(), ConstTensor5View::npages(), ConstTensor5View::nrows(), and ConstTensor5View::nshelves().
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].
x | The Tensor to check. |
v | The desired number of vitrines. |
s | The desired number of shelves. |
b | The desired number of books. |
p | The desired number of pages. |
r | The desired number of rows. |
c | The desired number of columns. |
Definition at line 196 of file logic.cc.
References ConstTensor6View::nbooks(), ConstTensor6View::ncols(), ConstTensor6View::npages(), ConstTensor6View::nrows(), ConstTensor6View::nshelves(), and ConstTensor6View::nvitrines().
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].
x | The Tensor to check. |
l | The desired number of libraries. |
v | The desired number of vitrines. |
s | The desired number of shelves. |
b | The desired number of books. |
p | The desired number of pages. |
r | The desired number of rows. |
c | The desired number of columns. |
Definition at line 226 of file logic.cc.
References ConstTensor7View::nbooks(), ConstTensor7View::ncols(), ConstTensor7View::nlibraries(), ConstTensor7View::npages(), ConstTensor7View::nrows(), ConstTensor7View::nshelves(), and ConstTensor7View::nvitrines().
bool is_size | ( | ConstVectorView | x, |
const Index & | n | ||
) |
Verifies that the size of x is l.
This function is supposed to be used together with assert like this: assert(is_size(x,l))
x | The Vector to check. |
n | The desired length. |
Definition at line 91 of file logic.cc.
References ConstVectorView::nelem().
Referenced by AngIntegrate_trapezoid(), AngIntegrate_trapezoid_fixedstep(), AngIntegrate_trapezoid_fixedstep_opt(), AngIntegrate_trapezoid_fixedstep_opt2(), AngIntegrate_trapezoid_opt(), AngIntegrate_trapezoid_opti(), AngIntegrate_trapezoid_original(), chk_size(), doit_conv_flagAbs(), doit_conv_flagAbsBT(), doit_conv_flagLsq(), doit_i_fieldSetConst(), doit_i_fieldUpdate1D(), doit_i_fieldUpdateSeq1D(), doit_i_fieldUpdateSeq1DPP(), doit_i_fieldUpdateSeq3D(), doit_scat_fieldCalc(), doit_scat_fieldCalcLimb(), DoitCloudboxFieldPut(), GasAbsLookup::Extract(), gridpos(), gridpos_poly(), interp(), interpweights(), iy_interp_cloudbox_field(), lubacksub(), ludcmp(), matrix_exp(), rte_step_doit(), and ScatteringMergeParticles1D().
bool is_sorted | ( | ConstVectorView | x | ) |
Checks if a vector is sorted in ascending order.
Duplicated values are allowed.
x | A vector. |
Definition at line 253 of file logic.cc.
References ConstVectorView::nelem().
Referenced by test44(), and xsec_species().
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.
x | An ArrayOfIndex. |
Definition at line 352 of file logic.cc.
References Array< base >::nelem().
Referenced by GasAbsLookup::Adapt().