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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2928
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2928
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "mx-m-cs.h" |
|
28 #include "mx-cs-m.h" |
4544
|
29 #include "mx-nda-cs.h" |
|
30 #include "mx-cs-nda.h" |
2928
|
31 |
|
32 #include "gripes.h" |
4055
|
33 #include "oct-obj.h" |
2928
|
34 #include "ov.h" |
|
35 #include "ov-re-mat.h" |
|
36 #include "ov-cx-mat.h" |
|
37 #include "ov-complex.h" |
|
38 #include "ov-typeinfo.h" |
|
39 #include "ops.h" |
|
40 #include "xdiv.h" |
|
41 #include "xpow.h" |
|
42 |
|
43 // matrix by complex scalar ops. |
|
44 |
4543
|
45 DEFNDBINOP_OP (add, matrix, complex, array, complex, +) |
|
46 DEFNDBINOP_OP (sub, matrix, complex, array, complex, -) |
|
47 DEFNDBINOP_OP (mul, matrix, complex, array, complex, *) |
2928
|
48 |
|
49 DEFBINOP (div, matrix, complex) |
|
50 { |
|
51 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
52 |
|
53 Complex d = v2.complex_value (); |
|
54 |
|
55 if (d == 0.0) |
|
56 gripe_divide_by_zero (); |
|
57 |
4543
|
58 return octave_value (v1.array_value () / d); |
2928
|
59 } |
|
60 |
|
61 DEFBINOP_FN (pow, matrix, complex, xpow) |
|
62 |
|
63 DEFBINOP (ldiv, matrix, complex) |
|
64 { |
3766
|
65 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
66 |
|
67 Matrix m1 = v1.matrix_value (); |
|
68 ComplexMatrix m2 = v2.complex_matrix_value (); |
5785
|
69 MatrixType typ = v1.matrix_type (); |
3766
|
70 |
5785
|
71 ComplexMatrix ret = xleftdiv (m1, m2, typ); |
|
72 |
|
73 v1.matrix_type (typ); |
|
74 return ret; |
2928
|
75 } |
|
76 |
4543
|
77 DEFNDBINOP_FN (lt, matrix, complex, array, complex, mx_el_lt) |
|
78 DEFNDBINOP_FN (le, matrix, complex, array, complex, mx_el_le) |
|
79 DEFNDBINOP_FN (eq, matrix, complex, array, complex, mx_el_eq) |
|
80 DEFNDBINOP_FN (ge, matrix, complex, array, complex, mx_el_ge) |
|
81 DEFNDBINOP_FN (gt, matrix, complex, array, complex, mx_el_gt) |
|
82 DEFNDBINOP_FN (ne, matrix, complex, array, complex, mx_el_ne) |
2928
|
83 |
4543
|
84 DEFNDBINOP_OP (el_mul, matrix, complex, array, complex, *) |
2928
|
85 |
|
86 DEFBINOP (el_div, matrix, complex) |
|
87 { |
|
88 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
89 |
|
90 Complex d = v2.complex_value (); |
|
91 |
|
92 if (d == 0.0) |
|
93 gripe_divide_by_zero (); |
|
94 |
4543
|
95 return octave_value (v1.array_value () / d); |
2928
|
96 } |
|
97 |
4543
|
98 DEFNDBINOP_FN (el_pow, matrix, complex, array, complex, elem_xpow) |
2928
|
99 |
|
100 DEFBINOP (el_ldiv, matrix, complex) |
|
101 { |
|
102 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex&); |
|
103 |
4543
|
104 return x_el_div (v2.complex_value (), v1.array_value ()); |
2928
|
105 } |
|
106 |
4543
|
107 DEFNDBINOP_FN (el_and, matrix, complex, array, complex, mx_el_and) |
|
108 DEFNDBINOP_FN (el_or, matrix, complex, array, complex, mx_el_or) |
2928
|
109 |
4915
|
110 DEFNDCATOP_FN (m_cs, matrix, complex, array, complex_array, concat) |
|
111 |
2928
|
112 void |
|
113 install_m_cs_ops (void) |
|
114 { |
3538
|
115 INSTALL_BINOP (op_add, octave_matrix, octave_complex, add); |
|
116 INSTALL_BINOP (op_sub, octave_matrix, octave_complex, sub); |
|
117 INSTALL_BINOP (op_mul, octave_matrix, octave_complex, mul); |
|
118 INSTALL_BINOP (op_div, octave_matrix, octave_complex, div); |
|
119 INSTALL_BINOP (op_pow, octave_matrix, octave_complex, pow); |
|
120 INSTALL_BINOP (op_ldiv, octave_matrix, octave_complex, ldiv); |
|
121 INSTALL_BINOP (op_lt, octave_matrix, octave_complex, lt); |
|
122 INSTALL_BINOP (op_le, octave_matrix, octave_complex, le); |
|
123 INSTALL_BINOP (op_eq, octave_matrix, octave_complex, eq); |
|
124 INSTALL_BINOP (op_ge, octave_matrix, octave_complex, ge); |
|
125 INSTALL_BINOP (op_gt, octave_matrix, octave_complex, gt); |
|
126 INSTALL_BINOP (op_ne, octave_matrix, octave_complex, ne); |
|
127 INSTALL_BINOP (op_el_mul, octave_matrix, octave_complex, el_mul); |
|
128 INSTALL_BINOP (op_el_div, octave_matrix, octave_complex, el_div); |
|
129 INSTALL_BINOP (op_el_pow, octave_matrix, octave_complex, el_pow); |
|
130 INSTALL_BINOP (op_el_ldiv, octave_matrix, octave_complex, el_ldiv); |
|
131 INSTALL_BINOP (op_el_and, octave_matrix, octave_complex, el_and); |
|
132 INSTALL_BINOP (op_el_or, octave_matrix, octave_complex, el_or); |
2928
|
133 |
4915
|
134 INSTALL_CATOP (octave_matrix, octave_complex, m_cs); |
|
135 |
2928
|
136 INSTALL_ASSIGNCONV (octave_matrix, octave_complex, octave_complex_matrix); |
|
137 } |
|
138 |
|
139 /* |
|
140 ;;; Local Variables: *** |
|
141 ;;; mode: C++ *** |
|
142 ;;; End: *** |
|
143 */ |