Mercurial > octave-nkf
annotate liboctave/numeric/lo-mappers.h @ 17822:ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
* libgui/src/dialog.h, libgui/src/find-files-dialog.h,
libgui/src/find-files-model.h, libgui/src/m-editor/file-editor-tab.h,
libgui/src/m-editor/octave-qscintilla.h, libgui/src/main-window.h,
libgui/src/octave-dock-widget.h, libgui/src/workspace-model.h,
libgui/src/workspace-view.h, libinterp/corefcn/Cell.h,
libinterp/corefcn/gl-render.h, libinterp/corefcn/gl2ps-renderer.h,
libinterp/corefcn/graphics.in.h, libinterp/corefcn/oct-errno.h,
libinterp/corefcn/oct-fstrm.h, libinterp/corefcn/oct-handle.h,
libinterp/corefcn/oct-hdf5.h, libinterp/corefcn/oct-hist.h,
libinterp/corefcn/oct-iostrm.h, libinterp/corefcn/oct-lvalue.h,
libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-procbuf.h,
libinterp/corefcn/oct-stdstrm.h, libinterp/corefcn/oct-stream.h,
libinterp/corefcn/oct-strstrm.h, libinterp/corefcn/octave-link.h,
libinterp/corefcn/pt-jit.h, libinterp/octave-value/ov-base-diag.h,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.h,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.h,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.h,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.h,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h,
libinterp/octave-value/ov-complex.h, libinterp/octave-value/ov-cs-list.h,
libinterp/octave-value/ov-cx-diag.h, libinterp/octave-value/ov-cx-mat.h,
libinterp/octave-value/ov-cx-sparse.h, libinterp/octave-value/ov-dld-fcn.h,
libinterp/octave-value/ov-fcn-handle.h, libinterp/octave-value/ov-fcn-inline.h,
libinterp/octave-value/ov-fcn.h, libinterp/octave-value/ov-float.h,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int-traits.h,
libinterp/octave-value/ov-int16.h, libinterp/octave-value/ov-int32.h,
libinterp/octave-value/ov-int64.h, libinterp/octave-value/ov-int8.h,
libinterp/octave-value/ov-java.h, libinterp/octave-value/ov-lazy-idx.h,
libinterp/octave-value/ov-mex-fcn.h, libinterp/octave-value/ov-null-mat.h,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.h,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.h,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.h,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.h,
libinterp/octave-value/ov-typeinfo.h, libinterp/octave-value/ov-uint16.h,
libinterp/octave-value/ov-uint32.h, libinterp/octave-value/ov-uint64.h,
libinterp/octave-value/ov-uint8.h, libinterp/octave-value/ov-usr-fcn.h,
libinterp/octave-value/ov.h, libinterp/parse-tree/pt-all.h,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-array-list.h,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.h,
libinterp/parse-tree/pt-bp.h, libinterp/parse-tree/pt-cbinop.h,
libinterp/parse-tree/pt-cell.h, libinterp/parse-tree/pt-check.h,
libinterp/parse-tree/pt-cmd.h, libinterp/parse-tree/pt-colon.h,
libinterp/parse-tree/pt-const.h, libinterp/parse-tree/pt-decl.h,
libinterp/parse-tree/pt-eval.h, libinterp/parse-tree/pt-except.h,
libinterp/parse-tree/pt-exp.h, libinterp/parse-tree/pt-fcn-handle.h,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.h,
libinterp/parse-tree/pt-jump.h, libinterp/parse-tree/pt-loop.h,
libinterp/parse-tree/pt-mat.h, libinterp/parse-tree/pt-misc.h,
libinterp/parse-tree/pt-pr-code.h, libinterp/parse-tree/pt-select.h,
libinterp/parse-tree/pt-stmt.h, libinterp/parse-tree/pt-unop.h,
libinterp/parse-tree/pt-walk.h, libinterp/parse-tree/pt.h,
liboctave/array/CColVector.h, liboctave/array/CDiagMatrix.h,
liboctave/array/CMatrix.h, liboctave/array/CNDArray.h,
liboctave/array/CRowVector.h, liboctave/array/boolMatrix.h,
liboctave/array/chMatrix.h, liboctave/array/chNDArray.h,
liboctave/array/dColVector.h, liboctave/array/dDiagMatrix.h,
liboctave/array/dMatrix.h, liboctave/array/dNDArray.h,
liboctave/array/dRowVector.h, liboctave/array/fCColVector.h,
liboctave/array/fCDiagMatrix.h, liboctave/array/fCMatrix.h,
liboctave/array/fCNDArray.h, liboctave/array/fCRowVector.h,
liboctave/array/fColVector.h, liboctave/array/fDiagMatrix.h,
liboctave/array/fMatrix.h, liboctave/array/fNDArray.h,
liboctave/array/fRowVector.h, liboctave/cruft/misc/lo-error.h,
liboctave/numeric/CmplxAEPBAL.h, liboctave/numeric/CmplxCHOL.h,
liboctave/numeric/CmplxGEPBAL.h, liboctave/numeric/CmplxHESS.h,
liboctave/numeric/CmplxLU.h, liboctave/numeric/CmplxQR.h,
liboctave/numeric/CmplxQRP.h, liboctave/numeric/CmplxSCHUR.h,
liboctave/numeric/CmplxSVD.h, liboctave/numeric/Quad.h,
liboctave/numeric/SparseCmplxCHOL.h, liboctave/numeric/SparseCmplxLU.h,
liboctave/numeric/SparseCmplxQR.h, liboctave/numeric/SparseQR.h,
liboctave/numeric/SparsedbleCHOL.h, liboctave/numeric/SparsedbleLU.h,
liboctave/numeric/bsxfun.h, liboctave/numeric/dbleAEPBAL.h,
liboctave/numeric/dbleCHOL.h, liboctave/numeric/dbleGEPBAL.h,
liboctave/numeric/dbleHESS.h, liboctave/numeric/dbleLU.h,
liboctave/numeric/dbleQR.h, liboctave/numeric/dbleQRP.h,
liboctave/numeric/dbleSCHUR.h, liboctave/numeric/dbleSVD.h,
liboctave/numeric/fCmplxAEPBAL.h, liboctave/numeric/fCmplxCHOL.h,
liboctave/numeric/fCmplxGEPBAL.h, liboctave/numeric/fCmplxHESS.h,
liboctave/numeric/fCmplxLU.h, liboctave/numeric/fCmplxQR.h,
liboctave/numeric/fCmplxQRP.h, liboctave/numeric/fCmplxSCHUR.h,
liboctave/numeric/fCmplxSVD.h, liboctave/numeric/fEIG.h,
liboctave/numeric/floatAEPBAL.h, liboctave/numeric/floatCHOL.h,
liboctave/numeric/floatGEPBAL.h, liboctave/numeric/floatHESS.h,
liboctave/numeric/floatLU.h, liboctave/numeric/floatQR.h,
liboctave/numeric/floatQRP.h, liboctave/numeric/floatSCHUR.h,
liboctave/numeric/floatSVD.h, liboctave/numeric/lo-mappers.h,
liboctave/numeric/lo-specfun.h, liboctave/numeric/oct-convn.h,
liboctave/numeric/oct-norm.h, liboctave/numeric/oct-rand.h,
liboctave/operators/Sparse-diag-op-defs.h,
liboctave/operators/Sparse-op-defs.h,
liboctave/operators/Sparse-perm-op-defs.h, liboctave/system/lo-sysdep.h,
liboctave/system/oct-env.h, liboctave/system/oct-group.h,
liboctave/system/oct-openmp.h, liboctave/system/oct-passwd.h,
liboctave/system/oct-syscalls.h, liboctave/system/oct-time.h,
liboctave/system/oct-uname.h, liboctave/util/lo-array-gripes.h,
liboctave/util/lo-cutils.h, liboctave/util/lo-ieee.h,
liboctave/util/lo-macros.h, liboctave/util/lo-math.h,
liboctave/util/lo-regexp.h, liboctave/util/lo-traits.h,
liboctave/util/lo-utils.h, liboctave/util/oct-base64.h,
liboctave/util/oct-binmap.h, liboctave/util/oct-glob.h,
liboctave/util/oct-inttypes.h, liboctave/util/oct-locbuf.h,
liboctave/util/oct-mem.h, liboctave/util/oct-mutex.h,
liboctave/util/oct-refcount.h, liboctave/util/oct-rl-edit.h,
liboctave/util/oct-rl-hist.h, liboctave/util/oct-shlib.h,
liboctave/util/oct-sort.h, liboctave/util/oct-sparse.h:
Use common #define syntax "octave_filename_h" in h_files.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 31 Oct 2013 22:19:07 -0700 |
parents | 49a5a4be04a1 |
children | 23681c9ea7ba |
rev | line source |
---|---|
1967 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
16971
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10436
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
1967 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1967 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1967 | 21 |
22 */ | |
23 | |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
24 #if !defined (octave_lo_mappers_h) |
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
25 #define octave_lo_mappers_h 1 |
1967 | 26 |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
27 #include <limits> |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
28 |
1967 | 29 #include "oct-cmplx.h" |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
30 #include "lo-math.h" |
1967 | 31 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
32 // Double Precision |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11213
diff
changeset
|
33 extern OCTAVE_API double xtrunc (double x); |
13737
30414ff19d5e
Use copysignf module from gnulib.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13720
diff
changeset
|
34 extern OCTAVE_API double xcopysign (double x, double y); |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
35 inline double xceil (double x) { return ceil (x); } |
11525
ab231f944252
avoid exposing gnulib:: in header files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
36 extern OCTAVE_API double xfloor (double x); |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
37 inline double arg (double x) { return atan2 (0.0, x); } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
38 inline double conj (double x) { return x; } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
39 inline double fix (double x) { return xtrunc (x); } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
40 inline double imag (double) { return 0.0; } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
41 inline double real (double x) { return x; } |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11213
diff
changeset
|
42 extern OCTAVE_API double xround (double x); |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
43 extern OCTAVE_API double xroundb (double x); |
6108 | 44 extern OCTAVE_API double signum (double x); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
45 extern OCTAVE_API double xlog2 (double x); |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
46 extern OCTAVE_API Complex xlog2 (const Complex& x); |
7740 | 47 extern OCTAVE_API double xlog2 (double x, int& exp); |
48 extern OCTAVE_API Complex xlog2 (const Complex& x, int& exp); | |
6108 | 49 extern OCTAVE_API double xexp2 (double x); |
1967 | 50 |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
51 // These are used by the BOOL_OP macros in mx-op-defs.h. |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
52 inline bool xisnan (bool) { return false; } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
53 inline bool xisnan (char) { return false; } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
54 |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
55 #if defined (HAVE_CMATH_ISNAN) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
56 inline bool xisnan (double x) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
57 { return std::isnan (x); } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
58 #else |
6108 | 59 extern OCTAVE_API bool xisnan (double x); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
60 #endif |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
61 #if defined (HAVE_CMATH_ISFINITE) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
62 inline bool xfinite (double x) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
63 { return std::isfinite (x); } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
64 #else |
6108 | 65 extern OCTAVE_API bool xfinite (double x); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
66 #endif |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
67 #if defined (HAVE_CMATH_ISINF) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
68 inline bool xisinf (double x) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
69 { return std::isinf (x); } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
70 #else |
6108 | 71 extern OCTAVE_API bool xisinf (double x); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
72 #endif |
3248 | 73 |
6108 | 74 extern OCTAVE_API bool octave_is_NA (double x); |
75 extern OCTAVE_API bool octave_is_NaN_or_NA (double x) GCC_ATTR_DEPRECATED; | |
4025 | 76 |
10268
9a16a61ed43d
new optimizations for accumarray
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
77 // Generic xmin, xmax definitions |
9a16a61ed43d
new optimizations for accumarray
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
78 template <class T> |
9a16a61ed43d
new optimizations for accumarray
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
79 inline T xmin (T x, T y) |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
80 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
81 return x <= y ? x : y; |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
82 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
83 |
10268
9a16a61ed43d
new optimizations for accumarray
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
84 template <class T> |
9a16a61ed43d
new optimizations for accumarray
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
85 inline T xmax (T x, T y) |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
86 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
87 return x >= y ? x : y; |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
88 } |
10268
9a16a61ed43d
new optimizations for accumarray
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
89 |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
90 // This form is favorable. GCC will translate (x <= y ? x : y) without a |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
91 // jump, hence the only conditional jump involved will be the first |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
92 // (xisnan), infrequent and hence friendly to branch prediction. |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
93 inline double |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
94 xmin (double x, double y) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
95 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
96 return xisnan (y) ? x : (x <= y ? x : y); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
97 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
98 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
99 inline double |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
100 xmax (double x, double y) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
101 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
102 return xisnan (y) ? x : (x >= y ? x : y); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
103 } |
1967 | 104 |
6108 | 105 extern OCTAVE_API Complex acos (const Complex& x); |
106 extern OCTAVE_API Complex acosh (const Complex& x); | |
107 extern OCTAVE_API Complex asin (const Complex& x); | |
108 extern OCTAVE_API Complex asinh (const Complex& x); | |
109 extern OCTAVE_API Complex atan (const Complex& x); | |
110 extern OCTAVE_API Complex atanh (const Complex& x); | |
3777 | 111 |
6108 | 112 extern OCTAVE_API bool octave_is_NA (const Complex& x); |
113 extern OCTAVE_API bool octave_is_NaN_or_NA (const Complex& x); | |
4469 | 114 |
6108 | 115 extern OCTAVE_API Complex xmin (const Complex& x, const Complex& y); |
116 extern OCTAVE_API Complex xmax (const Complex& x, const Complex& y); | |
3248 | 117 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
118 // Single Precision |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11213
diff
changeset
|
119 extern OCTAVE_API float xtrunc (float x); |
13737
30414ff19d5e
Use copysignf module from gnulib.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13720
diff
changeset
|
120 extern OCTAVE_API float xcopysign (float x, float y); |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
121 inline float xceil (float x) { return ceilf (x); } |
15409
c898dbe14e1d
build: Update imported module list from gnulib.
Rik <rik@octave.org>
parents:
15271
diff
changeset
|
122 extern OCTAVE_API float xfloor (float x); |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
123 inline float arg (float x) { return atan2f (0.0f, x); } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
124 inline float conj (float x) { return x; } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
125 inline float fix (float x) { return xtrunc (x); } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
126 inline float imag (float) { return 0.0f; } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
127 inline float real (float x) { return x; } |
11237
110e570e5f8d
keep gnulib out of lo-mappers.h
John W. Eaton <jwe@octave.org>
parents:
11213
diff
changeset
|
128 extern OCTAVE_API float xround (float x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
129 extern OCTAVE_API float xroundb (float x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
130 extern OCTAVE_API float signum (float x); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
131 extern OCTAVE_API float xlog2 (float x); |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
132 extern OCTAVE_API FloatComplex xlog2 (const FloatComplex& x); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
133 extern OCTAVE_API float xlog2 (float x, int& exp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
134 extern OCTAVE_API FloatComplex xlog2 (const FloatComplex& x, int& exp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
135 extern OCTAVE_API float xexp2 (float x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
136 |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
137 #if defined (HAVE_CMATH_ISNANF) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
138 inline bool xisnan (float x) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
139 { return std::isnan (x); } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
140 #else |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
141 extern OCTAVE_API bool xisnan (float x); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
142 #endif |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
143 #if defined (HAVE_CMATH_ISFINITEF) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
144 inline bool xfinite (float x) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
145 { return std::isfinite (x); } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
146 #else |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
147 extern OCTAVE_API bool xfinite (float x); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
148 #endif |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
149 #if defined (HAVE_CMATH_ISINFF) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
150 inline bool xisinf (float x) |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
151 { return std::isinf (x); } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
152 #else |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
153 extern OCTAVE_API bool xisinf (float x); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
154 #endif |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
155 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
156 extern OCTAVE_API bool octave_is_NA (float x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
157 extern OCTAVE_API bool octave_is_NaN_or_NA (float x) GCC_ATTR_DEPRECATED; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
158 |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
159 inline float |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
160 xmin (float x, float y) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
161 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
162 return xisnan (y) ? x : (x <= y ? x : y); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
163 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
164 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
165 inline float |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
166 xmax (float x, float y) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
167 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
168 return xisnan (y) ? x : (x >= y ? x : y); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
169 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
170 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
171 extern OCTAVE_API FloatComplex acos (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
172 extern OCTAVE_API FloatComplex acosh (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
173 extern OCTAVE_API FloatComplex asin (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
174 extern OCTAVE_API FloatComplex asinh (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
175 extern OCTAVE_API FloatComplex atan (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
176 extern OCTAVE_API FloatComplex atanh (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
177 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
178 extern OCTAVE_API bool octave_is_NA (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
179 extern OCTAVE_API bool octave_is_NaN_or_NA (const FloatComplex& x); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
180 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
181 extern OCTAVE_API FloatComplex xmin (const FloatComplex& x, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 const FloatComplex& y); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
183 extern OCTAVE_API FloatComplex xmax (const FloatComplex& x, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
184 const FloatComplex& y); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
185 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
186 // These map reals to Complex. |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
187 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
188 extern OCTAVE_API Complex rc_acos (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
189 extern OCTAVE_API FloatComplex rc_acos (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
190 extern OCTAVE_API Complex rc_acosh (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
191 extern OCTAVE_API FloatComplex rc_acosh (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
192 extern OCTAVE_API Complex rc_asin (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
193 extern OCTAVE_API FloatComplex rc_asin (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
194 extern OCTAVE_API Complex rc_atanh (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
195 extern OCTAVE_API FloatComplex rc_atanh (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
196 extern OCTAVE_API Complex rc_log (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
197 extern OCTAVE_API FloatComplex rc_log (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
198 extern OCTAVE_API Complex rc_log2 (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
199 extern OCTAVE_API FloatComplex rc_log2 (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
200 extern OCTAVE_API Complex rc_log10 (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
201 extern OCTAVE_API FloatComplex rc_log10 (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
202 extern OCTAVE_API Complex rc_sqrt (double); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
203 extern OCTAVE_API FloatComplex rc_sqrt (float); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
204 |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
205 // Some useful tests, that are commonly repeated. |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
206 // Test for a finite integer. |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
207 inline bool |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
208 xisinteger (double x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
209 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
210 return xfinite (x) && x == xround (x); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
211 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
212 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
213 inline bool |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
214 xisinteger (float x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
215 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
216 return xfinite (x) && x == xround (x); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
217 } |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
218 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11525
diff
changeset
|
219 // Test for negative sign. |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
220 extern OCTAVE_API bool xnegative_sign (double x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
221 extern OCTAVE_API bool xnegative_sign (float x); |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
222 |
13756
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13737
diff
changeset
|
223 // Test for positive sign. |
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13737
diff
changeset
|
224 inline bool xpositive_sign (double x) { return ! xnegative_sign (x); } |
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13737
diff
changeset
|
225 inline bool xpositive_sign (float x) { return ! xnegative_sign (x); } |
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13737
diff
changeset
|
226 |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
227 // Some old rounding functions. |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
228 |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
229 extern OCTAVE_API octave_idx_type NINTbig (double x); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
230 extern OCTAVE_API octave_idx_type NINTbig (float x); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
231 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
232 extern OCTAVE_API int NINT (double x); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
233 extern OCTAVE_API int NINT (float x); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
234 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
235 template <typename T> |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
236 T |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
237 X_NINT (T x) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
238 { |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
15487
diff
changeset
|
239 return (xfinite (x) ? xfloor (x + 0.5) : x); |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
240 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
241 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
242 inline OCTAVE_API double D_NINT (double x) { return X_NINT (x); } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
243 inline OCTAVE_API float F_NINT (float x) { return X_NINT (x); } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
244 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
245 // Template functions can have either float or double arguments. |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
246 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
247 template <typename T> |
11212
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
248 bool |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
249 xisnan (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
250 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
251 return (xisnan (real (x)) || xisnan (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
252 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
253 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
254 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
255 bool |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
256 xfinite (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
257 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
258 return (xfinite (real (x)) && xfinite (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
259 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
260 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
261 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
262 bool |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
263 xisinf (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
264 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
265 return (xisinf (real (x)) || xisinf (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
266 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
267 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
268 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
269 std::complex<T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
270 fix (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
271 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
272 return std::complex<T> (fix (real (x)), fix (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
273 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
274 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
275 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
276 std::complex<T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
277 ceil (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
278 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
279 return std::complex<T> (xceil (real (x)), xceil (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
280 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
281 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
282 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
283 std::complex<T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
284 floor (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
285 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
286 return std::complex<T> (xfloor (real (x)), xfloor (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
287 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
288 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
289 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
290 std::complex<T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
291 xround (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
292 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
293 return std::complex<T> (xround (real (x)), xround (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
294 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
295 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
296 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
297 std::complex<T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
298 xroundb (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
299 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
300 return std::complex<T> (xroundb (real (x)), xroundb (imag (x))); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
301 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
302 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
303 template <typename T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
304 std::complex<T> |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
305 signum (const std::complex<T>& x) |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
306 { |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
307 T tmp = abs (x); |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
308 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
309 return tmp == 0 ? 0.0 : x / tmp; |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
310 } |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
311 |
ce27d6f4e134
use templates and inline for more lo-mappers functionos
John W. Eaton <jwe@octave.org>
parents:
11211
diff
changeset
|
312 template <typename T> |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
313 T |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
314 xmod (T x, T y) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
315 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
316 T retval; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
317 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
318 if (y == 0) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
319 retval = x; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
320 else |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
321 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
322 T q = x / y; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
323 |
11361
140c8fbe8b0b
use correct types in mod template function
John W. Eaton <jwe@octave.org>
parents:
11237
diff
changeset
|
324 T n = xfloor (q); |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
325 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
326 if (X_NINT (y) != y) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
327 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
328 if (X_NINT (q) == q) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
329 n = q; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
330 else |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
331 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
332 if (x >= -1 && x <= 1) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
333 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
334 if (std::abs (q - X_NINT (q)) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
335 < std::numeric_limits<T>::epsilon ()) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
336 n = X_NINT (q); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
337 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
338 else |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
339 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
340 if (std::abs ((q - X_NINT (q))/ X_NINT (q)) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
341 < std::numeric_limits<T>::epsilon ()) |
11361
140c8fbe8b0b
use correct types in mod template function
John W. Eaton <jwe@octave.org>
parents:
11237
diff
changeset
|
342 n = X_NINT (q); |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
343 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
344 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
345 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
346 |
11397
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
347 // Prevent use of extra precision. |
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
348 volatile T tmp = y * n; |
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
349 |
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
350 retval = x - tmp; |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
351 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
352 |
11213
009d16b010fa
lo-mappers.cc (xmod, xrem): don't copy sign if result is zero
John W. Eaton <jwe@octave.org>
parents:
11212
diff
changeset
|
353 if (x != y && y != 0 && retval != 0) |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
354 retval = xcopysign (retval, y); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
355 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
356 return retval; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
357 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
358 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
359 template <typename T> |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
360 T |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
361 xrem (T x, T y) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
362 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
363 T retval; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
364 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
365 if (y == 0) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
366 retval = x; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
367 else |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
368 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
369 T q = x / y; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
370 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
371 T n = xtrunc (q); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
372 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
373 if (X_NINT (y) != y) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
374 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
375 if (X_NINT (q) == q) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
376 n = q; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
377 else |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
378 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
379 if (x >= -1 && x <= 1) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
380 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
381 if (std::abs (q - X_NINT (q)) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
382 < std::numeric_limits<T>::epsilon ()) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
383 n = X_NINT (q); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
384 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
385 else |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
386 { |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
387 if (std::abs ((q - X_NINT (q))/ X_NINT (q)) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
388 < std::numeric_limits<T>::epsilon ()) |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
389 n = X_NINT (q); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
390 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
391 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
392 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
393 |
11397
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
394 // Prevent use of extra precision. |
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
395 volatile T tmp = y * n; |
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
396 |
57868a21170e
lo-mappers.h (xrem, xmod): prevent use of extra precision
John W. Eaton <jwe@octave.org>
parents:
11361
diff
changeset
|
397 retval = x - tmp; |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
398 } |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
399 |
11213
009d16b010fa
lo-mappers.cc (xmod, xrem): don't copy sign if result is zero
John W. Eaton <jwe@octave.org>
parents:
11212
diff
changeset
|
400 if (x != y && y != 0 && retval != 0) |
11211
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
401 retval = xcopysign (retval, x); |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
402 |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
403 return retval; |
2554b4a0806e
use templates for some lo-mappers functions
John W. Eaton <jwe@octave.org>
parents:
11209
diff
changeset
|
404 } |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
405 |
15487
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
406 template <typename T> |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
407 T |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
408 xsignbit (T x) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
409 { |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
410 return signbit (x); |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
411 } |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15409
diff
changeset
|
412 |
1967 | 413 #endif |