GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
lo-mappers.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 Copyright (C) 2010 VZLU Prague
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_lo_mappers_h)
25 #define octave_lo_mappers_h 1
26 
27 #include "octave-config.h"
28 
29 #include <cmath>
30 
31 #include <limits>
32 
33 #include "lo-ieee.h"
34 #include "oct-cmplx.h"
35 #include "oct-inttypes-fwd.h"
36 
37 namespace octave
38 {
39  namespace math
40  {
41  extern OCTAVE_API bool isna (double x);
42  OCTAVE_DEPRECATED (4.4, "use 'math::isna' instead")
43  inline bool is_NA (double x) { return math::isna (x); }
44 
45  extern OCTAVE_API bool isna (float x);
46  OCTAVE_DEPRECATED (4.4, "use 'math::isna' instead")
47  inline bool is_NA (float x) { return math::isna (x); }
48 
49  extern OCTAVE_API bool isna (const Complex& x);
50  OCTAVE_DEPRECATED (4.4, "use 'math::isna' instead")
51  inline bool is_NA (const Complex& x) { return math::isna (x); }
52 
53  extern OCTAVE_API bool isna (const FloatComplex& x);
54  OCTAVE_DEPRECATED (4.4, "use 'math::isna' instead")
55  inline bool is_NA (const FloatComplex& x) { return math::isna (x); }
56 
57  extern OCTAVE_API bool is_NaN_or_NA (const Complex& x);
58  extern OCTAVE_API bool is_NaN_or_NA (const FloatComplex& x);
59 
60  inline double copysign (double x, double y) { return std::copysign (x, y); }
61  inline float copysign (float x, float y) { return std::copysignf (x, y); }
62 
63  inline double signbit (double x) { return std::signbit (x); }
64  inline float signbit (float x) { return std::signbit (x); }
65 
66  // Test for negative sign.
67  extern OCTAVE_API bool negative_sign (double x);
68  extern OCTAVE_API bool negative_sign (float x);
69 
70  // Test for positive sign.
71  inline bool positive_sign (double x) { return ! negative_sign (x); }
72  inline bool positive_sign (float x) { return ! negative_sign (x); }
73 
74  extern OCTAVE_API Complex acos (const Complex& x);
75  extern OCTAVE_API FloatComplex acos (const FloatComplex& x);
76 
77  extern OCTAVE_API Complex asin (const Complex& x);
78  extern OCTAVE_API FloatComplex asin (const FloatComplex& x);
79 
80  inline Complex atan (const Complex& x) { return std::atan (x); }
81  inline FloatComplex atan (const FloatComplex& x) { return std::atan (x); }
82 
83  // The C++ standard would normally return a std::complex value for conj
84  // even when the input is fully real. Octave overrides this.
85  inline double conj (double x) { return x; }
86  inline float conj (float x) { return x; }
87 
88  template <typename T>
89  std::complex<T>
90  conj (const std::complex<T>& x)
91  {
92  return std::conj (x);
93  }
94 
95  inline double log2 (double x) { return std::log2 (x); }
96  inline float log2 (float x) { return std::log2f (x); }
97 
98  extern OCTAVE_API Complex log2 (const Complex& x);
99  extern OCTAVE_API FloatComplex log2 (const FloatComplex& x);
100 
101  extern OCTAVE_API double log2 (double x, int& exp);
102  extern OCTAVE_API float log2 (float x, int& exp);
103 
104  extern OCTAVE_API Complex log2 (const Complex& x, int& exp);
105  extern OCTAVE_API FloatComplex log2 (const FloatComplex& x, int& exp);
106 
107  inline double exp2 (double x) { return std::exp2 (x); }
108  inline float exp2 (float x) { return std::exp2f (x); }
109 
110  template <typename T>
111  std::complex<T>
112  ceil (const std::complex<T>& x)
113  {
114  return std::complex<T> (std::ceil (std::real (x)),
115  std::ceil (std::imag (x)));
116  }
117 
118  template <typename T>
119  std::complex<T>
120  trunc (const std::complex<T>& x)
121  {
122  return std::complex<T> (std::trunc (std::real (x)),
123  std::trunc (std::imag (x)));
124  }
125 
126  // Provide alias for trunc under the more familiar name of fix.
127  inline double fix (double x) { return std::trunc (x); }
128  inline float fix (float x) { return std::trunc (x); }
129 
130  template <typename T>
131  std::complex<T>
132  fix (const std::complex<T>& x)
133  {
134  return trunc (x);
135  }
136 
137  template <typename T>
138  std::complex<T>
139  floor (const std::complex<T>& x)
140  {
141  return std::complex<T> (std::floor (std::real (x)),
142  std::floor (std::imag (x)));
143  }
144 
145  inline double round (double x) { return std::round (x); }
146  inline float round (float x) { return std::roundf (x); }
147 
148  template <typename T>
149  std::complex<T>
150  round (const std::complex<T>& x)
151  {
152  return std::complex<T> (round (std::real (x)), round (std::imag (x)));
153  }
154 
155  inline double
156  roundb (double x)
157  {
158  double t = round (x);
159 
160  if (fabs (x - t) == 0.5)
161  t = 2 * std::trunc (0.5 * t);
162 
163  return t;
164  }
165 
166  inline float
167  roundb (float x)
168  {
169  float t = round (x);
170 
171  if (fabsf (x - t) == 0.5f)
172  t = 2 * std::trunc (0.5f * t);
173 
174  return t;
175  }
176 
177  template <typename T>
178  std::complex<T>
179  roundb (const std::complex<T>& x)
180  {
181  return std::complex<T> (roundb (std::real (x)), roundb (std::imag (x)));
182  }
183 
184  extern OCTAVE_API double frexp (double x, int *expptr);
185  extern OCTAVE_API float frexp (float x, int *expptr);
186 
187  inline bool isnan (bool) { return false; }
188  inline bool isnan (char) { return false; }
189 
190  inline bool isnan (double x) { return std::isnan (x); }
191  inline bool isnan (float x) { return std::isnan (x); }
192 
193  // FIXME: Do we need the isnan overload for complex?
194  template <typename T>
195  bool
196  isnan (const std::complex<T>& x)
197  {
198  return (isnan (std::real (x)) || isnan (std::imag (x)));
199  }
200 
201  inline bool isfinite (double x) { return std::isfinite (x); }
202  inline bool isfinite (float x) { return std::isfinite (x); }
203 
204  // FIXME: Do we need isfinite overload for complex?
205  template <typename T>
206  bool
207  isfinite (const std::complex<T>& x)
208  {
209  return (isfinite (std::real (x)) && isfinite (std::imag (x)));
210  }
211 
212  OCTAVE_DEPRECATED (4.4, "use 'math::isfinite' instead")
213  inline bool finite (double x) { return math::isfinite (x); }
214  OCTAVE_DEPRECATED (4.4, "use 'math::isfinite' instead")
215  inline bool finite (float x) { return math::isfinite (x); }
216 
217  template <typename T>
218  OCTAVE_DEPRECATED (4.4, "use 'math::isfinite' instead")
219  bool
220  finite (const std::complex<T>& x)
221  {
222  return math::isfinite (x);
223  }
224 
225  inline bool isinf (double x) { return std::isinf (x); }
226  inline bool isinf (float x) { return std::isinf (x); }
227 
228  // FIXME: Do we need isinf overload for complex?
229  template <typename T>
230  bool
231  isinf (const std::complex<T>& x)
232  {
233  return (isinf (std::real (x)) || isinf (std::imag (x)));
234  }
235 
236  // Some useful tests, that are commonly repeated.
237  // Test for a finite integer.
238 
239  // FIXME: Benchmark whether trunc might be faster than round here.
240  inline bool isinteger (double x) { return isfinite (x) && x == round (x); }
241  inline bool isinteger (float x) { return isfinite (x) && x == round (x); }
242 
243  inline double
244  signum (double x)
245  {
246  double tmp = 0.0;
247 
248  if (x < 0.0)
249  tmp = -1.0;
250  else if (x > 0.0)
251  tmp = 1.0;
252 
253  return isnan (x) ? numeric_limits<double>::NaN () : tmp;
254  }
255 
256  inline float
257  signum (float x)
258  {
259  float tmp = 0.0f;
260 
261  if (x < 0.0f)
262  tmp = -1.0f;
263  else if (x > 0.0f)
264  tmp = 1.0f;
265 
266  return isnan (x) ? numeric_limits<float>::NaN () : tmp;
267  }
268 
269  template <typename T>
270  std::complex<T>
271  signum (const std::complex<T>& x)
272  {
273  T tmp = abs (x);
274 
275  return tmp == 0 ? 0.0 : x / tmp;
276  }
277 
278  // Convert X to the nearest integer value. Should not pass NaN to
279  // this function.
280 
281  // For integer types? Hmm. Need to be sure T is an integer type...
282  template <typename T>
283  T
284  x_nint (T x)
285  {
286  return x;
287  }
288 
289  template <>
290  inline double x_nint (double x)
291  {
292  return (isfinite (x) ? std::floor (x + 0.5) : x);
293  }
294 
295  template <>
296  inline float x_nint (float x)
297  {
298  return (isfinite (x) ? std::floor (x + 0.5f) : x);
299  }
300 
301  extern OCTAVE_API octave_idx_type nint_big (double x);
302  extern OCTAVE_API octave_idx_type nint_big (float x);
303 
304  extern OCTAVE_API int nint (double x);
305  extern OCTAVE_API int nint (float x);
306 
307  template <typename T>
308  T
309  mod (T x, T y)
310  {
311  T retval;
312 
313  if (y == 0)
314  retval = x;
315  else
316  {
317  T q = x / y;
318 
319  if (x_nint (y) != y
320  && (std::abs ((q - x_nint (q)) / x_nint (q))
321  < std::numeric_limits<T>::epsilon ()))
322  retval = 0;
323  else
324  {
325  T n = std::floor (q);
326 
327  // Prevent use of extra precision.
328  volatile T tmp = y * n;
329 
330  retval = x - tmp;
331  }
332  }
333 
334  if (x != y && y != 0)
335  retval = copysign (retval, y);
336 
337  return retval;
338  }
339 
340  template <typename T>
341  T
342  rem (T x, T y)
343  {
344  T retval;
345 
346  if (y == 0)
348  else
349  {
350  T q = x / y;
351 
352  if (x_nint (y) != y
353  && (std::abs ((q - x_nint (q)) / x_nint (q))
354  < std::numeric_limits<T>::epsilon ()))
355  retval = 0;
356  else
357  {
358  T n = std::trunc (q);
359 
360  // Prevent use of extra precision.
361  volatile T tmp = y * n;
362 
363  retval = x - tmp;
364  }
365  }
366 
367  if (x != y && y != 0)
368  retval = copysign (retval, x);
369 
370  return retval;
371  }
372 
373  // Generic min, max definitions
374  template <typename T>
375  T
376  min (T x, T y)
377  {
378  return x <= y ? x : y;
379  }
380 
381  template <typename T>
382  T
383  max (T x, T y)
384  {
385  return x >= y ? x : y;
386  }
387 
388  // This form is favorable. GCC will translate (x <= y ? x : y) without a
389  // jump, hence the only conditional jump involved will be the first
390  // (isnan), infrequent and hence friendly to branch prediction.
391 
392  inline double
393  min (double x, double y)
394  {
395  return isnan (y) ? x : (x <= y ? x : y);
396  }
397 
398  inline double
399  max (double x, double y)
400  {
401  return isnan (y) ? x : (x >= y ? x : y);
402  }
403 
404  inline float
405  min (float x, float y)
406  {
407  return isnan (y) ? x : (x <= y ? x : y);
408  }
409 
410  inline float
411  max (float x, float y)
412  {
413  return isnan (y) ? x : (x >= y ? x : y);
414  }
415 
416  inline std::complex<double>
417  min (const std::complex<double>& x, const std::complex<double>& y)
418  {
419  return abs (x) <= abs (y) ? x : (isnan (x) ? x : y);
420  }
421 
422  inline std::complex<float>
423  min (const std::complex<float>& x, const std::complex<float>& y)
424  {
425  return abs (x) <= abs (y) ? x : (isnan (x) ? x : y);
426  }
427 
428  inline std::complex<double>
429  max (const std::complex<double>& x, const std::complex<double>& y)
430  {
431  return abs (x) >= abs (y) ? x : (isnan (x) ? x : y);
432  }
433 
434  inline std::complex<float>
435  max (const std::complex<float>& x, const std::complex<float>& y)
436  {
437  return abs (x) >= abs (y) ? x : (isnan (x) ? x : y);
438  }
439 
440  template <typename T>
441  inline octave_int<T>
442  min (const octave_int<T>& x, const octave_int<T>& y)
443  {
444  return xmin (x, y);
445  }
446 
447  template <typename T>
448  inline octave_int<T>
449  max (const octave_int<T>& x, const octave_int<T>& y)
450  {
451  return xmax (x, y);
452  }
453 
454  // These map reals to Complex.
455 
456  extern OCTAVE_API Complex rc_acos (double);
457  extern OCTAVE_API FloatComplex rc_acos (float);
458 
459  extern OCTAVE_API Complex rc_acosh (double);
460  extern OCTAVE_API FloatComplex rc_acosh (float);
461 
462  extern OCTAVE_API Complex rc_asin (double);
463  extern OCTAVE_API FloatComplex rc_asin (float);
464 
465  extern OCTAVE_API Complex rc_atanh (double);
466  extern OCTAVE_API FloatComplex rc_atanh (float);
467 
468  extern OCTAVE_API Complex rc_log (double);
469  extern OCTAVE_API FloatComplex rc_log (float);
470 
471  extern OCTAVE_API Complex rc_log2 (double);
472  extern OCTAVE_API FloatComplex rc_log2 (float);
473 
474  extern OCTAVE_API Complex rc_log10 (double);
475  extern OCTAVE_API FloatComplex rc_log10 (float);
476 
477  extern OCTAVE_API Complex rc_sqrt (double);
478  extern OCTAVE_API FloatComplex rc_sqrt (float);
479  }
480 }
481 
482 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
483 
484 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isna' instead")
485 inline bool octave_is_NA (double x) { return octave::math::isna (x); }
486 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isna' instead")
487 inline bool octave_is_NA (float x) { return octave::math::isna (x); }
488 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isna' instead")
489 inline bool octave_is_NA (const Complex& x) { return octave::math::isna (x); }
490 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isna' instead")
491 inline bool octave_is_NA (const FloatComplex& x)
492 {
493  return octave::math::isna (x);
494 }
495 
496 OCTAVE_DEPRECATED (4.2, "use 'octave::math::acos' instead")
497 inline Complex acos (const Complex& x) { return octave::math::acos (x); }
498 OCTAVE_DEPRECATED (4.2, "use 'octave::math::acos' instead")
499 inline FloatComplex acos (const FloatComplex& x)
500 {
501  return octave::math::acos (x);
502 }
503 
504 OCTAVE_DEPRECATED (4.2, "use 'octave::math::asin' instead")
505 inline Complex asin (const Complex& x) { return octave::math::asin (x); }
506 OCTAVE_DEPRECATED (4.2, "use 'octave::math::asin' instead")
507 inline FloatComplex asin (const FloatComplex& x)
508 {
509  return octave::math::asin (x);
510 }
511 
512 OCTAVE_DEPRECATED (4.2, "use 'octave::math::atan' instead")
513 inline Complex atan (const Complex& x) { return octave::math::atan (x); }
514 OCTAVE_DEPRECATED (4.2, "use 'octave::math::atan' instead")
515 inline FloatComplex atan (const FloatComplex& x)
516 {
517  return octave::math::atan (x);
518 }
519 
520 OCTAVE_DEPRECATED (4.2, "use 'std::arg' instead")
521 inline double arg (double x) { return std::arg (x); }
522 OCTAVE_DEPRECATED (4.2, "use 'std::arg' instead")
523 inline float arg (float x) { return std::arg (x); }
524 
525 OCTAVE_DEPRECATED (4.2, "use 'octave::math::conj' instead")
526 inline double conj (double x) { return x; }
527 OCTAVE_DEPRECATED (4.2, "use 'octave::math::conj' instead")
528 inline float conj (float x) { return x; }
529 
530 OCTAVE_DEPRECATED (4.2, "use 'std::imag' instead")
531 inline double imag (double x) { return std::imag (x); }
532 OCTAVE_DEPRECATED (4.2, "use 'std::imag' instead")
533 inline float imag (float x) { return std::imag (x); }
534 
535 OCTAVE_DEPRECATED (4.2, "use 'std::real' instead")
536 inline double real (double x) { return std::real (x); }
537 OCTAVE_DEPRECATED (4.2, "use 'std::real' instead")
538 inline float real (float x) { return std::real (x); }
539 
540 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
541 inline double xlog2 (double x) { return octave::math::log2 (x); }
542 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
543 inline float xlog2 (float x) { return octave::math::log2 (x); }
544 
545 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
546 inline Complex xlog2 (const Complex& x) { return octave::math::log2 (x); }
547 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
548 inline FloatComplex xlog2 (const FloatComplex& x)
549 {
550  return octave::math::log2 (x);
551 }
552 
553 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
554 inline double xlog2 (double x, int& exp)
555 {
556  return octave::math::log2 (x, exp);
557 }
558 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
559 inline float xlog2 (float x, int& exp) { return octave::math::log2 (x, exp); }
560 
561 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
562 inline Complex xlog2 (const Complex& x, int& exp)
563 {
564  return octave::math::log2 (x, exp);
565 }
566 OCTAVE_DEPRECATED (4.2, "use 'octave::math::log2' instead")
567 inline FloatComplex xlog2 (const FloatComplex& x, int& exp)
568 {
569  return octave::math::log2 (x, exp);
570 }
571 
572 OCTAVE_DEPRECATED (4.2, "use 'octave::math::exp2' instead")
573 inline double xexp2 (double x) { return octave::math::exp2 (x); }
574 OCTAVE_DEPRECATED (4.2, "use 'octave::math::exp2' instead")
575 inline float xexp2 (float x) { return octave::math::exp2 (x); }
576 
577 OCTAVE_DEPRECATED (4.2, "use 'std::ceil' instead")
578 inline double xceil (double x) { return std::ceil (x); }
579 OCTAVE_DEPRECATED (4.2, "use 'std::ceil' instead")
580 inline float xceil (float x) { return std::ceil (x); }
581 
582 template <typename T>
583 OCTAVE_DEPRECATED (4.2, "use 'octave::math::ceil' instead")
584 std::complex<T>
585 ceil (const std::complex<T>& x)
586 {
587  return octave::math::ceil (x);
588 }
589 
590 OCTAVE_DEPRECATED (4.2, "use 'octave::math::copysign' instead")
591 inline double xcopysign (double x, double y)
592 {
593  return octave::math::copysign (x, y);
594 }
595 OCTAVE_DEPRECATED (4.2, "use 'octave::math::copysign' instead")
596 inline float xcopysign (float x, float y)
597 {
598  return octave::math::copysign (x, y);
599 }
600 
601 template <typename T>
602 OCTAVE_DEPRECATED (4.2, "use 'octave::math::signbit' instead")
603 T
604 xsignbit (T x)
605 {
606  return octave::math::signbit (x);
607 }
608 
609 OCTAVE_DEPRECATED (4.2, "use 'octave::math::negative_sign' instead")
610 inline bool xnegative_sign (double x)
611 {
613 }
614 OCTAVE_DEPRECATED (4.2, "use 'octave::math::negative_sign' instead")
615 inline bool xnegative_sign (float x)
616 {
618 }
619 
620 OCTAVE_DEPRECATED (4.2, "use 'octave::math::positive_sign' instead")
621 inline bool xpositive_sign (double x)
622 {
624 }
625 OCTAVE_DEPRECATED (4.2, "use 'octave::math::positive_sign' instead")
626 inline bool xpositive_sign (float x)
627 {
629 }
630 
631 OCTAVE_DEPRECATED (4.2, "use 'octave::math::signum' instead")
632 inline double signum (double x) { return octave::math::signum (x); }
633 OCTAVE_DEPRECATED (4.2, "use 'octave::math::signum' instead")
634 inline float signum (float x) { return octave::math::signum (x); }
635 
636 template <typename T>
637 OCTAVE_DEPRECATED (4.2, "use 'octave::math::signum' instead")
638 std::complex<T>
639 signum (const std::complex<T>& x)
640 {
641  return octave::math::signum (x);
642 }
643 
644 OCTAVE_DEPRECATED (4.2, "use 'std::trunc' instead")
645 inline double xtrunc (double x) { return std::trunc (x); }
646 OCTAVE_DEPRECATED (4.2, "use 'std::trunc' instead")
647 inline float xtrunc (float x) { return std::trunc (x); }
648 
649 template <typename T>
650 OCTAVE_DEPRECATED (4.2, "use 'octave::math::trunc' instead")
651 std::complex<T>
652 xtrunc (const std::complex<T>& x)
653 {
654  return octave::math::trunc (x);
655 }
656 
657 OCTAVE_DEPRECATED (4.2, "use 'octave::math::fix' instead")
658 inline double fix (double x) { return octave::math::fix (x); }
659 OCTAVE_DEPRECATED (4.2, "use 'octave::math::fix' instead")
660 inline float fix (float x) { return octave::math::fix (x); }
661 
662 template <typename T>
663 OCTAVE_DEPRECATED (4.2, "use 'octave::math::fix' instead")
664 std::complex<T>
665 fix (const std::complex<T>& x)
666 {
667  return octave::math::fix (x);
668 }
669 
670 OCTAVE_DEPRECATED (4.2, "use 'std::floor' instead")
671 inline double xfloor (double x) { return std::floor (x); }
672 OCTAVE_DEPRECATED (4.2, "use 'std::floor' instead")
673 inline float xfloor (float x) { return std::floor (x); }
674 
675 template <typename T>
676 OCTAVE_DEPRECATED (4.2, "use 'octave::math::floor' instead")
677 std::complex<T>
678 floor (const std::complex<T>& x)
679 {
680  return octave::math::floor (x);
681 }
682 
683 OCTAVE_DEPRECATED (4.2, "use 'octave::math::round' instead")
684 inline double xround (double x) { return octave::math::round (x); }
685 OCTAVE_DEPRECATED (4.2, "use 'octave::math::round' instead")
686 inline float xround (float x) { return octave::math::round (x); }
687 
688 template <typename T>
689 OCTAVE_DEPRECATED (4.2, "use 'octave::math::round' instead")
690 std::complex<T>
691 xround (const std::complex<T>& x)
692 {
693  return octave::math::round (x);
694 }
695 
696 OCTAVE_DEPRECATED (4.2, "use 'octave::math::roundb' instead")
697 inline double xroundb (double x) { return octave::math::roundb (x); }
698 OCTAVE_DEPRECATED (4.2, "use 'octave::math::roundb' instead")
699 inline float xroundb (float x) { return octave::math::roundb (x); }
700 
701 template <typename T>
702 OCTAVE_DEPRECATED (4.2, "use 'octave::math::roundb' instead")
703 std::complex<T>
704 xroundb (const std::complex<T>& x)
705 {
706  return octave::math::roundb (x);
707 }
708 
709 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isnan' instead")
710 inline bool xisnan (bool x) { return octave::math::isnan (x); }
711 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isnan' instead")
712 inline bool xisnan (char x) { return octave::math::isnan (x); }
713 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isnan' instead")
714 inline bool xisnan (double x) { return octave::math::isnan (x); }
715 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isnan' instead")
716 inline bool xisnan (float x) { return octave::math::isnan (x); }
717 
718 template <typename T>
719 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isnan' instead")
720 bool
721 xisnan (const std::complex<T>& x)
722 {
723  return octave::math::isnan (x);
724 }
725 
726 OCTAVE_DEPRECATED (4.4, "use 'octave::math::isfinite' instead")
727 inline bool xfinite (double x) { return octave::math::isfinite (x); }
728 OCTAVE_DEPRECATED (4.4, "use 'octave::math::isfinite' instead")
729 inline bool xfinite (float x) { return octave::math::isfinite (x); }
730 
731 template <typename T>
732 OCTAVE_DEPRECATED (4.4, "use 'octave::math::isfinite' instead")
733 bool
734 xfinite (const std::complex<T>& x)
735 {
736  return octave::math::isfinite (x);
737 }
738 
739 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isinf' instead")
740 inline bool xisinf (double x) { return octave::math::isinf (x); }
741 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isinf' instead")
742 inline bool xisinf (float x) { return octave::math::isinf (x); }
743 
744 template <typename T>
745 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isinf' instead")
746 bool
747 xisinf (const std::complex<T>& x)
748 {
749  return octave::math::isinf (x);
750 }
751 
752 // Some useful tests, that are commonly repeated.
753 // Test for a finite integer.
754 
755 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isinteger' instead")
756 inline bool
757 xisinteger (double x)
758 {
759  return octave::math::isinteger (x);
760 }
761 
762 OCTAVE_DEPRECATED (4.2, "use 'octave::math::isinteger' instead")
763 inline bool
764 xisinteger (float x)
765 {
766  return octave::math::isinteger (x);
767 }
768 
769 template <typename T>
770 OCTAVE_DEPRECATED (4.2, "use 'octave::math::x_nint' instead")
771 T
772 X_NINT (T x)
773 {
774  return octave::math::x_nint (x);
775 }
776 
777 OCTAVE_DEPRECATED (4.2, "use 'octave::math::x_nint (x)' instead")
778 inline double D_NINT (double x) { return octave::math::x_nint (x); }
779 OCTAVE_DEPRECATED (4.2, "use 'octave::math::x_nint (x)' instead")
780 inline float F_NINT (float x) { return octave::math::x_nint (x); }
781 
782 OCTAVE_DEPRECATED (4.2, "use 'octave::math::nint_big' instead")
783 inline octave_idx_type NINTbig (double x) { return octave::math::nint_big (x); }
784 OCTAVE_DEPRECATED (4.2, "use 'octave::math::nint_big' instead")
785 inline octave_idx_type NINTbig (float x) { return octave::math::nint_big (x); }
786 
787 OCTAVE_DEPRECATED (4.2, "use 'octave::math::nint' instead")
788 inline int NINT (double x) { return octave::math::nint (x); }
789 OCTAVE_DEPRECATED (4.2, "use 'octave::math::nint' instead")
790 inline int NINT (float x) { return octave::math::nint (x); }
791 
792 template <typename T>
793 OCTAVE_DEPRECATED (4.2, "use 'octave::math::mod' instead")
794 T
795 xmod (T x, T y)
796 {
797  return octave::math::mod (x, y);
798 }
799 
800 template <typename T>
801 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rem' instead")
802 T
803 xrem (T x, T y)
804 {
805  return octave::math::rem (x, y);
806 }
807 
808 template <typename T>
809 OCTAVE_DEPRECATED (4.2, "use 'octave::math::min' instead")
810 T
811 xmin (T x, T y)
812 {
813  return octave::math::min (x, y);
814 }
815 
816 template <typename T>
817 OCTAVE_DEPRECATED (4.2, "use 'octave::math::max' instead")
818 T
819 xmax (T x, T y)
820 {
821  return octave::math::max (x, y);
822 }
823 
824 OCTAVE_DEPRECATED (4.2, "use 'octave::math::min' instead")
825 inline double
826 xmin (double x, double y)
827 {
828  return octave::math::min (x, y);
829 }
830 
831 OCTAVE_DEPRECATED (4.2, "use 'octave::math::max' instead")
832 inline double
833 xmax (double x, double y)
834 {
835  return octave::math::max (x, y);
836 }
837 
838 OCTAVE_DEPRECATED (4.2, "use 'octave::math::min' instead")
839 inline float
840 xmin (float x, float y)
841 {
842  return octave::math::min (x, y);
843 }
844 
845 OCTAVE_DEPRECATED (4.2, "use 'octave::math::max' instead")
846 inline float
847 xmax (float x, float y)
848 {
849  return octave::math::max (x, y);
850 }
851 
852 OCTAVE_DEPRECATED (4.2, "use 'octave::math::min' instead")
853 inline Complex
854 xmin (const Complex& x, const Complex& y)
855 {
856  return octave::math::min (x, y);
857 }
858 
859 OCTAVE_DEPRECATED (4.2, "use 'octave::math::max' instead")
860 inline Complex
861 xmax (const Complex& x, const Complex& y)
862 {
863  return octave::math::max (x, y);
864 }
865 
866 OCTAVE_DEPRECATED (4.2, "use 'octave::math::min' instead")
867 inline OCTAVE_API FloatComplex
868 xmin (const FloatComplex& x, const FloatComplex& y)
869 {
870  return octave::math::min (x, y);
871 }
872 
873 OCTAVE_DEPRECATED (4.2, "use 'octave::math::max' instead")
874 inline FloatComplex
875 xmax (const FloatComplex& x, const FloatComplex& y)
876 {
877  return octave::math::max (x, y);
878 }
879 
880 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_acos' instead")
881 inline Complex rc_acos (double x) { return octave::math::rc_acos (x); }
882 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_acos' instead")
883 inline FloatComplex rc_acos (float x) { return octave::math::rc_acos (x); }
884 
885 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_acosh' instead")
886 inline Complex rc_acosh (double x) { return octave::math::rc_acosh (x); }
887 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_acosh' instead")
888 inline FloatComplex rc_acosh (float x) { return octave::math::rc_acosh (x); }
889 
890 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_asin' instead")
891 inline Complex rc_asin (double x) { return octave::math::rc_asin (x); }
892 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_asin' instead")
893 inline FloatComplex rc_asin (float x) { return octave::math::rc_asin (x); }
894 
895 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_atanh' instead")
896 inline Complex rc_atanh (double x) { return octave::math::rc_atanh (x); }
897 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_atanh' instead")
898 inline FloatComplex rc_atanh (float x) { return octave::math::rc_atanh (x); }
899 
900 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_log' instead")
901 inline Complex rc_log (double x) { return octave::math::rc_log (x); }
902 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_log' instead")
903 inline FloatComplex rc_log (float x) { return octave::math::rc_log (x); }
904 
905 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_log2' instead")
906 inline Complex rc_log2 (double x) { return octave::math::rc_log2 (x); }
907 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_log2' instead")
908 inline FloatComplex rc_log2 (float x) { return octave::math::rc_log2 (x); }
909 
910 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_log10' instead")
911 inline Complex rc_log10 (double x) { return octave::math::rc_log10 (x); }
912 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_log10' instead")
913 inline FloatComplex rc_log10 (float x) { return octave::math::rc_log10 (x); }
914 
915 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_sqrt' instead")
916 inline Complex rc_sqrt (double x) { return octave::math::rc_sqrt (x); }
917 OCTAVE_DEPRECATED (4.2, "use 'octave::math::rc_sqrt' instead")
918 inline FloatComplex rc_sqrt (float x) { return octave::math::rc_sqrt (x); }
919 
920 #endif
921 
922 #endif
bool isinteger(double x)
Definition: lo-mappers.h:240
FloatComplex atan(const FloatComplex &x)
Definition: lo-mappers.h:81
Complex rc_log10(double x)
Definition: lo-mappers.cc:307
octave_int< T > xmax(const octave_int< T > &x, const octave_int< T > &y)
Complex rc_acosh(double x)
Definition: lo-mappers.cc:241
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:322
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
double conj(double x)
Definition: lo-mappers.h:85
T max(T x, T y)
Definition: lo-mappers.h:383
bool isna(double x)
Definition: lo-mappers.cc:45
bool isnan(bool)
Definition: lo-mappers.h:187
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:112
float log2(float x)
Definition: lo-mappers.h:96
bool isinf(double x)
Definition: lo-mappers.h:225
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:139
std::complex< T > round(const std::complex< T > &x)
Definition: lo-mappers.h:150
STL namespace.
static T abs(T x)
Definition: pr-output.cc:1696
bool isinf(const std::complex< T > &x)
Definition: lo-mappers.h:231
Complex acos(const Complex &x)
Definition: lo-mappers.cc:83
Complex atan(const Complex &x)
Definition: lo-mappers.h:80
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
float signbit(float x)
Definition: lo-mappers.h:64
bool positive_sign(double x)
Definition: lo-mappers.h:71
double fix(double x)
Definition: lo-mappers.h:127
Complex asin(const Complex &x)
Definition: lo-mappers.cc:105
double frexp(double x, int *expptr)
Definition: lo-mappers.cc:126
Complex log2(const Complex &x)
Definition: lo-mappers.cc:137
std::complex< T > signum(const std::complex< T > &x)
Definition: lo-mappers.h:271
octave_value arg
Definition: pr-output.cc:3244
Complex rc_atanh(double x)
Definition: lo-mappers.cc:266
float copysign(float x, float y)
Definition: lo-mappers.h:61
double signum(double x)
Definition: lo-mappers.h:244
Complex rc_log2(double x)
Definition: lo-mappers.cc:292
std::complex< T > trunc(const std::complex< T > &x)
Definition: lo-mappers.h:120
double tmp
Definition: data.cc:6252
octave_value retval
Definition: data.cc:6246
Complex rc_log(double x)
Definition: lo-mappers.cc:279
bool finite(double x)
Definition: lo-mappers.h:213
std::complex< T > conj(const std::complex< T > &x)
Definition: lo-mappers.h:90
bool isfinite(const std::complex< T > &x)
Definition: lo-mappers.h:207
T min(T x, T y)
Definition: lo-mappers.h:376
Complex rc_acos(double x)
Definition: lo-mappers.cc:228
octave_int< T > xmin(const octave_int< T > &x, const octave_int< T > &y)
float exp2(float x)
Definition: lo-mappers.h:108
double exp2(double x)
Definition: lo-mappers.h:107
T mod(T x, T y)
Definition: lo-mappers.h:309
bool is_NaN_or_NA(const Complex &x)
Definition: lo-mappers.cc:69
octave_idx_type nint_big(double x)
Definition: lo-mappers.cc:182
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number). NaN is the result of operations which do not produce a well defined 0 result. Common operations which produce a NaN are arithmetic with infinity ex($\infty - \infty$)
bool negative_sign(double x)
Definition: lo-mappers.cc:176
bool isnan(const std::complex< T > &x)
Definition: lo-mappers.h:196
Complex rc_asin(double x)
Definition: lo-mappers.cc:253
bool isfinite(double x)
Definition: lo-mappers.h:201
double roundb(double x)
Definition: lo-mappers.h:156
bool is_NA(double x)
Definition: lo-mappers.h:43
the element is set to zero In other the statement xample y
Definition: data.cc:5264
double round(double x)
Definition: lo-mappers.h:145
T rem(T x, T y)
Definition: lo-mappers.h:342
ColumnVector imag(const ComplexColumnVector &a)
Definition: dColVector.cc:141
std::complex< T > fix(const std::complex< T > &x)
Definition: lo-mappers.h:132
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
std::complex< double > Complex
Definition: oct-cmplx.h:31
ColumnVector real(const ComplexColumnVector &a)
Definition: dColVector.cc:135
double copysign(double x, double y)
Definition: lo-mappers.h:60
double signbit(double x)
Definition: lo-mappers.h:63
T x_nint(T x)
Definition: lo-mappers.h:284
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
int nint(double x)
Definition: lo-mappers.cc:206