68 if (n == 0)
return (1.0);
119 const Numeric Dlimit = 1.00000e-15;
125 "The vectors x and y must all have the same length of 4 elements!\n"
132 "LagrangeInterpol4: the relation x[1] =< a < x[2] is not satisfied. "
133 "No interpolation can be calculated.\n")
137 for (
Index i = 0; i < 4; ++i) {
139 for (
Index k = 0; k < 4; ++k) {
140 if ((k != i) && (fabs(x[i] - x[k]) > Dlimit))
141 b[i] =
b[i] * ((
a - x[k]) / (x[i] - x[k]));
146 for (
Index i = 0; i < n_x; ++i) ya = ya +
b[i] * y[i];
163 return x[x.
nelem() - 1];
178 return x[x.
nelem() - 1];
204 Index n = (
Index)floor((stop - start) / step) + 1;
207 for (
Index i = 0; i < n; i++) x[i] = start + (
double)i * step;
233 Numeric step = (stop - start) / ((
double)n - 1);
234 for (
Index i = 0; i < n - 1; i++) x[i] = start + (
double)i * step;
241 Numeric step = (stop - start) / ((
double)n - 1);
242 for (
Index i = 0; i < n - 1; i++) x[i] = start + (
double)i * step;
275 Numeric step = (log(stop) -
a) / ((
double)n - 1);
277 for (
Index i = 1; i < n - 1; i++) x[i] = exp(
a + (
double)i * step);
299 for (
Index i=1; i<n; ++i)
300 sum += (x[i]-x[i-1]) * (y[i]+y[i-1]);
322 for (
Index i=1; i<n; ++i)
323 csum[i] = csum[i-1] + x[i];
345 for (
Index i = 0; i < n; ++i) {
348 for (
Index j = 0; j < m - 1; ++j) {
349 res1[i] += 0.5 *
DEG2RAD * (Integrand(i, j) + Integrand(i, j + 1)) *
350 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[i] *
DEG2RAD);
354 for (
Index i = 0; i < n - 1; ++i) {
356 0.5 *
DEG2RAD * (res1[i] + res1[i + 1]) * (za_grid[i + 1] - za_grid[i]);
386 if ((grid_stepsize[0] > 0) && (grid_stepsize[1] > 0)) {
389 Numeric stepsize_za = grid_stepsize[0];
390 Numeric stepsize_aa = grid_stepsize[1];
396 for (
Index i = 0; i < n; ++i) {
397 temp = Integrand(i, 0);
398 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++) {
411 res *= 0.5 *
DEG2RAD * stepsize_za;
440 for (
Index i = 0; i < n - 1; ++i) {
443 (Integrand[i] * sin(za_grid[i] *
DEG2RAD) +
444 Integrand[i + 1] * sin(za_grid[i + 1] *
DEG2RAD)) *
445 (za_grid[i + 1] - za_grid[i]);
505 for (
Index ix = 0; ix < nx; ix++) {
506 const Numeric eterm = exp(-la * x[ix]);
507 psd[ix] = n0 * eterm;
511 "Given mu is ", mu,
'\n',
512 "Seems unreasonable. Have you mixed up the inputs?")
514 for (
Index ix = 0; ix < nx; ix++) {
515 const Numeric eterm = exp(-la * x[ix]);
517 psd[ix] = n0 * xterm * eterm;
518 psd[ix] = n0 *
pow(x[ix], mu) * exp(-la * x[ix]);
524 "Given mu is ", mu,
'\n',
525 "Seems unreasonable. Have you mixed up the inputs?")
527 "Given gamma is ", ga,
'\n',
528 "Seems unreasonable. Have you mixed up the inputs?")
529 for (
Index ix = 0; ix < nx; ix++) {
531 const Numeric eterm = exp(-la * pterm);
533 psd[ix] = n0 * xterm * eterm;
569 const bool& do_n0_jac,
570 const bool& do_mu_jac,
571 const bool& do_la_jac,
572 const bool& do_ga_jac) {
579 if (ga == 1 && !do_ga_jac) {
580 if (mu == 0 && !do_mu_jac) {
582 for (
Index ix = 0; ix < nx; ix++) {
583 const Numeric eterm = exp(-la * x[ix]);
584 psd[ix] = n0 * eterm;
586 jac_data(0, ix) = eterm;
589 jac_data(2, ix) = -x[ix] * psd[ix];
594 "Given mu is ", mu,
'\n',
595 "Seems unreasonable. Have you mixed up the inputs?")
597 for (
Index ix = 0; ix < nx; ix++) {
598 const Numeric eterm = exp(-la * x[ix]);
600 psd[ix] = n0 * xterm * eterm;
602 jac_data(0, ix) = xterm * eterm;
605 jac_data(1, ix) = log(x[ix]) * psd[ix];
608 jac_data(2, ix) = -x[ix] * psd[ix];
610 psd[ix] = n0 *
pow(x[ix], mu) * exp(-la * x[ix]);
616 "Given mu is ", mu,
'\n',
617 "Seems unreasonable. Have you mixed up the inputs?")
619 "Given gamma is ", ga,
'\n',
620 "Seems unreasonable. Have you mixed up the inputs?")
621 for (
Index ix = 0; ix < nx; ix++) {
623 const Numeric eterm = exp(-la * pterm);
625 psd[ix] = n0 * xterm * eterm;
627 jac_data(0, ix) = xterm * eterm;
630 jac_data(1, ix) = log(x[ix]) * psd[ix];
633 jac_data(2, ix) = -pterm * psd[ix];
636 jac_data(3, ix) = -la * pterm * log(x[ix]) * psd[ix];
647 Numeric f_c = tgamma(4.0) / 256.0;
648 f_c *=
pow(tgamma((alpha + 5.0) / beta), 4 + alpha);
649 f_c /=
pow(tgamma((alpha + 4.0) / beta), 5 + alpha);
651 Numeric f_d = tgamma((alpha + 5.0) / beta);
652 f_d /= tgamma((alpha + 4.0) / beta);
656 psd[i] = beta * f_c *
pow(xi, alpha) * exp(-
pow(f_d * xi, beta));
658 psd[i] * (alpha / xi - beta * f_d *
pow(f_d * xi, beta - 1.0));
680 if (x > 0. && N0 > 0. && Lambda > 0. && (mu + 1) / gamma > 0.) {
682 dN = N0 *
pow(x, mu) * exp(-Lambda *
pow(x, gamma));
687 "At least one argument is zero or negative.\n"
688 "Modified gamma distribution can not be calculated.\n"
691 "lambda = ", Lambda,
"\n"
693 "gamma = ", gamma,
"\n")
712 for (
Index i = 0; i < x.
nelem(); i++) x[i] /= l;
844 w[0] = (x[1] - x[0]) / 2.;
846 for (
Index i = 1; i < nph * 2 - 1; i++) {
847 w[i] = (x[i + 1] - x[i - 1]) / 2.;
860 w[0] = (x[1] - x[0])/2;
863 for (
Index i = 1; i <
N-1; i++ ){
864 w[i] = (x[i+1] - x[i-1])/2;
868 w[
N-1] = (x[
N-1] - x[
N-2])/2;
This file contains the definition of Array.
Constants of physical expressions as constexpr.
Index nelem() const ARTS_NOEXCEPT
A constant view of a Matrix.
Index nrows() const noexcept
Index ncols() const noexcept
A constant view of a Tensor3.
Index npages() const
Returns the number of pages.
Index nrows() const
Returns the number of rows.
Index ncols() const
Returns the number of columns.
A constant view of a Vector.
Index nelem() const noexcept
Returns the number of elements.
void resize(Index n)
Resize function.
#define ARTS_ASSERT(condition,...)
#define ARTS_USER_ERROR(...)
#define ARTS_USER_ERROR_IF(condition,...)
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
bool is_multiple(const Index &x, const Index &y)
Checks if an integer is a multiple of another integer.
Header file for logic.cc.
void linspace(Vector &x, const Numeric start, const Numeric stop, const Numeric step)
linspace
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
void cumsum(VectorView csum, ConstVectorView x)
cumsum
void unitl(Vector &x)
unitl
Numeric fac(const Index n)
fac
constexpr Numeric DEG2RAD
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
void reshape(Tensor3View X, ConstVectorView x)
reshape
void mgd(VectorView psd, const Vector &x, const Numeric &n0, const Numeric &mu, const Numeric &la, const Numeric &ga)
Numeric LagrangeInterpol4(ConstVectorView x, ConstVectorView y, const Numeric a)
Lagrange Interpolation (internal function).
void delanoe_shape_with_derivative(VectorView psd, MatrixView jac_data, const Vector &x, const Numeric &alpha, const Numeric &beta)
! Shape functions for normalized PSD.
void calculate_weights_linear(Vector &x, Vector &w, const Index nph)
calculate_weights_linear
Numeric trapz(ConstVectorView x, ConstVectorView y)
trapz
Numeric mod_gamma_dist(Numeric x, Numeric N0, Numeric Lambda, Numeric mu, Numeric gamma)
Generalized Modified Gamma Distribution.
void flat(VectorView x, ConstMatrixView X)
flat
Numeric last(ConstVectorView x)
last
Index integer_div(const Index &x, const Index &y)
integer_div
Numeric AngIntegrate_trapezoid(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid.
Numeric sign(const Numeric &x)
sign
void mgd_with_derivatives(VectorView psd, MatrixView jac_data, const Vector &x, const Numeric &n0, const Numeric &mu, const Numeric &la, const Numeric &ga, const bool &do_n0_jac, const bool &do_mu_jac, const bool &do_la_jac, const bool &do_ga_jac)
void calculate_int_weights_arbitrary_grid(Vector &w, const Vector &x)
Calculates trapezoidal integration weights for arbitray grid.
Numeric AngIntegrate_trapezoid_opti(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
AngIntegrate_trapezoid_opti.
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
This file contains the definition of String, the ARTS string class.
constexpr Numeric pi
The following mathematical constants are generated in python Decimal package by the code:
constexpr auto deg2rad(auto x) noexcept
Converts degrees to radians.
Numeric pow(const Rational base, Numeric exp)
Power of.
Numeric sqrt(const Rational r)
Square root.