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