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
7#pragma once
8
9#include "./concepts.hpp"
10#include "./map.hpp"
12#include "./traits.hpp"
13
14#include <cmath>
15#include <complex>
16#include <utility>
17
18/*
19 File is generated by vim.
20 To regenerate the file,
21 1- load the vim function by (or add this to your .vim ?)
22 :source vimexpand.vim
23 2- call it
24 :call VimExpandSimple()
25
26
27 It is better than C macro, it gives a cleaner code
28 (for error messages, no preproc, doc generation : otherwise no doc string ...)
29
30 ---- normal mapping -------
31
32 VIMEXPAND abs imag floor
38 template <ArrayOrScalar A>
39 auto @(A &&a) {
40 return nda::map(
41 [](auto const &x) {
42 using std::@;
43 return @(x);
44 })(std::forward<A>(a));
45 }
46
47 --------- same, no using std::-------
48
49 VIMEXPAND real abs2 isnan
55 template <ArrayOrScalar A>
56 auto @(A &&a) {
57 return nda::map(
58 [](auto const &x) {return detail::@(x); })(std::forward<A>(a));
59 }
60
61 --------- mapping with matrix excluded -------
62
63 VIMEXPAND exp cos sin tan cosh sinh tanh acos asin atan log sqrt
69 template <ArrayOrScalar A>
70 auto @(A &&a) requires(get_algebra<A> != 'M') {
71 return nda::map(
72 [](auto const &x) {
73 using std::@;
74 return @(x);
75 })(std::forward<A>(a));
76 }
77
78*/
79
80namespace nda {
81
87 // --- VIMEXPAND_START --DO NOT EDIT BELOW --
88
89
95 template <ArrayOrScalar A>
96 auto abs(A &&a) {
97 return nda::map(
98 [](auto const &x) {
99 using std::abs;
100 return abs(x);
101 })(std::forward<A>(a));
102 }
103
109 template <ArrayOrScalar A>
110 auto imag(A &&a) {
111 return nda::map(
112 [](auto const &x) {
113 using std::imag;
114 return imag(x);
115 })(std::forward<A>(a));
116 }
117
123 template <ArrayOrScalar A>
124 auto floor(A &&a) {
125 return nda::map(
126 [](auto const &x) {
127 using std::floor;
128 return floor(x);
129 })(std::forward<A>(a));
130 }
131
137 template <ArrayOrScalar A>
138 auto real(A &&a) {
139 return nda::map(
140 [](auto const &x) {return detail::real(x); })(std::forward<A>(a));
141 }
142
148 template <ArrayOrScalar A>
149 auto abs2(A &&a) {
150 return nda::map(
151 [](auto const &x) {return detail::abs2(x); })(std::forward<A>(a));
152 }
153
159 template <ArrayOrScalar A>
160 auto isnan(A &&a) {
161 return nda::map(
162 [](auto const &x) {return detail::isnan(x); })(std::forward<A>(a));
163 }
164
170 template <ArrayOrScalar A>
171 auto exp(A &&a) requires(get_algebra<A> != 'M') {
172 return nda::map(
173 [](auto const &x) {
174 using std::exp;
175 return exp(x);
176 })(std::forward<A>(a));
177 }
178
184 template <ArrayOrScalar A>
185 auto cos(A &&a) requires(get_algebra<A> != 'M') {
186 return nda::map(
187 [](auto const &x) {
188 using std::cos;
189 return cos(x);
190 })(std::forward<A>(a));
191 }
192
198 template <ArrayOrScalar A>
199 auto sin(A &&a) requires(get_algebra<A> != 'M') {
200 return nda::map(
201 [](auto const &x) {
202 using std::sin;
203 return sin(x);
204 })(std::forward<A>(a));
205 }
206
212 template <ArrayOrScalar A>
213 auto tan(A &&a) requires(get_algebra<A> != 'M') {
214 return nda::map(
215 [](auto const &x) {
216 using std::tan;
217 return tan(x);
218 })(std::forward<A>(a));
219 }
220
226 template <ArrayOrScalar A>
227 auto cosh(A &&a) requires(get_algebra<A> != 'M') {
228 return nda::map(
229 [](auto const &x) {
230 using std::cosh;
231 return cosh(x);
232 })(std::forward<A>(a));
233 }
234
240 template <ArrayOrScalar A>
241 auto sinh(A &&a) requires(get_algebra<A> != 'M') {
242 return nda::map(
243 [](auto const &x) {
244 using std::sinh;
245 return sinh(x);
246 })(std::forward<A>(a));
247 }
248
254 template <ArrayOrScalar A>
255 auto tanh(A &&a) requires(get_algebra<A> != 'M') {
256 return nda::map(
257 [](auto const &x) {
258 using std::tanh;
259 return tanh(x);
260 })(std::forward<A>(a));
261 }
262
268 template <ArrayOrScalar A>
269 auto acos(A &&a) requires(get_algebra<A> != 'M') {
270 return nda::map(
271 [](auto const &x) {
272 using std::acos;
273 return acos(x);
274 })(std::forward<A>(a));
275 }
276
282 template <ArrayOrScalar A>
283 auto asin(A &&a) requires(get_algebra<A> != 'M') {
284 return nda::map(
285 [](auto const &x) {
286 using std::asin;
287 return asin(x);
288 })(std::forward<A>(a));
289 }
290
296 template <ArrayOrScalar A>
297 auto atan(A &&a) requires(get_algebra<A> != 'M') {
298 return nda::map(
299 [](auto const &x) {
300 using std::atan;
301 return atan(x);
302 })(std::forward<A>(a));
303 }
304
310 template <ArrayOrScalar A>
311 auto log(A &&a) requires(get_algebra<A> != 'M') {
312 return nda::map(
313 [](auto const &x) {
314 using std::log;
315 return log(x);
316 })(std::forward<A>(a));
317 }
318
324 template <ArrayOrScalar A>
325 auto sqrt(A &&a) requires(get_algebra<A> != 'M') {
326 return nda::map(
327 [](auto const &x) {
328 using std::sqrt;
329 return sqrt(x);
330 })(std::forward<A>(a));
331 }
332
335}
Provides concepts for the nda library.
auto cos(A &&a)
Function cos for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types)...
auto sinh(A &&a)
Function sinh for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto tanh(A &&a)
Function tanh for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto sin(A &&a)
Function sin for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types)...
auto log(A &&a)
Function log for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types)...
auto floor(A &&a)
Function floor for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto abs(A &&a)
Function abs for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto tan(A &&a)
Function tan for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types)...
auto atan(A &&a)
Function atan for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto real(A &&a)
Function real for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto sqrt(A &&a)
Function sqrt for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto imag(A &&a)
Function imag for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto isnan(A &&a)
Function isnan for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto cosh(A &&a)
Function cosh for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto abs2(A &&a)
Function abs2 for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto asin(A &&a)
Function asin for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto acos(A &&a)
Function acos for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
auto exp(A &&a)
Function exp for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types)...
mapped< F > map(F f)
Create a lazy function call expression on arrays/views.
Definition map.hpp:213
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.