pops-core  0.9
PoPS (Pest or Pathogen Spread) Model Core C++ library
kernel_types.hpp
Go to the documentation of this file.
1 /*
2  * PoPS model - disperal kernel types
3  *
4  * Copyright (C) 2015-2020 by the authors.
5  *
6  * Authors: Vaclav Petras (wenzeslaus gmail com)
7  * Chris Jones (cjones1688 gmail com)
8  * Anna Petrasova (kratochanna gmail com)
9  * Zexi Chen (zchen22 ncsu edu)
10  *
11  * The code contained herein is licensed under the GNU General Public
12  * License. You may obtain a copy of the GNU General Public License
13  * Version 2 or later at the following locations:
14  *
15  * http://www.opensource.org/licenses/gpl-license.html
16  * http://www.gnu.org/copyleft/gpl.html
17  */
18 
36 #ifndef POPS_KERNEL_TYPES_HPP
37 #define POPS_KERNEL_TYPES_HPP
38 
39 #include <string>
40 #include <stdexcept>
41 
42 namespace pops {
43 
54 {
55  Cauchy,
56  Exponential,
57  Uniform,
59  PowerLaw,
61  Gamma,
63  Weibull,
64  Normal,
65  LogNormal,
66  Logistic,
67  Network,
68  None,
69 };
70 
76 inline DispersalKernelType kernel_type_from_string(const std::string& text)
77 {
78  if (text == "cauchy" || text == "Cauchy")
80  else if (text == "exponential" || text == "Exponential")
82  else if (text == "uniform" || text == "Uniform")
84  else if (
85  text == "deterministic neighbor" || text == "deterministic-neighbor"
86  || text == "Deterministic-neighbor" || text == "Deterministic-Neighbor"
87  || text == "Deterministic neighbor" || text == "Deterministic Neighbor")
89  else if (
90  text == "power law" || text == "power-law" || text == "Power-law"
91  || text == "Power-Law" || text == "Power Law" || text == "Power law")
93  else if (
94  text == "hyperbolic secant" || text == "hyperbolic-secant"
95  || text == "Hyperbolic-secant" || text == "Hyperbolic-Secant"
96  || text == "Hyperbolic secant" || text == "Hyperbolic Secant")
98  else if (text == "gamma" || text == "Gamma")
100  else if (
101  text == "exponential power" || text == "exponential-power"
102  || text == "Exponential-power" || text == "Exponential-Power"
103  || text == "Exponential power" || text == "Exponential Power")
105  else if (text == "weibull" || text == "Weibull")
107  else if (text == "normal" || text == "Normal")
109  else if (
110  text == "log normal" || text == "log-normal" || text == "Log-normal"
111  || text == "Log-Normal" || text == "Log normal" || text == "Log Normal")
113  else if (text == "logistic" || text == "Logistic")
115  else if (text == "network" || text == "Network")
117  else if (text == "none" || text == "None" || text == "NONE" || text.empty())
119  else
120  throw std::invalid_argument(
121  "kernel_type_from_string: Invalid"
122  " value '"
123  + text + "' provided");
124 }
125 
129 {
130  // call the string version
131  return kernel_type_from_string(text ? std::string(text) : std::string());
132 }
133 
134 } // namespace pops
135 
136 #endif // POPS_KERNEL_TYPES_HPP
pops::DispersalKernelType::HyperbolicSecant
@ HyperbolicSecant
Hyperbolic secant dispersal kernel.
pops::DispersalKernelType::Gamma
@ Gamma
Gamma dispersal kernel.
pops::kernel_type_from_string
DispersalKernelType kernel_type_from_string(const std::string &text)
Get a corresponding enum value for a string which is a kernel name.
Definition: kernel_types.hpp:76
pops::DispersalKernelType::Logistic
@ Logistic
Logistic dispersal kernel.
pops::DispersalKernelType::Exponential
@ Exponential
Exponential dispersal kernel.
pops::DispersalKernelType::Uniform
@ Uniform
Random uniform dispersal kernel.
pops::DispersalKernelType::Weibull
@ Weibull
Weibull dispersal kernel.
pops::DispersalKernelType::ExponentialPower
@ ExponentialPower
Exponential power dispersal kernel.
pops::DispersalKernelType::Network
@ Network
Network spread.
pops::DispersalKernelType::DeterministicNeighbor
@ DeterministicNeighbor
Deterministic immediate neighbor dispersal kernel.
pops::DispersalKernelType::Normal
@ Normal
Normal dispersal kernel.
pops::DispersalKernelType
DispersalKernelType
Type of dispersal kernel.
Definition: kernel_types.hpp:53
pops::DispersalKernelType::Cauchy
@ Cauchy
Cauchy dispersal kernel.
pops::DispersalKernelType::PowerLaw
@ PowerLaw
Power law dispersal kernel.
pops
Definition: cauchy_kernel.hpp:25
pops::DispersalKernelType::LogNormal
@ LogNormal
Log-normal dispersal kernel.
pops::DispersalKernelType::None
@ None
No dispersal kernel (no spread)