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-cm.h" |
|
28 #include "mx-cm-m.h" |
4544
|
29 #include "mx-nda-cnda.h" |
|
30 #include "mx-cnda-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-typeinfo.h" |
|
38 #include "ops.h" |
|
39 #include "xdiv.h" |
|
40 #include "xpow.h" |
|
41 |
|
42 // matrix by complex matrix ops. |
|
43 |
4550
|
44 DEFNDBINOP_OP (add, matrix, complex_matrix, array, complex_array, +) |
|
45 DEFNDBINOP_OP (sub, matrix, complex_matrix, array, complex_array, -) |
4543
|
46 |
2928
|
47 DEFBINOP_OP (mul, matrix, complex_matrix, *) |
5785
|
48 |
|
49 DEFBINOP (div, matrix, complex_matrix) |
|
50 { |
|
51 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); |
|
52 MatrixType typ = v2.matrix_type (); |
|
53 |
|
54 ComplexMatrix ret = xdiv (v1.matrix_value (), |
|
55 v2.complex_matrix_value (), typ); |
|
56 |
|
57 v2.matrix_type (typ); |
|
58 return ret; |
|
59 } |
2928
|
60 |
|
61 DEFBINOPX (pow, matrix, complex_matrix) |
|
62 { |
|
63 error ("can't do A ^ B for A and B both matrices"); |
|
64 return octave_value (); |
|
65 } |
|
66 |
5785
|
67 DEFBINOP (ldiv, matrix, complex_matrix) |
|
68 { |
|
69 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); |
|
70 MatrixType typ = v1.matrix_type (); |
|
71 |
|
72 ComplexMatrix ret = xleftdiv (v1.matrix_value (), |
|
73 v2.complex_matrix_value (), typ); |
|
74 |
|
75 v1.matrix_type (typ); |
|
76 return ret; |
|
77 } |
2928
|
78 |
4550
|
79 DEFNDBINOP_FN (lt, matrix, complex_matrix, array, complex_array, mx_el_lt) |
|
80 DEFNDBINOP_FN (le, matrix, complex_matrix, array, complex_array, mx_el_le) |
|
81 DEFNDBINOP_FN (eq, matrix, complex_matrix, array, complex_array, mx_el_eq) |
|
82 DEFNDBINOP_FN (ge, matrix, complex_matrix, array, complex_array, mx_el_ge) |
|
83 DEFNDBINOP_FN (gt, matrix, complex_matrix, array, complex_array, mx_el_gt) |
|
84 DEFNDBINOP_FN (ne, matrix, complex_matrix, array, complex_array, mx_el_ne) |
2928
|
85 |
4550
|
86 DEFNDBINOP_FN (el_mul, matrix, complex_matrix, array, complex_array, product) |
|
87 DEFNDBINOP_FN (el_div, matrix, complex_matrix, array, complex_array, quotient) |
|
88 DEFNDBINOP_FN (el_pow, matrix, complex_matrix, array, complex_array, elem_xpow) |
2928
|
89 |
|
90 DEFBINOP (el_ldiv, matrix, complex_matrix) |
|
91 { |
|
92 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&); |
|
93 |
4550
|
94 return quotient (v2.complex_array_value (), v1.array_value ()); |
2928
|
95 } |
|
96 |
4550
|
97 DEFNDBINOP_FN (el_and, matrix, complex_matrix, array, complex_array, mx_el_and) |
|
98 DEFNDBINOP_FN (el_or, matrix, complex_matrix, array, complex_array, mx_el_or) |
2928
|
99 |
4915
|
100 DEFNDCATOP_FN (m_cm, matrix, complex_matrix, array, complex_array, concat) |
|
101 |
2928
|
102 DEFCONV (complex_matrix_conv, matrix, complex_matrix) |
|
103 { |
|
104 CAST_CONV_ARG (const octave_matrix&); |
|
105 |
4543
|
106 return new octave_complex_matrix (ComplexNDArray (v.array_value ())); |
2928
|
107 } |
|
108 |
|
109 void |
|
110 install_m_cm_ops (void) |
|
111 { |
3538
|
112 INSTALL_BINOP (op_add, octave_matrix, octave_complex_matrix, add); |
|
113 INSTALL_BINOP (op_sub, octave_matrix, octave_complex_matrix, sub); |
|
114 INSTALL_BINOP (op_mul, octave_matrix, octave_complex_matrix, mul); |
|
115 INSTALL_BINOP (op_div, octave_matrix, octave_complex_matrix, div); |
|
116 INSTALL_BINOP (op_pow, octave_matrix, octave_complex_matrix, pow); |
|
117 INSTALL_BINOP (op_ldiv, octave_matrix, octave_complex_matrix, ldiv); |
|
118 INSTALL_BINOP (op_lt, octave_matrix, octave_complex_matrix, lt); |
|
119 INSTALL_BINOP (op_le, octave_matrix, octave_complex_matrix, le); |
|
120 INSTALL_BINOP (op_eq, octave_matrix, octave_complex_matrix, eq); |
|
121 INSTALL_BINOP (op_ge, octave_matrix, octave_complex_matrix, ge); |
|
122 INSTALL_BINOP (op_gt, octave_matrix, octave_complex_matrix, gt); |
|
123 INSTALL_BINOP (op_ne, octave_matrix, octave_complex_matrix, ne); |
|
124 INSTALL_BINOP (op_el_mul, octave_matrix, octave_complex_matrix, el_mul); |
|
125 INSTALL_BINOP (op_el_div, octave_matrix, octave_complex_matrix, el_div); |
|
126 INSTALL_BINOP (op_el_pow, octave_matrix, octave_complex_matrix, el_pow); |
|
127 INSTALL_BINOP (op_el_ldiv, octave_matrix, octave_complex_matrix, el_ldiv); |
|
128 INSTALL_BINOP (op_el_and, octave_matrix, octave_complex_matrix, el_and); |
|
129 INSTALL_BINOP (op_el_or, octave_matrix, octave_complex_matrix, el_or); |
2928
|
130 |
4915
|
131 INSTALL_CATOP (octave_matrix, octave_complex_matrix, m_cm); |
|
132 |
2928
|
133 INSTALL_ASSIGNCONV (octave_matrix, octave_complex_matrix, octave_complex_matrix); |
|
134 |
3540
|
135 INSTALL_WIDENOP (octave_matrix, octave_complex_matrix, complex_matrix_conv); |
2928
|
136 } |
|
137 |
|
138 /* |
|
139 ;;; Local Variables: *** |
|
140 ;;; mode: C++ *** |
|
141 ;;; End: *** |
|
142 */ |