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