72 if (n == 0)
return (1.0);
75 for (
Index i = 1; i <= n; i++)
129 const Numeric Dlimit = 1.00000e-15;
134 if ( (n_x != 4) || (n_y != 4) )
137 os <<
"The vectors x and y must all have the same length of 4 elements!\n" 138 <<
"Actual lengths:\n" 139 <<
"x:" << n_x <<
", " <<
"y:" << n_y <<
".";
140 throw runtime_error(os.str());
144 if ( (a < x[1]) || (a > x[2]) )
147 os <<
"LagrangeInterpol4: the relation x[1] =< a < x[2] is not satisfied. " 148 <<
"No interpolation can be calculated.\n";
149 throw runtime_error(os.str());
154 for (
Index i=0 ; i < 4 ; ++i)
157 for (
Index k=0 ; k < 4 ; ++k)
159 if ( (k != i) && (fabs(x[i]-x[k]) > Dlimit) )
160 b[i] = b[i] * ( (a-x[k]) / (x[i]-x[k]) );
165 for (
Index i=0 ; i < n_x ; ++i) ya = ya + b[i]*y[i];
185 assert( x.
nelem() > 0 );
186 return x[x.
nelem()-1];
203 assert( x.
nelem() > 0 );
204 return x[x.
nelem()-1];
234 Index n = (
Index) floor( (stop-start)/step ) + 1;
238 for (
Index i=0; i<n; i++ )
239 x[i] = start + (
double)i*step;
269 Numeric step = (stop-start)/((
double)n-1) ;
270 for (
Index i=0; i<n-1; i++ )
271 x[i] = start + (
double)i*step;
308 Numeric step = (log(stop)-a)/((
double)n-1);
310 for (
Index i=1; i<n-1; i++ )
311 x[i] = exp(a + (
double)i*step);
335 assert (
is_size(Integrand, n, m));
337 for (
Index i = 0; i < n ; ++i)
341 for (
Index j = 0; j < m - 1; ++j)
343 res1[i] += 0.5 *
DEG2RAD * (Integrand(i, j) + Integrand(i, j + 1)) *
344 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[i] *
DEG2RAD);
348 for (
Index i = 0; i < n - 1; ++i)
350 res += 0.5 *
DEG2RAD * (res1[i] + res1[i + 1]) *
351 (za_grid[i + 1] - za_grid[i]);
383 if ((grid_stepsize[0] > 0) && (grid_stepsize[1] > 0))
387 Numeric stepsize_za = grid_stepsize[0];
388 Numeric stepsize_aa = grid_stepsize[1];
390 assert (
is_size(Integrand, n, m));
394 for (
Index i = 0; i < n ; ++i)
396 temp = Integrand(i, 0);
397 for (
Index j = 1; j < m - 1; j++)
399 temp += Integrand(i, j) * 2;
401 temp += Integrand(i, m-1);
407 for (
Index i = 1; i < n - 1; i++)
412 res *= 0.5 *
DEG2RAD * stepsize_za;
443 assert (
is_size(Integrand, n));
446 for (
Index i = 0; i < n - 1; ++i)
450 + Integrand[i + 1] * sin(za_grid[i + 1] * DEG2RAD))
451 * (za_grid[i + 1] - za_grid[i]);
517 os <<
"Argument is zero or negative." 518 <<
"Gamma function can not be calculated.\n";
519 throw runtime_error(os.str());
542 static const Numeric cof[6] = {
543 76.18009172947146, -86.50532032941677, 24.01409824083091,
544 -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5
551 tmp -= (x+0.5)*log(tmp);
552 ser = 1.000000000190015;
553 for (
Index j=0;j<=5;j++) ser += cof[j]/++y;
554 return -tmp+log(2.5066282746310005*ser/x);
559 os <<
"Argument is zero or negative.\n" 560 <<
"log Gamma function can not be calculated.\n";
561 throw runtime_error(os.str());
580 assert( x.
nelem() > 0 );
583 for(
Index i=0; i<x.nelem(); i++ )
INDEX Index
The type to use for all integer numbers and indices.
void unitl(Vector &x)
lunit
Index nelem() const
Number of elements.
Numeric AngIntegrate_trapezoid_opti(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
AngIntegrate_trapezoid_opti.
Numeric fac(const Index n)
fac
Numeric LagrangeInterpol4(ConstVectorView x, ConstVectorView y, const Numeric a)
Lagrange Interpolation (internal function).
Numeric last(ConstVectorView x)
last
bool is_multiple(const Index &x, const Index &y)
Checks if an integer is a multiple of another integer.
Index nelem() const
Returns the number of elements.
Numeric sign(const Numeric &x)
sign
This file contains the definition of Array.
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
NUMERIC Numeric
The type to use for all floating point numbers.
Index integer_div(const Index &x, const Index &y)
integer_div
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
Header file for logic.cc.
This can be used to make arrays out of anything.
void resize(Index n)
Assignment operator from VectorView.
A constant view of a Vector.
A constant view of a Matrix.
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
Numeric gamma_func(Numeric xx)
Gamma Function.
void linspace(Vector &x, const Numeric start, const Numeric stop, const Numeric step)
linspace
Numeric lgamma_func(Numeric xx)
ln Gamma Function
Numeric AngIntegrate_trapezoid(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid.
This file contains the definition of String, the ARTS string class.