5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 Andy Adler |
|
5 |
|
6 Octave is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
5307
|
17 along with this program; see the file COPYING. If not, write to the |
|
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
5164
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "gripes.h" |
|
28 #include "oct-obj.h" |
|
29 #include "ov.h" |
|
30 #include "ov-typeinfo.h" |
|
31 #include "ops.h" |
|
32 |
|
33 #include "sparse-xdiv.h" |
|
34 #include "sparse-xpow.h" |
|
35 #include "ov-re-sparse.h" |
|
36 #include "ov-cx-sparse.h" |
|
37 |
|
38 #ifdef HAVE_CONFIG_H |
|
39 #include <config.h> |
|
40 #endif |
|
41 |
|
42 #include "gripes.h" |
|
43 #include "oct-obj.h" |
|
44 #include "ov.h" |
|
45 #include "ov-cx-mat.h" |
|
46 #include "ov-typeinfo.h" |
|
47 #include "ops.h" |
|
48 #include "xdiv.h" |
|
49 #include "xpow.h" |
|
50 |
|
51 // unary sparse complex matrix ops. |
|
52 |
|
53 DEFUNOP_OP (not, sparse_complex_matrix, !) |
|
54 DEFUNOP_OP (uplus, sparse_complex_matrix, /* no-op */) |
|
55 DEFUNOP_OP (uminus, sparse_complex_matrix, -) |
|
56 |
|
57 DEFUNOP (transpose, sparse_complex_matrix) |
|
58 { |
|
59 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
5322
|
60 return octave_value |
|
61 (v.sparse_complex_matrix_value().transpose (), |
|
62 v.sparse_type ().transpose ()); |
5164
|
63 } |
|
64 |
|
65 DEFUNOP (hermitian, sparse_complex_matrix) |
|
66 { |
|
67 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
5322
|
68 return octave_value |
|
69 (v.sparse_complex_matrix_value().hermitian (), |
|
70 v.sparse_type ().transpose ()); |
5164
|
71 } |
|
72 |
|
73 #if 0 |
|
74 DEFUNOP (incr, sparse_complex_matrix) |
|
75 { |
|
76 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
|
77 |
|
78 return octave_value (v.complex_matrix_value () .increment ()); |
|
79 } |
|
80 |
|
81 DEFUNOP (decr, sparse_complex_matrix) |
|
82 { |
|
83 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
|
84 |
|
85 return octave_value (v.complex_matrix_value () .decrement ()); |
|
86 } |
|
87 #endif |
|
88 |
|
89 // complex matrix by complex matrix ops. |
|
90 |
|
91 DEFBINOP_OP (add, sparse_complex_matrix, sparse_complex_matrix, +) |
|
92 DEFBINOP_OP (sub, sparse_complex_matrix, sparse_complex_matrix, -) |
|
93 |
|
94 DEFBINOP_OP (mul, sparse_complex_matrix, sparse_complex_matrix, *) |
|
95 |
5322
|
96 DEFBINOP (div, sparse_complex_matrix, sparse_complex_matrix) |
|
97 { |
|
98 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
99 octave_sparse_complex_matrix&); |
|
100 SparseType typ = v2.sparse_type (); |
|
101 SparseComplexMatrix ret = xdiv (v1.sparse_complex_matrix_value (), |
|
102 v2.sparse_complex_matrix_value (), typ); |
|
103 |
|
104 v2.sparse_type (typ); |
|
105 return ret; |
|
106 } |
5164
|
107 |
|
108 DEFBINOPX (pow, sparse_complex_matrix, sparse_complex_matrix) |
|
109 { |
|
110 error ("can't do A ^ B for A and B both matrices"); |
|
111 return octave_value (); |
|
112 } |
|
113 |
5322
|
114 DEFBINOP (ldiv, sparse_complex_matrix, sparse_complex_matrix) |
|
115 { |
|
116 CAST_BINOP_ARGS (octave_sparse_complex_matrix&, |
|
117 const octave_sparse_complex_matrix&); |
|
118 SparseType typ = v1.sparse_type (); |
|
119 |
|
120 SparseComplexMatrix ret = xleftdiv (v1.sparse_complex_matrix_value (), |
|
121 v2.sparse_complex_matrix_value (), typ); |
|
122 |
|
123 v1.sparse_type (typ); |
|
124 return ret; |
|
125 } |
5164
|
126 |
|
127 DEFBINOP_FN (lt, sparse_complex_matrix, sparse_complex_matrix, mx_el_lt) |
|
128 DEFBINOP_FN (le, sparse_complex_matrix, sparse_complex_matrix, mx_el_le) |
|
129 DEFBINOP_FN (eq, sparse_complex_matrix, sparse_complex_matrix, mx_el_eq) |
|
130 DEFBINOP_FN (ge, sparse_complex_matrix, sparse_complex_matrix, mx_el_ge) |
|
131 DEFBINOP_FN (gt, sparse_complex_matrix, sparse_complex_matrix, mx_el_gt) |
|
132 DEFBINOP_FN (ne, sparse_complex_matrix, sparse_complex_matrix, mx_el_ne) |
|
133 |
|
134 DEFBINOP_FN (el_mul, sparse_complex_matrix, sparse_complex_matrix, product) |
|
135 DEFBINOP_FN (el_div, sparse_complex_matrix, sparse_complex_matrix, quotient) |
|
136 DEFBINOP_FN (el_pow, sparse_complex_matrix, sparse_complex_matrix, elem_xpow) |
|
137 |
|
138 DEFBINOP (el_ldiv, sparse_complex_matrix, sparse_complex_matrix) |
|
139 { |
|
140 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
141 const octave_sparse_complex_matrix&); |
|
142 |
|
143 return octave_value (quotient (v2.sparse_complex_matrix_value (), |
|
144 v1.sparse_complex_matrix_value ())); |
|
145 } |
|
146 |
|
147 DEFBINOP_FN (el_and, sparse_complex_matrix, sparse_complex_matrix, mx_el_and) |
|
148 DEFBINOP_FN (el_or, sparse_complex_matrix, sparse_complex_matrix, mx_el_or) |
|
149 |
|
150 DEFCATOP_FN (scm_scm, sparse_complex_matrix, sparse_complex_matrix, concat) |
|
151 |
|
152 DEFASSIGNOP_FN (assign, sparse_complex_matrix, sparse_complex_matrix, assign) |
|
153 |
|
154 void |
|
155 install_scm_scm_ops (void) |
|
156 { |
|
157 INSTALL_UNOP (op_not, octave_sparse_complex_matrix, not); |
|
158 INSTALL_UNOP (op_uplus, octave_sparse_complex_matrix, uplus); |
|
159 INSTALL_UNOP (op_uminus, octave_sparse_complex_matrix, uminus); |
|
160 INSTALL_UNOP (op_transpose, octave_sparse_complex_matrix, transpose); |
|
161 INSTALL_UNOP (op_hermitian, octave_sparse_complex_matrix, hermitian); |
|
162 |
|
163 #if 0 |
|
164 INSTALL_NCUNOP (op_incr, octave_sparse_complex_matrix, incr); |
|
165 INSTALL_NCUNOP (op_decr, octave_sparse_complex_matrix, decr); |
|
166 #endif |
|
167 |
|
168 INSTALL_BINOP (op_add, octave_sparse_complex_matrix, |
|
169 octave_sparse_complex_matrix, add); |
|
170 INSTALL_BINOP (op_sub, octave_sparse_complex_matrix, |
|
171 octave_sparse_complex_matrix, sub); |
|
172 INSTALL_BINOP (op_mul, octave_sparse_complex_matrix, |
|
173 octave_sparse_complex_matrix, mul); |
|
174 INSTALL_BINOP (op_div, octave_sparse_complex_matrix, |
|
175 octave_sparse_complex_matrix, div); |
|
176 INSTALL_BINOP (op_pow, octave_sparse_complex_matrix, |
|
177 octave_sparse_complex_matrix, pow); |
|
178 INSTALL_BINOP (op_ldiv, octave_sparse_complex_matrix, |
|
179 octave_sparse_complex_matrix, ldiv); |
|
180 INSTALL_BINOP (op_lt, octave_sparse_complex_matrix, |
|
181 octave_sparse_complex_matrix, lt); |
|
182 INSTALL_BINOP (op_le, octave_sparse_complex_matrix, |
|
183 octave_sparse_complex_matrix, le); |
|
184 INSTALL_BINOP (op_eq, octave_sparse_complex_matrix, |
|
185 octave_sparse_complex_matrix, eq); |
|
186 INSTALL_BINOP (op_ge, octave_sparse_complex_matrix, |
|
187 octave_sparse_complex_matrix, ge); |
|
188 INSTALL_BINOP (op_gt, octave_sparse_complex_matrix, |
|
189 octave_sparse_complex_matrix, gt); |
|
190 INSTALL_BINOP (op_ne, octave_sparse_complex_matrix, |
|
191 octave_sparse_complex_matrix, ne); |
|
192 INSTALL_BINOP (op_el_mul, octave_sparse_complex_matrix, |
|
193 octave_sparse_complex_matrix, el_mul); |
|
194 INSTALL_BINOP (op_el_div, octave_sparse_complex_matrix, |
|
195 octave_sparse_complex_matrix, el_div); |
|
196 INSTALL_BINOP (op_el_pow, octave_sparse_complex_matrix, |
|
197 octave_sparse_complex_matrix, el_pow); |
|
198 INSTALL_BINOP (op_el_ldiv, octave_sparse_complex_matrix, |
|
199 octave_sparse_complex_matrix, el_ldiv); |
|
200 INSTALL_BINOP (op_el_and, octave_sparse_complex_matrix, |
|
201 octave_sparse_complex_matrix, el_and); |
|
202 INSTALL_BINOP (op_el_or, octave_sparse_complex_matrix, |
|
203 octave_sparse_complex_matrix, el_or); |
|
204 |
|
205 INSTALL_CATOP (octave_sparse_complex_matrix, |
|
206 octave_sparse_complex_matrix, scm_scm); |
|
207 |
|
208 INSTALL_ASSIGNOP (op_asn_eq, octave_sparse_complex_matrix, |
|
209 octave_sparse_complex_matrix, assign); |
|
210 } |
|
211 |
|
212 /* |
|
213 ;;; Local Variables: *** |
|
214 ;;; mode: C++ *** |
|
215 ;;; End: *** |
|
216 */ |