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-complex.h" |
|
32 #include "ov-cx-mat.h" |
|
33 #include "ov-typeinfo.h" |
|
34 #include "ops.h" |
|
35 #include "xdiv.h" |
|
36 #include "xpow.h" |
|
37 |
|
38 // complex scalar by complex matrix ops. |
|
39 |
4550
|
40 DEFNDBINOP_OP (add, complex, complex_matrix, complex, complex_array, +) |
|
41 DEFNDBINOP_OP (sub, complex, complex_matrix, complex, complex_array, -) |
|
42 DEFNDBINOP_OP (mul, complex, complex_matrix, complex, complex_array, *) |
2928
|
43 |
|
44 DEFBINOP (div, complex, complex_matrix) |
|
45 { |
3766
|
46 CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); |
|
47 |
|
48 ComplexMatrix m1 = v1.complex_matrix_value (); |
|
49 ComplexMatrix m2 = v2.complex_matrix_value (); |
5785
|
50 MatrixType typ = v2.matrix_type (); |
3766
|
51 |
5785
|
52 ComplexMatrix ret = xdiv (m1, m2, typ); |
|
53 |
|
54 v2.matrix_type (typ); |
|
55 return ret; |
2928
|
56 } |
|
57 |
|
58 DEFBINOP_FN (pow, complex, complex_matrix, xpow) |
|
59 |
|
60 DEFBINOP (ldiv, complex, complex_matrix) |
|
61 { |
|
62 CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); |
|
63 |
|
64 Complex d = v1.complex_value (); |
|
65 |
|
66 if (d == 0.0) |
|
67 gripe_divide_by_zero (); |
|
68 |
4550
|
69 return octave_value (v2.complex_array_value () / d); |
2928
|
70 } |
|
71 |
4550
|
72 DEFNDBINOP_FN (lt, complex, complex_matrix, complex, complex_array, mx_el_lt) |
|
73 DEFNDBINOP_FN (le, complex, complex_matrix, complex, complex_array, mx_el_le) |
|
74 DEFNDBINOP_FN (eq, complex, complex_matrix, complex, complex_array, mx_el_eq) |
|
75 DEFNDBINOP_FN (ge, complex, complex_matrix, complex, complex_array, mx_el_ge) |
|
76 DEFNDBINOP_FN (gt, complex, complex_matrix, complex, complex_array, mx_el_gt) |
|
77 DEFNDBINOP_FN (ne, complex, complex_matrix, complex, complex_array, mx_el_ne) |
2928
|
78 |
4550
|
79 DEFNDBINOP_OP (el_mul, complex, complex_matrix, complex, complex_array, *) |
|
80 DEFNDBINOP_FN (el_div, complex, complex_matrix, complex, complex_array, x_el_div) |
|
81 DEFNDBINOP_FN (el_pow, complex, complex_matrix, complex, complex_array, elem_xpow) |
2928
|
82 |
|
83 DEFBINOP (el_ldiv, complex, complex_matrix) |
|
84 { |
|
85 CAST_BINOP_ARGS (const octave_complex&, const octave_complex_matrix&); |
|
86 |
|
87 Complex d = v1.complex_value (); |
|
88 |
|
89 if (d == 0.0) |
|
90 gripe_divide_by_zero (); |
|
91 |
4550
|
92 return octave_value (v2.complex_array_value () / d); |
2928
|
93 } |
|
94 |
4550
|
95 DEFNDBINOP_FN (el_and, complex, complex_matrix, complex, complex_array, mx_el_and) |
|
96 DEFNDBINOP_FN (el_or, complex, complex_matrix, complex, complex_array, mx_el_or) |
2928
|
97 |
4915
|
98 DEFNDCATOP_FN (cs_cm, complex, complex_matrix, complex_array, complex_array, concat) |
|
99 |
2928
|
100 DEFCONV (complex_matrix_conv, complex, complex_matrix) |
|
101 { |
|
102 CAST_CONV_ARG (const octave_complex&); |
|
103 |
|
104 return new octave_complex_matrix (v.complex_matrix_value ()); |
|
105 } |
|
106 |
|
107 void |
|
108 install_cs_cm_ops (void) |
|
109 { |
3538
|
110 INSTALL_BINOP (op_add, octave_complex, octave_complex_matrix, add); |
|
111 INSTALL_BINOP (op_sub, octave_complex, octave_complex_matrix, sub); |
|
112 INSTALL_BINOP (op_mul, octave_complex, octave_complex_matrix, mul); |
|
113 INSTALL_BINOP (op_div, octave_complex, octave_complex_matrix, div); |
|
114 INSTALL_BINOP (op_pow, octave_complex, octave_complex_matrix, pow); |
|
115 INSTALL_BINOP (op_ldiv, octave_complex, octave_complex_matrix, ldiv); |
|
116 INSTALL_BINOP (op_lt, octave_complex, octave_complex_matrix, lt); |
|
117 INSTALL_BINOP (op_le, octave_complex, octave_complex_matrix, le); |
|
118 INSTALL_BINOP (op_eq, octave_complex, octave_complex_matrix, eq); |
|
119 INSTALL_BINOP (op_ge, octave_complex, octave_complex_matrix, ge); |
|
120 INSTALL_BINOP (op_gt, octave_complex, octave_complex_matrix, gt); |
|
121 INSTALL_BINOP (op_ne, octave_complex, octave_complex_matrix, ne); |
|
122 INSTALL_BINOP (op_el_mul, octave_complex, octave_complex_matrix, el_mul); |
|
123 INSTALL_BINOP (op_el_div, octave_complex, octave_complex_matrix, el_div); |
|
124 INSTALL_BINOP (op_el_pow, octave_complex, octave_complex_matrix, el_pow); |
|
125 INSTALL_BINOP (op_el_ldiv, octave_complex, octave_complex_matrix, el_ldiv); |
|
126 INSTALL_BINOP (op_el_and, octave_complex, octave_complex_matrix, el_and); |
|
127 INSTALL_BINOP (op_el_or, octave_complex, octave_complex_matrix, el_or); |
2928
|
128 |
4915
|
129 INSTALL_CATOP (octave_complex, octave_complex_matrix, cs_cm); |
|
130 |
2928
|
131 INSTALL_ASSIGNCONV (octave_complex, octave_complex_matrix, octave_complex_matrix); |
|
132 |
3540
|
133 INSTALL_WIDENOP (octave_complex, octave_complex_matrix, complex_matrix_conv); |
2928
|
134 } |
|
135 |
|
136 /* |
|
137 ;;; Local Variables: *** |
|
138 ;;; mode: C++ *** |
|
139 ;;; End: *** |
|
140 */ |