Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ahField.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
44# ifndef AHFIELD_H
45# define AHFIELD_H
46
47# include <iostream>
48# include <limits>
49# include <ahFunction.H>
50
51namespace Aleph {
52
53 template <typename Dtype>
54class Field
55{
57
58public:
59
60 static const Dtype Zero = 0;
61
62 static const Dtype Min;
63
64 static const Dtype Max;
65
67
68 typedef Dtype dtype;
69
70 Dtype & get_value() { return num; }
71
72 const Dtype & get_value() const { return num; }
73
74 Field(Dtype && d = 0.0) : num(d)
75 {
76 // empty
77 }
78
79 Field(const Dtype & d) : num(d)
80 {
81 // empty
82 }
83
84 Field(Dtype & d) : num(d)
85 {
86 // empty
87 }
88
89 Field & operator = (const Dtype & d)
90 {
91 num = d;
92 return *this;
93 }
94
96 {
97 num = d;
98 return *this;
99 }
100
101 Field & operator = (const Dtype && d)
102 {
103 num = d;
104 return *this;
105 }
106
108 {
109 return Field(num + rhs.num);
110 }
111
113 {
114 num += rhs.num;
115 return *this;
116 }
117};
118
119
120 template <class T>
121std::ostream & operator << (std::ostream & osObject, const Field<T> & rightOp)
122{
123 osObject << rightOp.get_value();
124
125 return osObject;
126}
127
128 template <typename Dtype>
129const Dtype Field<Dtype>::Min = std::numeric_limits<Dtype>::min();
130
131
132 template <typename Dtype>
133const Dtype Field<Dtype>::Max = std::numeric_limits<Dtype>::max();
134
135
137
139
141
143
145
146
147} // end namespace Aleph
148
149# endif // AHFIELD_H
Standard functor implementations and comparison objects.
const Dtype & get_value() const
Definition ahField.H:72
static const Dtype Zero
Definition ahField.H:60
Field(Dtype &&d=0.0)
Definition ahField.H:74
Field & operator+=(const Field &rhs)
Definition ahField.H:112
Field(Dtype &d)
Definition ahField.H:84
Field(const Dtype &d)
Definition ahField.H:79
static const Dtype Max
Definition ahField.H:64
Dtype dtype
Definition ahField.H:68
Dtype & get_value()
Definition ahField.H:70
Dtype num
Definition ahField.H:56
static const Dtype Min
Definition ahField.H:62
Field operator+(const Field &rhs)
Definition ahField.H:107
Field & operator=(const Dtype &d)
Definition ahField.H:89
Dtype Distance_Type
Definition ahField.H:66
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Field< float > Float
Definition ahField.H:140
Field< long double > Ldouble
Definition ahField.H:144
Field< int > Integer
Definition ahField.H:136
Field< short > Short
Definition ahField.H:138
Field< double > Double
Definition ahField.H:142
std::ostream & operator<<(std::ostream &osObject, const Field< T > &rightOp)
Definition ahField.H:121
DynList< T > maps(const C &c, Op op)
Classic map operation.