File: xmath.rst

package info (click to toggle)
xtensor 0.25.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,476 kB
  • sloc: cpp: 65,302; makefile: 202; python: 171; javascript: 8
file content (385 lines) | stat: -rw-r--r-- 22,382 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
.. Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht

   Distributed under the terms of the BSD 3-Clause License.

   The full license is in the file LICENSE, distributed with this software.

.. raw:: html

   <style>
   .rst-content table.docutils {
       width: 100%;
       table-layout: fixed;
   }

   table.docutils .line-block {
       margin-left: 0;
       margin-bottom: 0;
   }

   table.docutils code.literal {
       color: initial;
   }

   code.docutils {
       background: initial;
   }
   </style>

Mathematical functions
======================

.. toctree::

   operators

.. table::
   :widths: 30 70

   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator+`     | identity                                 |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator-`     | opposite                                 |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator+`     | addition                                 |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator-`     | substraction                             |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator*`     | multiplication                           |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator/`     | division                                 |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator||`    | logical or                               |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator&&`    | logical and                              |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator!`     | logical not                              |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::where`         | ternary selection                        |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::any`           | return true if any value is truthy       |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::all`           | return true if all the values are truthy |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator\<`    | element-wise lesser than                 |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator\<=`   | element-wise less or equal               |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator>`     | element-wise greater than                |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator>=`    | element-wise greater or equal            |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator==`    | expression equality                      |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator!=`    | expression inequality                    |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::equal`         | element-wise equality                    |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::not_equal`     | element-wise inequality                  |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::less`          | element-wise lesser than                 |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::less_equal`    | element-wise less or equal               |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::greater`       | element-wise greater than                |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::greater_equal` | element-wise greater or equal            |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::cast`          | element-wise ``static_cast``             |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator&`     | bitwise and                              |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator|`     | bitwise or                               |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator^`     | bitwise xor                              |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator~`     | bitwise not                              |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::left_shift`    | bitwise shift left                       |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::right_shift`   | bitwise shift right                      |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator\<\<`  | bitwise shift left                       |
   +-------------------------------+------------------------------------------+
   | :cpp:func:`xt::operator\>\>`  | bitwise shift right                      |
   +-------------------------------+------------------------------------------+

.. toctree::

   index_related

.. table::
   :widths: 30 70

   +------------------------------+----------------------+
   | :cpp:func:`xt::where`        | indices selection    |
   +------------------------------+----------------------+
   | :cpp:func:`xt::nonzero`      | indices selection    |
   +------------------------------+----------------------+
   | :cpp:func:`xt::argwhere`     | indices selection    |
   +------------------------------+----------------------+
   | :cpp:func:`xt::from_indices` | biulder from indices |
   +------------------------------+----------------------+

.. toctree::

   basic_functions

