ARTS 2.5.4 (git: 31ce4f0e)
math_funcs.h
Go to the documentation of this file.
1/* Copyright (C) 2002-2012
2 Patrick Eriksson <Patrick.Eriksson@chalmers.se>
3 Stefan Buehler <sbuehler@ltu.se>
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
19
20/*****************************************************************************
21 *** File description
22 *****************************************************************************/
23
32#ifndef math_funcs_h
33#define math_funcs_h
34
35#include "matpack.h"
36#include "matpackI.h"
37#include "matpackIII.h"
38
39Numeric fac(const Index n);
40
41Index integer_div(const Index& x, const Index& y);
42
44
45Index last(const ArrayOfIndex& x);
46
47void linspace(Vector& x,
48 const Numeric start,
49 const Numeric stop,
50 const Numeric step);
51
52void nlinspace(Vector& x,
53 const Numeric start,
54 const Numeric stop,
55 const Index n);
56
58 const Numeric start,
59 const Numeric stop,
60 const Index n);
61
62void nlogspace(Vector& x,
63 const Numeric start,
64 const Numeric stop,
65 const Index n);
66
69
71 ConstVectorView za_grid,
72 ConstVectorView aa_grid);
73
75 ConstVectorView za_grid);
76
78 ConstVectorView za_grid,
79 ConstVectorView aa_grid,
80 ConstVectorView grid_stepsize);
81
82Numeric sign(const Numeric& x);
83
84void mgd(VectorView psd,
85 const Vector& x,
86 const Numeric& n0,
87 const Numeric& mu,
88 const Numeric& la,
89 const Numeric& ga);
90
92 MatrixView jac_data,
93 const Vector& x,
94 const Numeric& n0,
95 const Numeric& mu,
96 const Numeric& la,
97 const Numeric& ga,
98 const bool& do_n0_jac,
99 const bool& do_mu_jac,
100 const bool& do_la_jac,
101 const bool& do_ga_jac);
102
119 MatrixView jac_data,
120 const Vector& x,
121 const Numeric& alpha,
122 const Numeric& beta);
123
125 Numeric x, Numeric N0, Numeric Lambda, Numeric mu, Numeric gamma);
126
127void unitl(Vector& x);
128
131
134
135void calculate_weights_linear(Vector& x, Vector& w, const Index nph);
136
143
144
146template <typename MatpackType>
147constexpr bool any_negative(const MatpackType& var) noexcept {
148 if (var.empty()) return false;
149 if (min(var) < 0) return true;
150 return false;
151}
152
158constexpr Index pow_negative_one(Index x) noexcept { return (x % 2) ? -1 : 1; }
159
160#endif // math_funcs_h
A constant view of a Matrix.
Definition: matpackI.h:1043
A constant view of a Tensor3.
Definition: matpackIII.h:130
A constant view of a Vector.
Definition: matpackI.h:512
bool empty() const noexcept
Returns true if variable size is zero.
Definition: matpackI.h:525
The MatrixView class.
Definition: matpackI.h:1164
The Tensor3View class.
Definition: matpackIII.h:246
The VectorView class.
Definition: matpackI.h:663
The Vector class.
Definition: matpackI.h:899
#define beta
#define min(a, b)
void linspace(Vector &x, const Numeric start, const Numeric stop, const Numeric step)
linspace
Definition: math_funcs.cc:200
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
Definition: math_funcs.cc:227
void unitl(Vector &x)
unitl
Definition: math_funcs.cc:686
void reshape(MatrixView X, ConstVectorView x)
reshape
Definition: math_funcs.cc:788
Numeric fac(const Index n)
fac
Definition: math_funcs.cc:65
constexpr Index pow_negative_one(Index x) noexcept
Computes std::pow(-1, x) without std::pow.
Definition: math_funcs.h:158
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
Definition: math_funcs.cc:263
constexpr bool any_negative(const MatpackType &var) noexcept
Checks for negative values.
Definition: math_funcs.h:147
void mgd(VectorView psd, const Vector &x, const Numeric &n0, const Numeric &mu, const Numeric &la, const Numeric &ga)
Definition: math_funcs.cc:470
void delanoe_shape_with_derivative(VectorView psd, MatrixView jac_data, const Vector &x, const Numeric &alpha, const Numeric &beta)
! Shape functions for normalized PSD.
Definition: math_funcs.cc:620
void calculate_weights_linear(Vector &x, Vector &w, const Index nph)
calculate_weights_linear
Definition: math_funcs.cc:812
Numeric trapz(ConstVectorView x, ConstVectorView y)
trapz
Definition: math_funcs.cc:293
Numeric mod_gamma_dist(Numeric x, Numeric N0, Numeric Lambda, Numeric mu, Numeric gamma)
Generalized Modified Gamma Distribution.
Definition: math_funcs.cc:654
void flat(VectorView x, ConstMatrixView X)
flat
Definition: math_funcs.cc:706
Numeric last(ConstVectorView x)
last
Definition: math_funcs.cc:161
Index integer_div(const Index &x, const Index &y)
integer_div
Definition: math_funcs.cc:89
Numeric AngIntegrate_trapezoid(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid.
Definition: math_funcs.cc:315
Numeric sign(const Numeric &x)
sign
Definition: math_funcs.cc:442
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)
Definition: math_funcs.cc:540
void calculate_int_weights_arbitrary_grid(Vector &w, const Vector &x)
Calculates trapezoidal integration weights for arbitray grid.
Definition: math_funcs.cc:830
Numeric AngIntegrate_trapezoid_opti(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
AngIntegrate_trapezoid_opti.
Definition: math_funcs.cc:359
Implementation of Matrix, Vector, and such stuff.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
constexpr Numeric alpha
Fine structure constant convenience name [-].
VectorView var(VectorView var, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the variance of the ranged ys.
Definition: raw.cc:159
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:80
#define w