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