annotate liboctave/oct-cmplx.h @ 8874:bd1b1fe9c6e9 ss-3-1-53

bump version info for snapshot
author John W. Eaton <jwe@octave.org>
date Wed, 25 Feb 2009 18:35:47 -0500
parents 9f7ce4bf7650
children eb63fbe60fab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1648
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
1 /*
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1995, 1996, 1997, 2000, 2001, 2004, 2005, 2007
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 John W. Eaton
1648
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
5
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
7
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
11 option) any later version.
1648
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
12
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
16 for more details.
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
17
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
20 <http://www.gnu.org/licenses/>.
1648
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
21
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
22 */
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
23
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_oct_cmplx_h)
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
25 #define octave_oct_cmplx_h 1
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
26
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
27 #include <complex>
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
28
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 2847
diff changeset
29 typedef std::complex<double> Complex;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
30 typedef std::complex<float> FloatComplex;
1648
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
31
8751
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
32 // The default comparison of complex number is to compare by abs, then by arg.
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
33 // FIXME: this could be speeded up significantly.
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
34 template <class T>
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
35 inline bool operator < (const std::complex<T>& a,
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
36 const std::complex<T>& b)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
37 {
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
38 T ax = std::abs (a), bx = std::abs (b);
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
39 return ax < bx || (ax == bx && std::arg (a) < std::arg (b));
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
40 }
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
41
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
42 template <class T>
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
43 inline bool operator > (const std::complex<T>& a,
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
44 const std::complex<T>& b)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
45 {
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
46 T ax = std::abs (a), bx = std::abs (b);
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
47 return ax > bx || (ax == bx && std::arg (a) > std::arg (b));
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
48 }
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
49
1648
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
50 #endif
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
51
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
52 /*
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
53 ;;; Local Variables: ***
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
54 ;;; mode: C++ ***
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
55 ;;; End: ***
65ef5beea500 [project @ 1995-12-20 06:43:29 by jwe]
jwe
parents:
diff changeset
56 */