Go to the documentation of this file.
66 if (n == 0)
return (1.0);
117 const Numeric Dlimit = 1.00000e-15;
120 const Index n_x =
x.nelem();
121 const Index n_y =
y.nelem();
122 if ((n_x != 4) || (n_y != 4)) {
124 os <<
"The vectors x and y must all have the same length of 4 elements!\n"
125 <<
"Actual lengths:\n"
126 <<
"x:" << n_x <<
", "
127 <<
"y:" << n_y <<
".";
128 throw runtime_error(os.str());
132 if ((a <
x[1]) || (a >
x[2])) {
134 os <<
"LagrangeInterpol4: the relation x[1] =< a < x[2] is not satisfied. "
135 <<
"No interpolation can be calculated.\n";
136 throw runtime_error(os.str());
141 for (
Index i = 0; i < 4; ++i) {
143 for (
Index k = 0; k < 4; ++k) {
144 if ((k != i) && (fabs(
x[i] -
x[k]) > Dlimit))
145 b[i] = b[i] * ((a -
x[k]) / (
x[i] -
x[k]));
150 for (
Index i = 0; i < n_x; ++i) ya = ya + b[i] *
y[i];
166 assert(
x.nelem() > 0);
167 return x[
x.nelem() - 1];
181 assert(
x.nelem() > 0);
182 return x[
x.nelem() - 1];
211 for (
Index i = 0; i < n; i++)
x[i] =
start + (
double)i * step;
238 for (
Index i = 0; i < n - 1; i++)
x[i] =
start + (
double)i * step;
246 for (
Index i = 0; i < n - 1; i++)
x[i] =
start + (
double)i * step;
279 Numeric step = (log(stop) - a) / ((
double)n - 1);
281 for (
Index i = 1; i < n - 1; i++)
x[i] = exp(a + (
double)i * step);
302 assert(
is_size(Integrand, n, m));
304 for (
Index i = 0; i < n; ++i) {
307 for (
Index j = 0; j < m - 1; ++j) {
308 res1[i] += 0.5 *
DEG2RAD * (Integrand(i, j) + Integrand(i, j + 1)) *
313 for (
Index i = 0; i < n - 1; ++i) {
345 if ((grid_stepsize[0] > 0) && (grid_stepsize[1] > 0)) {
348 Numeric stepsize_za = grid_stepsize[0];
349 Numeric stepsize_aa = grid_stepsize[1];
351 assert(
is_size(Integrand, n, m));
355 for (
Index i = 0; i < n; ++i) {
356 temp = Integrand(i, 0);
357 for (
Index j = 1; j < m - 1; j++) {
358 temp += Integrand(i, j) * 2;
360 temp += Integrand(i, m - 1);
366 for (
Index i = 1; i < n - 1; i++) {
370 res *= 0.5 *
DEG2RAD * stepsize_za;
399 for (
Index i = 0; i < n - 1; ++i) {
457 const Index nx =
x.nelem();
459 assert(psd.
nelem() == nx);
464 for (
Index ix = 0; ix < nx; ix++) {
465 const Numeric eterm = exp(-la *
x[ix]);
466 psd[ix] = n0 * eterm;
471 os <<
"Given mu is " << mu << endl
472 <<
"Seems unreasonable. Have you mixed up the inputs?";
473 throw runtime_error(os.str());
476 for (
Index ix = 0; ix < nx; ix++) {
477 const Numeric eterm = exp(-la *
x[ix]);
479 psd[ix] = n0 * xterm * eterm;
480 psd[ix] = n0 *
pow(
x[ix], mu) * exp(-la *
x[ix]);
487 os <<
"Given mu is " << mu << endl
488 <<
"Seems unreasonable. Have you mixed up the inputs?";
489 throw runtime_error(os.str());
493 os <<
"Given gamma is " << ga << endl
494 <<
"Seems unreasonable. Have you mixed up the inputs?";
495 throw runtime_error(os.str());
497 for (
Index ix = 0; ix < nx; ix++) {
499 const Numeric eterm = exp(-la * pterm);
501 psd[ix] = n0 * xterm * eterm;
537 const bool& do_n0_jac,
538 const bool& do_mu_jac,
539 const bool& do_la_jac,
540 const bool& do_ga_jac) {
541 const Index nx =
x.nelem();
543 assert(psd.
nelem() == nx);
544 assert(jac_data.
nrows() == 4);
545 assert(jac_data.
ncols() == nx);
547 if (ga == 1 && !do_ga_jac) {
548 if (mu == 0 && !do_mu_jac) {
550 for (
Index ix = 0; ix < nx; ix++) {
551 const Numeric eterm = exp(-la *
x[ix]);
552 psd[ix] = n0 * eterm;
554 jac_data(0, ix) = eterm;
557 jac_data(2, ix) = -
x[ix] * psd[ix];
563 os <<
"Given mu is " << mu << endl
564 <<
"Seems unreasonable. Have you mixed up the inputs?";
565 throw runtime_error(os.str());
568 for (
Index ix = 0; ix < nx; ix++) {
569 const Numeric eterm = exp(-la *
x[ix]);
571 psd[ix] = n0 * xterm * eterm;
573 jac_data(0, ix) = xterm * eterm;
576 jac_data(1, ix) = log(
x[ix]) * psd[ix];
579 jac_data(2, ix) = -
x[ix] * psd[ix];
581 psd[ix] = n0 *
pow(
x[ix], mu) * exp(-la *
x[ix]);
588 os <<
"Given mu is " << mu << endl
589 <<
"Seems unreasonable. Have you mixed up the inputs?";
590 throw runtime_error(os.str());
594 os <<
"Given gamma is " << ga << endl
595 <<
"Seems unreasonable. Have you mixed up the inputs?";
596 throw runtime_error(os.str());
598 for (
Index ix = 0; ix < nx; ix++) {
600 const Numeric eterm = exp(-la * pterm);
602 psd[ix] = n0 * xterm * eterm;
604 jac_data(0, ix) = xterm * eterm;
607 jac_data(1, ix) = log(
x[ix]) * psd[ix];
610 jac_data(2, ix) = -pterm * psd[ix];
613 jac_data(3, ix) = -la * pterm * log(
x[ix]) * psd[ix];
624 Numeric f_c = tgamma(4.0) / 256.0;
625 f_c *=
pow(tgamma((alpha + 5.0) /
beta), 4 + alpha);
626 f_c /=
pow(tgamma((alpha + 4.0) /
beta), 5 + alpha);
629 f_d /= tgamma((alpha + 4.0) /
beta);
631 for (
Index i = 0; i <
x.nelem(); ++i) {
635 psd[i] * (alpha / xi -
beta * f_d *
pow(f_d * xi,
beta - 1.0));
657 if (
x > 0. && N0 > 0. && Lambda > 0. && (mu + 1) / gamma > 0.) {
659 dN = N0 *
pow(
x, mu) * exp(-Lambda *
pow(
x, gamma));
664 os <<
"At least one argument is zero or negative.\n"
665 <<
"Modified gamma distribution can not be calculated.\n"
666 <<
"x = " <<
x <<
"\n"
667 <<
"N0 = " << N0 <<
"\n"
668 <<
"lambda = " << Lambda <<
"\n"
669 <<
"mu = " << mu <<
"\n"
670 <<
"gamma = " << gamma <<
"\n";
672 throw runtime_error(os.str());
688 assert(
x.nelem() > 0);
691 for (
Index i = 0; i <
x.nelem(); i++)
x[i] /= l;
823 w[0] = (
x[1] -
x[0]) / 2.;
825 for (
Index i = 1; i < nph * 2 - 1; i++) {
826 w[i] = (
x[i + 1] -
x[i - 1]) / 2.;
828 w[
x.nelem() - 1] = (
x[
x.nelem() - 1] -
x[
x.nelem() - 2]) / 2.;
void mgd(VectorView psd, const Vector &x, const Numeric &n0, const Numeric &mu, const Numeric &la, const Numeric &ga)
Numeric fac(const Index n)
fac
Numeric LagrangeInterpol4(ConstVectorView x, ConstVectorView y, const Numeric a)
Lagrange Interpolation (internal function).
Complex w(Complex z) noexcept
The Faddeeva function.
Numeric sign(const Numeric &x)
sign
Numeric last(ConstVectorView x)
last
Vector y(Workspace &ws) noexcept
Index nrows() const
Returns the number of rows.
Numeric AngIntegrate_trapezoid_opti(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
AngIntegrate_trapezoid_opti.
This file contains the definition of Array.
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
Numeric sqrt(const Rational r)
Square root.
Index npages() const
Returns the number of pages.
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
This can be used to make arrays out of anything.
Numeric pow(const Rational base, Numeric exp)
Power of.
void flat(VectorView x, ConstMatrixView X)
flat
void unitl(Vector &x)
unitl
void reshape(Tensor3View X, ConstVectorView x)
reshape
Index ncols() const
Returns the number of columns.
Numeric mod_gamma_dist(Numeric x, Numeric N0, Numeric Lambda, Numeric mu, Numeric gamma)
Generalized Modified Gamma Distribution.
Index nelem() const
Returns the number of elements.
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)
NUMERIC Numeric
The type to use for all floating point numbers.
void delanoe_shape_with_derivative(VectorView psd, MatrixView jac_data, const Vector &x, const Numeric &alpha, const Numeric &beta)
! Shape functions for normalized PSD.
Numeric AngIntegrate_trapezoid(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid.
Vector za_grid(Workspace &ws) noexcept
Index nrows() const
Returns the number of rows.
Index integer_div(const Index &x, const Index &y)
integer_div
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
A constant view of a Matrix.
Header file for logic.cc.
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
bool is_multiple(const Index &x, const Index &y)
Checks if an integer is a multiple of another integer.
Index ncols() const
Returns the number of columns.
A constant view of a Tensor3.
void calculate_weights_linear(Vector &x, Vector &w, const Index nph)
calculate_weights_linear
Vector x(Workspace &ws) noexcept
INDEX Index
The type to use for all integer numbers and indices.
void linspace(Vector &x, const Numeric start, const Numeric stop, const Numeric step)
linspace
Vector aa_grid(Workspace &ws) noexcept
A constant view of a Vector.
This file contains the definition of String, the ARTS string class.