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-typeinfo.h" |
|
33 #include "ops.h" |
|
34 #include "xdiv.h" |
|
35 #include "xpow.h" |
|
36 |
3203
|
37 // unary complex matrix ops. |
|
38 |
4550
|
39 DEFNDUNOP_OP (not, complex_matrix, complex_array, !) |
4965
|
40 DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */) |
4550
|
41 DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -) |
3203
|
42 |
|
43 DEFUNOP (transpose, complex_matrix) |
|
44 { |
|
45 CAST_UNOP_ARG (const octave_complex_matrix&); |
|
46 |
4673
|
47 if (v.ndims () > 2) |
|
48 { |
|
49 error ("transpose not defined for N-d objects"); |
|
50 return octave_value (); |
|
51 } |
|
52 else |
|
53 return octave_value (v.complex_matrix_value().transpose ()); |
3203
|
54 } |
|
55 |
|
56 DEFUNOP (hermitian, complex_matrix) |
|
57 { |
|
58 CAST_UNOP_ARG (const octave_complex_matrix&); |
|
59 |
4673
|
60 if (v.ndims () > 2) |
|
61 { |
|
62 error ("complex-conjugate transpose not defined for N-d objects"); |
|
63 return octave_value (); |
|
64 } |
|
65 else |
|
66 return octave_value (v.complex_matrix_value().hermitian ()); |
3203
|
67 } |
|
68 |
|
69 DEFNCUNOP_METHOD (incr, complex_matrix, increment) |
|
70 DEFNCUNOP_METHOD (decr, complex_matrix, decrement) |
|
71 |
2928
|
72 // complex matrix by complex matrix ops. |
|
73 |
4550
|
74 DEFNDBINOP_OP (add, complex_matrix, complex_matrix, complex_array, complex_array, +) |
|
75 DEFNDBINOP_OP (sub, complex_matrix, complex_matrix, complex_array, complex_array, -) |
4543
|
76 |
2928
|
77 DEFBINOP_OP (mul, complex_matrix, complex_matrix, *) |
|
78 DEFBINOP_FN (div, complex_matrix, complex_matrix, xdiv) |
|
79 |
|
80 DEFBINOPX (pow, complex_matrix, complex_matrix) |
|
81 { |
|
82 error ("can't do A ^ B for A and B both matrices"); |
|
83 return octave_value (); |
|
84 } |
|
85 |
|
86 DEFBINOP_FN (ldiv, complex_matrix, complex_matrix, xleftdiv) |
|
87 |
4550
|
88 DEFNDBINOP_FN (lt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_lt) |
|
89 DEFNDBINOP_FN (le, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_le) |
|
90 DEFNDBINOP_FN (eq, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_eq) |
|
91 DEFNDBINOP_FN (ge, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ge) |
|
92 DEFNDBINOP_FN (gt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_gt) |
|
93 DEFNDBINOP_FN (ne, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ne) |
2928
|
94 |
4550
|
95 DEFNDBINOP_FN (el_mul, complex_matrix, complex_matrix, complex_array, complex_array, product) |
|
96 DEFNDBINOP_FN (el_div, complex_matrix, complex_matrix, complex_array, complex_array, quotient) |
|
97 DEFNDBINOP_FN (el_pow, complex_matrix, complex_matrix, complex_array, complex_array, elem_xpow) |
2928
|
98 |
|
99 DEFBINOP (el_ldiv, complex_matrix, complex_matrix) |
|
100 { |
|
101 CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&); |
|
102 |
4550
|
103 return octave_value (quotient (v2.complex_array_value (), v1.complex_array_value ())); |
2928
|
104 } |
|
105 |
4550
|
106 DEFNDBINOP_FN (el_and, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_and) |
|
107 DEFNDBINOP_FN (el_or, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_or) |
2928
|
108 |
4915
|
109 DEFNDCATOP_FN (cm_cm, complex_matrix, complex_matrix, complex_array, complex_array, concat) |
|
110 |
4686
|
111 DEFNDASSIGNOP_FN (assign, complex_matrix, complex_matrix, complex_array, assign) |
2928
|
112 |
|
113 void |
|
114 install_cm_cm_ops (void) |
|
115 { |
3538
|
116 INSTALL_UNOP (op_not, octave_complex_matrix, not); |
4965
|
117 INSTALL_UNOP (op_uplus, octave_complex_matrix, uplus); |
3538
|
118 INSTALL_UNOP (op_uminus, octave_complex_matrix, uminus); |
|
119 INSTALL_UNOP (op_transpose, octave_complex_matrix, transpose); |
|
120 INSTALL_UNOP (op_hermitian, octave_complex_matrix, hermitian); |
3203
|
121 |
3538
|
122 INSTALL_NCUNOP (op_incr, octave_complex_matrix, incr); |
|
123 INSTALL_NCUNOP (op_decr, octave_complex_matrix, decr); |
3203
|
124 |
3538
|
125 INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex_matrix, add); |
|
126 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex_matrix, sub); |
|
127 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex_matrix, mul); |
|
128 INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex_matrix, div); |
|
129 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex_matrix, pow); |
|
130 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex_matrix, ldiv); |
|
131 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex_matrix, lt); |
|
132 INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex_matrix, le); |
|
133 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex_matrix, eq); |
|
134 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex_matrix, ge); |
|
135 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex_matrix, gt); |
|
136 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex_matrix, ne); |
|
137 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex_matrix, el_mul); |
|
138 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex_matrix, el_div); |
|
139 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex_matrix, el_pow); |
|
140 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex_matrix, el_ldiv); |
|
141 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex_matrix, el_and); |
|
142 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex_matrix, el_or); |
2928
|
143 |
4915
|
144 INSTALL_CATOP (octave_complex_matrix, octave_complex_matrix, cm_cm); |
|
145 |
3538
|
146 INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex_matrix, assign); |
2928
|
147 } |
|
148 |
|
149 /* |
|
150 ;;; Local Variables: *** |
|
151 ;;; mode: C++ *** |
|
152 ;;; End: *** |
|
153 */ |