.. table::
   :widths: 30 70

   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::abs`       | absolute value                                     |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::fabs`      | absolute value                                     |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::fmod`      | remainder of the floating point division operation |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::remainder` | signed remainder of the division operation         |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::fma`       | fused multiply-add operation                       |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::minimum`   | element-wise minimum                               |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::maximum`   | element-wise maximum                               |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::fmin`      | element-wise minimum for floating point values     |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::fmax`      | element-wise maximum for floating point values     |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::fdim`      | element-wise positive difference                   |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::clip`      | element-wise clipping operation                    |
   +---------------------------+----------------------------------------------------+
   | :cpp:func:`xt::sign`      | element-wise indication of the sign                |
   +---------------------------+----------------------------------------------------+

.. toctree::

   exponential_functions

.. table::
   :widths: 30 70

   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::exp`   | natural exponential function            |
   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::exp2`  | base 2 exponential function             |
   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::expm1` | natural exponential function, minus one |
   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::log`   | natural logarithm function              |
   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::log2`  | base 2 logarithm function               |
   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::log10` | base 10 logarithm function              |
   +-----------------------+-----------------------------------------+
   | :cpp:func:`xt::log1p` | natural logarithm of one plus function  |
   +-----------------------+-----------------------------------------+

.. toctree::

   power_functions

.. table::
   :widths: 30 70

   +-----------------------+----------------------+
   | :cpp:func:`xt::pow`   | power function       |
   +-----------------------+----------------------+
   | :cpp:func:`xt::sqrt`  | square root function |
   +-----------------------+----------------------+
   | :cpp:func:`xt::cbrt`  | cubic root function  |
   +-----------------------+----------------------+
   | :cpp:func:`xt::hypot` | hypotenuse function  |
   +-----------------------+----------------------+

.. toctree::

   trigonometric_functions

.. table::
   :widths: 30 70

   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::sin`   | sine function                               |
   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::cos`   | cosine function                             |
   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::tan`   | tangent function                            |
   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::asin`  | arc sine function                           |
   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::acos`  | arc cosine function                         |
   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::atan`  | arc tangent function                        |
   +-----------------------+---------------------------------------------+
   | :cpp:func:`xt::atan2` | arc tangent function, determining quadrants |
   +-----------------------+---------------------------------------------+

.. toctree::

   hyperbolic_functions

.. table::
   :widths: 30 70

   +-----------------------+-------------------------------------+
   | :cpp:func:`xt::sinh`  | hyperbolic sine function            |
   +-----------------------+-------------------------------------+
   | :cpp:func:`xt::cosh`  | hyperbolic cosine function          |
   +-----------------------+-------------------------------------+
   | :cpp:func:`xt::tanh`  | hyperbolic tangent function         |
   +-----------------------+-------------------------------------+
   | :cpp:func:`xt::asinh` | inverse hyperbolic sine function    |
   +-----------------------+-------------------------------------+
   | :cpp:func:`xt::acosh` | inverse hyperbolic cosine function  |
   +-----------------------+-------------------------------------+
   | :cpp:func:`xt::atanh` | inverse hyperbolic tangent function |
   +-----------------------+-------------------------------------+

.. toctree::

   error_functions

.. table::
   :widths: 30 70

   +------------------------+-----------------------------------------+
   | :cpp:func:`xt::erf`    | error function                          |
   +------------------------+-----------------------------------------+
   | :cpp:func:`xt::erfc`   | complementary error function            |
   +------------------------+-----------------------------------------+
   | :cpp:func:`xt::tgamma` | gamma function                          |
   +------------------------+-----------------------------------------+
   | :cpp:func:`xt::lgamma` | natural logarithm of the gamma function |
   +------------------------+-----------------------------------------+

.. toctree::

   nearint_operations

.. table::
   :widths: 30 70

   +---------------------------+----------------------------------------------+
   | :cpp:func:`xt::ceil`      | nearest integers not less                    |
   +---------------------------+----------------------------------------------+
   | :cpp:func:`xt::floor`     | nearest integers not greater                 |
   +---------------------------+----------------------------------------------+
   | :cpp:func:`xt::trunc`     | nearest integers not greater in magnitude    |
   +---------------------------+----------------------------------------------+
   | :cpp:func:`xt::round`     | nearest integers, rounding away from zero    |
   +---------------------------+----------------------------------------------+
   | :cpp:func:`xt::nearbyint` | nearest integers using current rounding mode |
   +---------------------------+----------------------------------------------+
   | :cpp:func:`xt::rint`      | nearest integers using current rounding mode |
   +---------------------------+----------------------------------------------+

.. toctree::

   classif_functions

.. table::
   :widths: 30 70

   +--------------------------+----------------------------------+
   | :cpp:func:`xt::isfinite` | checks for finite values         |
   +--------------------------+----------------------------------+
   | :cpp:func:`xt::isinf`    | checks for infinite values       |
   +--------------------------+----------------------------------+
   | :cpp:func:`xt::isnan`    | checks for NaN values            |
   +--------------------------+----------------------------------+
   | :cpp:func:`xt::isclose`  | element-wise closeness detection |
   +--------------------------+----------------------------------+
   | :cpp:func:`xt::allclose` | closeness reduction              |
   +--------------------------+----------------------------------+

.. toctree::

   reducing_functions

.. table::
   :widths: 30 70

   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::sum`               | sum of elements over given axes                                     |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::prod`              | product of elements over given axes                                 |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::mean`              | mean of elements over given axes                                    |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::average`           | weighted average along the specified axis                           |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::variance`          | variance of elements over given axes                                |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::stddev`            | standard deviation of elements over given axes                      |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::diff`              | Calculate the n-th discrete difference along the given axis         |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::amax`              | amax of elements over given axes                                    |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::amin`              | amin of elements over given axes                                    |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::trapz`             | Integrate along the given axis using the composite trapezoidal rule |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_l0`           | L0 pseudo-norm over given axes                                      |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_l1`           | L1 norm over given axes                                             |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_sq`           | Squared L2 norm over given axes                                     |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_l2`           | L2 norm over given axes                                             |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_linf`         | Infinity norm over given axes                                       |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_lp_to_p`      | p_th power of Lp norm over given axes                               |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_lp`           | Lp norm over given axes                                             |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_induced_l1`   | Induced L1 norm of a matrix                                         |
   +-----------------------------------+---------------------------------------------------------------------+
   | :cpp:func:`xt::norm_induced_linf` | Induced L-infinity norm of a matrix                                 |
   +-----------------------------------+---------------------------------------------------------------------+

.. toctree::

   accumulating_functions

.. table::
   :widths: 30 70

   +-------------------------+------------------------------------------------+
   | :cpp:func:`xt::cumsum`  | Cumulative sum of elements over a given axis   |
   +-------------------------+------------------------------------------------+
   | :cpp:func:`xt::cumprod` | Cumulative product of elements over given axes |
   +-------------------------+------------------------------------------------+

.. toctree::

   nan_functions

.. table::
   :widths: 30 70

   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nan_to_num` | Convert NaN and +/- inf to finite numbers                            |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nanmin`     | Min of elements over a given axis, ignoring NaNs                     |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nanmax`     | Max of elements over a given axis, ignoring NaNs                     |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nansum`     | Sum of elements over a given axis, replacing NaN with 0              |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nanprod`    | Product of elements over given axes, replacing NaN with 1            |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nancumsum`  | Cumulative sum of elements over a given axis, replacing NaN with 0   |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nancumprod` | Cumulative product of elements over given axes, replacing NaN with 1 |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nanmean`    | Mean of elements over given axes, ignoring NaNs                      |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nanvar`     | Variance of elements over given axes, ignoring NaNs                  |
   +----------------------------+----------------------------------------------------------------------+
   | :cpp:func:`xt::nanstd`     | Standard deviation of elements over given axes, ignoring NaNs        |
   +----------------------------+----------------------------------------------------------------------+