TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
mapped_functions.hxx
Go to the documentation of this file.
1
6#pragma once
7
8#include "./concepts.hpp"
9#include "./map.hpp"
11#include "./traits.hpp"
12
13#include <cmath>
14#include <complex>
15#include <utility>
16
17/*
18 File is generated by vim.
19 To regenerate the file,
20 1- load the vim function by (or add this to your .vim ?)
21 :source vimexpand.vim
22 2- call it
23 :call VimExpandSimple()
24
25
26 It is better than C macro, it gives a cleaner code
27 (for error messages, no preproc, doc generation : otherwise no doc string ...)
28
29 ---- normal mapping -------
30
31 VIMEXPAND abs imag floor
37 template <Array A>
38 auto @(A &&a) {
39 return nda::map(
40 [](auto const &x) {
41 using std::@;
42 return @(x);
43 })(std::forward<A>(a));
44 }
45
46 --------- same, no using std::-------
47
48 VIMEXPAND real abs2 isnan
54 template <Array A>
55 auto @(A &&a) {
56 return nda::map(
57 [](auto const &x) {return @(x); })(std::forward<A>(a));
58 }
59
60 --------- mapping with matrix excluded -------
61
62 VIMEXPAND exp cos sin tan cosh sinh tanh acos asin atan log sqrt
68 template <Array A>
69 auto @(A &&a) requires(get_algebra<A> != 'M') {
70 return nda::map(
71 [](auto const &x) {
72 using std::@;
73 return @(x);
74 })(std::forward<A>(a));
75 }
76
77*/
78
79namespace nda {
80
86 // --- VIMEXPAND_START --DO NOT EDIT BELOW --
87
88
94 template <Array A>
95 auto abs(A &&a) {
96 return nda::map(
97 [](auto const &x) {
98 using std::abs;
99 return abs(x);
100 })(std::forward<A>(a));
101 }
102
108 template <Array A>
109 auto imag(A &&a) {
110 return nda::map(
111 [](auto const &x) {
112 using std::imag;
113 return imag(x);
114 })(std::forward<A>(a));
115 }
116
122 template <Array A>
123 auto floor(A &&a) {
124 return nda::map(
125 [](auto const &x) {
126 using std::floor;
127 return floor(x);
128 })(std::forward<A>(a));
129 }
130
136 template <Array A>
137 auto real(A &&a) {
138 return nda::map(
139 [](auto const &x) {return real(x); })(std::forward<A>(a));
140 }
141
147 template <Array A>
148 auto abs2(A &&a) {
149 return nda::map(
150 [](auto const &x) {return abs2(x); })(std::forward<A>(a));
151 }
152
158 template <Array A>
159 auto isnan(A &&a) {
160 return nda::map(
161 [](auto const &x) {return isnan(x); })(std::forward<A>(a));
162 }
163
169 template <Array A>
170 auto exp(A &&a) requires(get_algebra<A> != 'M') {
171 return nda::map(
172 [](auto const &x) {
173 using std::exp;
174 return exp(x);
175 })(std::forward<A>(a));
176 }
177
183 template <Array A>
184 auto cos(A &&a) requires(get_algebra<A> != 'M') {
185 return nda::map(
186 [](auto const &x) {
187 using std::cos;
188 return cos(x);
189 })(std::forward<A>(a));
190 }
191
197 template <Array A>
198 auto sin(A &&a) requires(get_algebra<A> != 'M') {
199 return nda::map(
200 [](auto const &x) {
201 using std::sin;
202 return sin(x);
203 })(std::forward<A>(a));
204 }
205
211 template <Array A>
212 auto tan(A &&a) requires(get_algebra<A> != 'M') {
213 return nda::map(
214 [](auto const &x) {
215 using std::tan;
216 return tan(x);
217 })(std::forward<A>(a));
218 }
219
225 template <Array A>
226 auto cosh(A &&a) requires(get_algebra<A> != 'M') {
227 return nda::map(
228 [](auto const &x) {
229 using std::cosh;
230 return cosh(x);
231 })(std::forward<A>(a));
232 }
233
239 template <Array A>
240 auto sinh(A &&a) requires(get_algebra<A> != 'M') {
241 return nda::map(
242 [](auto const &x) {
243 using std::sinh;
244 return sinh(x);
245 })(std::forward<A>(a));
246 }
247
253 template <Array A>
254 auto tanh(A &&a) requires(get_algebra<A> != 'M') {
255 return nda::map(
256 [](auto const &x) {
257 using std::tanh;
258 return tanh(x);
259 })(std::forward<A>(a));
260 }
261
267 template <Array A>
268 auto acos(A &&a) requires(get_algebra<A> != 'M') {
269 return nda::map(
270 [](auto const &x) {
271 using std::acos;
272 return acos(x);
273 })(std::forward<A>(a));
274 }
275
281 template <Array A>
282 auto asin(A &&a) requires(get_algebra<A> != 'M') {
283 return nda::map(
284 [](auto const &x) {
285 using std::asin;
286 return asin(x);
287 })(std::forward<A>(a));
288 }
289
295 template <Array A>
296 auto atan(A &&a) requires(get_algebra<A> != 'M') {
297 return nda::map(
298 [](auto const &x) {
299 using std::atan;
300 return atan(x);
301 })(std::forward<A>(a));
302 }
303
309 template <Array A>
310 auto log(A &&a) requires(get_algebra<A> != 'M') {
311 return nda::map(
312 [](auto const &x) {
313 using std::log;
314 return log(x);
315 })(std::forward<A>(a));
316 }
317
323 template <Array A>
324 auto sqrt(A &&a) requires(get_algebra<A> != 'M') {
325 return nda::map(
326 [](auto const &x) {
327 using std::sqrt;
328 return sqrt(x);
329 })(std::forward<A>(a));
330 }
331
333}
Provides concepts for the nda library.
auto cos(A &&a)
Lazy, coefficient-wise cos function for non-matrix nda::Array types.
auto sinh(A &&a)
Lazy, coefficient-wise sinh function for non-matrix nda::Array types.
auto tanh(A &&a)
Lazy, coefficient-wise tanh function for non-matrix nda::Array types.
auto sin(A &&a)
Lazy, coefficient-wise sin function for non-matrix nda::Array types.
auto log(A &&a)
Lazy, coefficient-wise log function for non-matrix nda::Array types.
bool isnan(std::complex< double > const &z)
Check if a std::complex<double> is NaN.
auto floor(A &&a)
Lazy, coefficient-wise floor function for nda::Array types.
auto abs(A &&a)
Lazy, coefficient-wise abs function for nda::Array types.
double abs2(double x)
Get the squared absolute value of a double.
auto tan(A &&a)
Lazy, coefficient-wise tan function for non-matrix nda::Array types.
auto atan(A &&a)
Lazy, coefficient-wise atan function for non-matrix nda::Array types.
auto sqrt(A &&a)
Lazy, coefficient-wise sqrt function for non-matrix nda::Array types.
auto real(T t)
Get the real part of a scalar.
auto imag(A &&a)
Lazy, coefficient-wise imag function for nda::Array types.
auto cosh(A &&a)
Lazy, coefficient-wise cosh function for non-matrix nda::Array types.
auto asin(A &&a)
Lazy, coefficient-wise asin function for non-matrix nda::Array types.
auto acos(A &&a)
Lazy, coefficient-wise acos function for non-matrix nda::Array types.
auto exp(A &&a)
Lazy, coefficient-wise exp function for non-matrix nda::Array types.
mapped< F > map(F f)
Create a lazy function call expression on arrays/views.
Definition map.hpp:199
Provides lazy function calls on arrays/views.
Provides some custom implementations of standard mathematical functions used for lazy,...
Provides type traits for the nda library.