Mercurial > octave
annotate src/OPERATORS/op-cm-s.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 | 1beb23d2b892 |
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 | |
28 #include "mx-cm-s.h" | |
4544 | 29 #include "mx-cnda-s.h" |
2928 | 30 |
31 #include "gripes.h" | |
4055 | 32 #include "oct-obj.h" |
2928 | 33 #include "ov.h" |
34 #include "ov-cx-mat.h" | |
3766 | 35 #include "ov-re-mat.h" |
2928 | 36 #include "ov-scalar.h" |
37 #include "ov-typeinfo.h" | |
38 #include "ops.h" | |
39 #include "xdiv.h" | |
40 #include "xpow.h" | |
41 | |
42 // complex matrix by scalar ops. | |
43 | |
4550 | 44 DEFNDBINOP_OP (add, complex_matrix, scalar, complex_array, scalar, +) |
45 DEFNDBINOP_OP (sub, complex_matrix, scalar, complex_array, scalar, -) | |
46 DEFNDBINOP_OP (mul, complex_matrix, scalar, complex_array, scalar, *) | |
2928 | 47 |
48 DEFBINOP (div, complex_matrix, scalar) | |
49 { | |
50 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); | |
51 | |
52 double d = v2.double_value (); | |
53 | |
54 if (d == 0.0) | |
55 gripe_divide_by_zero (); | |
56 | |
4550 | 57 return octave_value (v1.complex_array_value () / d); |
2928 | 58 } |
59 | |
60 DEFBINOP_FN (pow, complex_matrix, scalar, xpow) | |
61 | |
62 DEFBINOP (ldiv, complex_matrix, scalar) | |
63 { | |
3766 | 64 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); |
65 | |
66 ComplexMatrix m1 = v1.complex_matrix_value (); | |
67 Matrix m2 = v2.matrix_value (); | |
5785 | 68 MatrixType typ = v1.matrix_type (); |
3766 | 69 |
5785 | 70 ComplexMatrix ret = xleftdiv (m1, m2, typ); |
71 | |
72 v1.matrix_type (typ); | |
73 return ret; | |
2928 | 74 } |
75 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
76 DEFNDCMPLXCMPOP_FN (lt, complex_matrix, scalar, complex_array, scalar, mx_el_lt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
77 DEFNDCMPLXCMPOP_FN (le, complex_matrix, scalar, complex_array, scalar, mx_el_le) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
78 DEFNDCMPLXCMPOP_FN (eq, complex_matrix, scalar, complex_array, scalar, mx_el_eq) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
79 DEFNDCMPLXCMPOP_FN (ge, complex_matrix, scalar, complex_array, scalar, mx_el_ge) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
80 DEFNDCMPLXCMPOP_FN (gt, complex_matrix, scalar, complex_array, scalar, mx_el_gt) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
81 DEFNDCMPLXCMPOP_FN (ne, complex_matrix, scalar, complex_array, scalar, mx_el_ne) |
2928 | 82 |
7275 | 83 DEFNDBINOP_OP (el_mul, complex_matrix, scalar, complex_array, scalar, *) |
2928 | 84 |
85 DEFBINOP (el_div, complex_matrix, scalar) | |
86 { | |
87 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); | |
88 | |
89 double d = v2.double_value (); | |
90 | |
91 if (d == 0.0) | |
92 gripe_divide_by_zero (); | |
93 | |
4550 | 94 return octave_value (v1.complex_array_value () / d); |
2928 | 95 } |
96 | |
4550 | 97 DEFNDBINOP_FN (el_pow, complex_matrix, scalar, complex_array, scalar, elem_xpow) |
2928 | 98 |
99 DEFBINOP (el_ldiv, complex_matrix, scalar) | |
100 { | |
101 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_scalar&); | |
102 | |
4550 | 103 return x_el_div (v2.double_value (), v1.complex_array_value ()); |
2928 | 104 } |
105 | |
4550 | 106 DEFNDBINOP_FN (el_and, complex_matrix, scalar, complex_array, scalar, mx_el_and) |
107 DEFNDBINOP_FN (el_or, complex_matrix, scalar, complex_array, scalar, mx_el_or) | |
2928 | 108 |
4915 | 109 DEFNDCATOP_FN (cm_s, complex_matrix, scalar, complex_array, array, concat) |
110 | |
4686 | 111 DEFNDASSIGNOP_FN (assign, complex_matrix, scalar, complex_array, assign) |
2928 | 112 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
7275
diff
changeset
|
113 DEFNDASSIGNOP_OP (assign_mul, complex_matrix, scalar, scalar, *=) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
7275
diff
changeset
|
114 DEFNDASSIGNOP_OP (assign_div, complex_matrix, scalar, scalar, /=) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
7275
diff
changeset
|
115 |
2928 | 116 void |
117 install_cm_s_ops (void) | |
118 { | |
3538 | 119 INSTALL_BINOP (op_add, octave_complex_matrix, octave_scalar, add); |
120 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_scalar, sub); | |
121 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_scalar, mul); | |
122 INSTALL_BINOP (op_div, octave_complex_matrix, octave_scalar, div); | |
123 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_scalar, pow); | |
124 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_scalar, ldiv); | |
125 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_scalar, lt); | |
126 INSTALL_BINOP (op_le, octave_complex_matrix, octave_scalar, le); | |
127 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_scalar, eq); | |
128 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_scalar, ge); | |
129 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_scalar, gt); | |
130 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_scalar, ne); | |
131 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_scalar, el_mul); | |
132 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_scalar, el_div); | |
133 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_scalar, el_pow); | |
134 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_scalar, el_ldiv); | |
135 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_scalar, el_and); | |
136 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_scalar, el_or); | |
2928 | 137 |
4915 | 138 INSTALL_CATOP (octave_complex_matrix, octave_scalar, cm_s); |
139 | |
3538 | 140 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_scalar, assign); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
7275
diff
changeset
|
141 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
7275
diff
changeset
|
142 INSTALL_ASSIGNOP (op_mul_eq, octave_complex_matrix, octave_scalar, assign_mul); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
7275
diff
changeset
|
143 INSTALL_ASSIGNOP (op_div_eq, octave_complex_matrix, octave_scalar, assign_div); |
2928 | 144 } |
145 | |
146 /* | |
147 ;;; Local Variables: *** | |
148 ;;; mode: C++ *** | |
149 ;;; End: *** | |
150 */ |