imate
C++/CUDA Reference
indicator.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3  * SPDX-License-Identifier: BSD-3-Clause
4  * SPDX-FileType: SOURCE
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the license found in the LICENSE.txt file in the root
8  * directory of this source tree.
9  */
10 
11 
12 // =======
13 // Headers
14 // =======
15 
16 #include "./indicator.h"
17 
18 
19 // =========
20 // Indicator
21 // =========
22 
25 
26 Indicator::Indicator(double a_, double b_)
27 {
28  this->a = a_;
29  this->b = b_;
30 }
31 
32 
33 // ==================
34 // Indicator function (float)
35 // ==================
36 
40 
41 float Indicator::function(const float lambda_) const
42 {
43  if ((lambda_ < this->a) || (lambda_ > this->b))
44  {
45  return 0.0;
46  }
47  else
48  {
49  return 1.0;
50  }
51 }
52 
53 
54 // ==================
55 // Indicator function (double)
56 // ==================
57 
61 
62 double Indicator::function(const double lambda_) const
63 {
64  if ((lambda_ < this->a) || (lambda_ > this->b))
65  {
66  return 0.0;
67  }
68  else
69  {
70  return 1.0;
71  }
72 }
73 
74 
75 // ==================
76 // Indicator function (long double)
77 // ==================
78 
82 
83 long double Indicator::function(const long double lambda_) const
84 {
85  if ((lambda_ < this->a) || (lambda_ > this->b))
86  {
87  return 0.0;
88  }
89  else
90  {
91  return 1.0;
92  }
93 }
Indicator(double a_, double b_)
Sets the default parameters a and c.
Definition: indicator.cpp:26
virtual float function(const float lambda_) const
Definition: indicator.cpp:41
double a
Definition: indicator.h:48
double b
Definition: indicator.h:49