Mercurial > octave
annotate src/OPERATORS/op-cs-m.cc @ 9588:319e2ab9b8ae
warn about the complex comparison ops
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 21:48:19 +0200 |
parents | a1dbe9d80eee |
children | ac4b97c6bf8b |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
4 2007 John W. Eaton | |
2928 | 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. | |
2928 | 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/>. | |
2928 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
4544 | 28 #include "mx-cs-nda.h" |
29 #include "mx-nda-cs.h" | |
30 #include "mx-cs-nda.h" | |
31 #include "mx-nda-cs.h" | |
2928 | 32 |
33 #include "gripes.h" | |
4055 | 34 #include "oct-obj.h" |
2928 | 35 #include "ov.h" |
36 #include "ov-complex.h" | |
37 #include "ov-cx-mat.h" | |
38 #include "ov-re-mat.h" | |
39 #include "ov-typeinfo.h" | |
40 #include "ops.h" | |
41 #include "xdiv.h" | |
42 #include "xpow.h" | |
43 | |
44 // complex scalar by matrix ops. | |
45 | |
4543 | 46 DEFNDBINOP_OP (add, complex, matrix, complex, array, +) |
47 DEFNDBINOP_OP (sub, complex, matrix, complex, array, -) | |
48 DEFNDBINOP_OP (mul, complex, matrix, complex, array, *) | |
2928 | 49 |
50 DEFBINOP (div, complex, matrix) | |
51 { | |
3766 | 52 CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); |
53 | |
54 ComplexMatrix m1 = v1.complex_matrix_value (); | |
55 Matrix m2 = v2.matrix_value (); | |
5785 | 56 MatrixType typ = v2.matrix_type (); |
3766 | 57 |
5785 | 58 ComplexMatrix ret = xdiv (m1, m2, typ); |
59 | |
60 v2.matrix_type (typ); | |
61 return ret; | |
2928 | 62 } |
63 | |
64 DEFBINOP_FN (pow, complex, matrix, xpow) | |
65 | |
66 DEFBINOP (ldiv, complex, matrix) | |
67 { | |
68 CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); | |
69 | |
70 Complex d = v1.complex_value (); | |
71 | |
72 if (d == 0.0) | |
73 gripe_divide_by_zero (); | |
74 | |
4543 | 75 return octave_value (v2.array_value () / d); |
2928 | 76 } |
77 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
78 DEFNDCMPLXCMPOP_FN (lt, complex, matrix, complex, array, mx_el_lt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
79 DEFNDCMPLXCMPOP_FN (le, complex, matrix, complex, array, mx_el_le) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
80 DEFNDCMPLXCMPOP_FN (eq, complex, matrix, complex, array, mx_el_eq) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
81 DEFNDCMPLXCMPOP_FN (ge, complex, matrix, complex, array, mx_el_ge) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
82 DEFNDCMPLXCMPOP_FN (gt, complex, matrix, complex, array, mx_el_gt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
83 DEFNDCMPLXCMPOP_FN (ne, complex, matrix, complex, array, mx_el_ne) |
2928 | 84 |
4543 | 85 DEFNDBINOP_OP (el_mul, complex, matrix, complex, array, *) |
86 DEFNDBINOP_FN (el_div, complex, matrix, complex, array, x_el_div) | |
87 DEFNDBINOP_FN (el_pow, complex, matrix, complex, array, elem_xpow) | |
2928 | 88 |
89 DEFBINOP (el_ldiv, complex, matrix) | |
90 { | |
91 CAST_BINOP_ARGS (const octave_complex&, const octave_matrix&); | |
92 | |
93 Complex d = v1.complex_value (); | |
94 | |
95 if (d == 0.0) | |
96 gripe_divide_by_zero (); | |
97 | |
4543 | 98 return octave_value (v2.array_value () / d); |
2928 | 99 } |
100 | |
4543 | 101 DEFNDBINOP_FN (el_and, complex, matrix, complex, array, mx_el_and) |
102 DEFNDBINOP_FN (el_or, complex, matrix, complex, array, mx_el_or) | |
2928 | 103 |
4915 | 104 DEFNDCATOP_FN (cs_m, complex, matrix, complex_array, array, concat) |
105 | |
2928 | 106 void |
107 install_cs_m_ops (void) | |
108 { | |
3538 | 109 INSTALL_BINOP (op_add, octave_complex, octave_matrix, add); |
110 INSTALL_BINOP (op_sub, octave_complex, octave_matrix, sub); | |
111 INSTALL_BINOP (op_mul, octave_complex, octave_matrix, mul); | |
112 INSTALL_BINOP (op_div, octave_complex, octave_matrix, div); | |
113 INSTALL_BINOP (op_pow, octave_complex, octave_matrix, pow); | |
114 INSTALL_BINOP (op_ldiv, octave_complex, octave_matrix, ldiv); | |
115 INSTALL_BINOP (op_lt, octave_complex, octave_matrix, lt); | |
116 INSTALL_BINOP (op_le, octave_complex, octave_matrix, le); | |
117 INSTALL_BINOP (op_eq, octave_complex, octave_matrix, eq); | |
118 INSTALL_BINOP (op_ge, octave_complex, octave_matrix, ge); | |
119 INSTALL_BINOP (op_gt, octave_complex, octave_matrix, gt); | |
120 INSTALL_BINOP (op_ne, octave_complex, octave_matrix, ne); | |
121 INSTALL_BINOP (op_el_mul, octave_complex, octave_matrix, el_mul); | |
122 INSTALL_BINOP (op_el_div, octave_complex, octave_matrix, el_div); | |
123 INSTALL_BINOP (op_el_pow, octave_complex, octave_matrix, el_pow); | |
124 INSTALL_BINOP (op_el_ldiv, octave_complex, octave_matrix, el_ldiv); | |
125 INSTALL_BINOP (op_el_and, octave_complex, octave_matrix, el_and); | |
126 INSTALL_BINOP (op_el_or, octave_complex, octave_matrix, el_or); | |
2928 | 127 |
4915 | 128 INSTALL_CATOP (octave_complex, octave_matrix, cs_m); |
129 | |
2928 | 130 INSTALL_ASSIGNCONV (octave_complex, octave_matrix, octave_complex_matrix); |
131 } | |
132 | |
133 /* | |
134 ;;; Local Variables: *** | |
135 ;;; mode: C++ *** | |
136 ;;; End: *** | |
137 */ |