2928
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2928
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include "gripes.h" |
4055
|
29 #include "oct-obj.h" |
2928
|
30 #include "ov.h" |
|
31 #include "ov-cx-mat.h" |
|
32 #include "ov-complex.h" |
|
33 #include "ov-typeinfo.h" |
|
34 #include "ops.h" |
|
35 #include "xdiv.h" |
|
36 #include "xpow.h" |
|
37 |
|
38 // complex matrix by complex scalar ops. |
|
39 |
4550
|
40 DEFNDBINOP_OP (add, complex_matrix, complex, complex_array, complex, +) |
|
41 DEFNDBINOP_OP (sub, complex_matrix, complex, complex_array, complex, -) |
|
42 DEFNDBINOP_OP (mul, complex_matrix, complex, complex_array, complex, *) |
2928
|
43 |
|
44 DEFBINOP (div, complex_matrix, complex) |
|
45 { |
|
46 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
47 |
|
48 Complex d = v2.complex_value (); |
|
49 |
|
50 if (d == 0.0) |
|
51 gripe_divide_by_zero (); |
|
52 |
4550
|
53 return octave_value (v1.complex_array_value () / d); |
2928
|
54 } |
|
55 |
|
56 DEFBINOP_FN (pow, complex_matrix, complex, xpow) |
|
57 |
|
58 DEFBINOP (ldiv, complex_matrix, complex) |
|
59 { |
3766
|
60 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
61 |
|
62 ComplexMatrix m1 = v1.complex_matrix_value (); |
|
63 ComplexMatrix m2 = v2.complex_matrix_value (); |
|
64 |
|
65 return octave_value (xleftdiv (m1, m2)); |
2928
|
66 } |
|
67 |
4550
|
68 DEFNDBINOP_FN (lt, complex_matrix, complex, complex_array, complex, mx_el_lt) |
|
69 DEFNDBINOP_FN (le, complex_matrix, complex, complex_array, complex, mx_el_le) |
|
70 DEFNDBINOP_FN (eq, complex_matrix, complex, complex_array, complex, mx_el_eq) |
|
71 DEFNDBINOP_FN (ge, complex_matrix, complex, complex_array, complex, mx_el_ge) |
|
72 DEFNDBINOP_FN (gt, complex_matrix, complex, complex_array, complex, mx_el_gt) |
|
73 DEFNDBINOP_FN (ne, complex_matrix, complex, complex_array, complex, mx_el_ne) |
2928
|
74 |
4550
|
75 DEFNDBINOP_OP (el_mul, complex_matrix, complex, complex_array, complex, *) |
2928
|
76 |
|
77 DEFBINOP (el_div, complex_matrix, complex) |
|
78 { |
|
79 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
80 |
|
81 Complex d = v2.complex_value (); |
|
82 |
|
83 if (d == 0.0) |
|
84 gripe_divide_by_zero (); |
|
85 |
4550
|
86 return octave_value (v1.complex_array_value () / d); |
2928
|
87 } |
|
88 |
4550
|
89 DEFNDBINOP_FN (el_pow, complex_matrix, complex, complex_array, complex, elem_xpow) |
2928
|
90 |
|
91 DEFBINOP (el_ldiv, complex_matrix, complex) |
|
92 { |
|
93 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&); |
|
94 |
4550
|
95 return x_el_div (v2.complex_value (), v1.complex_array_value ()); |
2928
|
96 } |
|
97 |
4550
|
98 DEFNDBINOP_FN (el_and, complex_matrix, complex, complex_array, complex, mx_el_and) |
|
99 DEFNDBINOP_FN (el_or, complex_matrix, complex, complex_array, complex, mx_el_or) |
2928
|
100 |
4915
|
101 DEFNDCATOP_FN (cm_cs, complex_matrix, complex, complex_array, complex_array, concat) |
|
102 |
4686
|
103 DEFNDASSIGNOP_FN (assign, complex_matrix, complex, complex_array, assign) |
2928
|
104 |
|
105 void |
|
106 install_cm_cs_ops (void) |
|
107 { |
3538
|
108 INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex, add); |
|
109 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex, sub); |
|
110 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex, mul); |
|
111 INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex, div); |
|
112 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex, pow); |
|
113 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex, ldiv); |
|
114 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex, lt); |
|
115 INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex, le); |
|
116 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex, eq); |
|
117 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex, ge); |
|
118 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex, gt); |
|
119 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex, ne); |
|
120 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex, el_mul); |
|
121 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex, el_div); |
|
122 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex, el_pow); |
|
123 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex, el_ldiv); |
|
124 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex, el_and); |
|
125 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex, el_or); |
2928
|
126 |
4915
|
127 INSTALL_CATOP (octave_complex_matrix, octave_complex, cm_cs); |
|
128 |
3538
|
129 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex, assign); |
2928
|
130 } |
|
131 |
|
132 /* |
|
133 ;;; Local Variables: *** |
|
134 ;;; mode: C++ *** |
|
135 ;;; End: *** |
|
136 */ |