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 |
|
17 along with this program; see the file COPYING. If not, write to the Free |
|
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
19 |
|
20 */ |
|
21 |
|
22 #ifdef HAVE_CONFIG_H |
|
23 #include <config.h> |
|
24 #endif |
|
25 |
|
26 #include "gripes.h" |
|
27 #include "oct-obj.h" |
|
28 #include "ov.h" |
|
29 #include "ov-typeinfo.h" |
|
30 #include "ops.h" |
|
31 |
|
32 #include "sparse-xdiv.h" |
|
33 #include "sparse-xpow.h" |
|
34 #include "ov-re-sparse.h" |
|
35 #include "ov-cx-sparse.h" |
|
36 |
|
37 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
38 #pragma implementation |
|
39 #endif |
|
40 |
|
41 #ifdef HAVE_CONFIG_H |
|
42 #include <config.h> |
|
43 #endif |
|
44 |
|
45 #include "gripes.h" |
|
46 #include "oct-obj.h" |
|
47 #include "ov.h" |
|
48 #include "ov-cx-mat.h" |
|
49 #include "ov-typeinfo.h" |
|
50 #include "ops.h" |
|
51 #include "xdiv.h" |
|
52 #include "xpow.h" |
|
53 |
|
54 // unary sparse complex matrix ops. |
|
55 |
|
56 DEFUNOP_OP (not, sparse_complex_matrix, !) |
|
57 DEFUNOP_OP (uplus, sparse_complex_matrix, /* no-op */) |
|
58 DEFUNOP_OP (uminus, sparse_complex_matrix, -) |
|
59 |
|
60 DEFUNOP (transpose, sparse_complex_matrix) |
|
61 { |
|
62 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
|
63 |
|
64 return octave_value (v.sparse_complex_matrix_value().transpose ()); |
|
65 } |
|
66 |
|
67 DEFUNOP (hermitian, sparse_complex_matrix) |
|
68 { |
|
69 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
|
70 |
|
71 return octave_value (v.sparse_complex_matrix_value().hermitian ()); |
|
72 } |
|
73 |
|
74 #if 0 |
|
75 DEFUNOP (incr, sparse_complex_matrix) |
|
76 { |
|
77 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
|
78 |
|
79 return octave_value (v.complex_matrix_value () .increment ()); |
|
80 } |
|
81 |
|
82 DEFUNOP (decr, sparse_complex_matrix) |
|
83 { |
|
84 CAST_UNOP_ARG (const octave_sparse_complex_matrix&); |
|
85 |
|
86 return octave_value (v.complex_matrix_value () .decrement ()); |
|
87 } |
|
88 #endif |
|
89 |
|
90 // complex matrix by complex matrix ops. |
|
91 |
|
92 DEFBINOP_OP (add, sparse_complex_matrix, sparse_complex_matrix, +) |
|
93 DEFBINOP_OP (sub, sparse_complex_matrix, sparse_complex_matrix, -) |
|
94 |
|
95 DEFBINOP_OP (mul, sparse_complex_matrix, sparse_complex_matrix, *) |
|
96 |
|
97 DEFBINOP_FN (div, sparse_complex_matrix, sparse_complex_matrix, xdiv) |
|
98 |
|
99 DEFBINOPX (pow, sparse_complex_matrix, sparse_complex_matrix) |
|
100 { |
|
101 error ("can't do A ^ B for A and B both matrices"); |
|
102 return octave_value (); |
|
103 } |
|
104 |
|
105 DEFBINOP_FN (ldiv, sparse_complex_matrix, sparse_complex_matrix, xleftdiv) |
|
106 |
|
107 DEFBINOP_FN (lt, sparse_complex_matrix, sparse_complex_matrix, mx_el_lt) |
|
108 DEFBINOP_FN (le, sparse_complex_matrix, sparse_complex_matrix, mx_el_le) |
|
109 DEFBINOP_FN (eq, sparse_complex_matrix, sparse_complex_matrix, mx_el_eq) |
|
110 DEFBINOP_FN (ge, sparse_complex_matrix, sparse_complex_matrix, mx_el_ge) |
|
111 DEFBINOP_FN (gt, sparse_complex_matrix, sparse_complex_matrix, mx_el_gt) |
|
112 DEFBINOP_FN (ne, sparse_complex_matrix, sparse_complex_matrix, mx_el_ne) |
|
113 |
|
114 DEFBINOP_FN (el_mul, sparse_complex_matrix, sparse_complex_matrix, product) |
|
115 DEFBINOP_FN (el_div, sparse_complex_matrix, sparse_complex_matrix, quotient) |
|
116 DEFBINOP_FN (el_pow, sparse_complex_matrix, sparse_complex_matrix, elem_xpow) |
|
117 |
|
118 DEFBINOP (el_ldiv, sparse_complex_matrix, sparse_complex_matrix) |
|
119 { |
|
120 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
121 const octave_sparse_complex_matrix&); |
|
122 |
|
123 return octave_value (quotient (v2.sparse_complex_matrix_value (), |
|
124 v1.sparse_complex_matrix_value ())); |
|
125 } |
|
126 |
|
127 DEFBINOP_FN (el_and, sparse_complex_matrix, sparse_complex_matrix, mx_el_and) |
|
128 DEFBINOP_FN (el_or, sparse_complex_matrix, sparse_complex_matrix, mx_el_or) |
|
129 |
|
130 DEFCATOP_FN (scm_scm, sparse_complex_matrix, sparse_complex_matrix, concat) |
|
131 |
|
132 DEFASSIGNOP_FN (assign, sparse_complex_matrix, sparse_complex_matrix, assign) |
|
133 |
|
134 void |
|
135 install_scm_scm_ops (void) |
|
136 { |
|
137 INSTALL_UNOP (op_not, octave_sparse_complex_matrix, not); |
|
138 INSTALL_UNOP (op_uplus, octave_sparse_complex_matrix, uplus); |
|
139 INSTALL_UNOP (op_uminus, octave_sparse_complex_matrix, uminus); |
|
140 INSTALL_UNOP (op_transpose, octave_sparse_complex_matrix, transpose); |
|
141 INSTALL_UNOP (op_hermitian, octave_sparse_complex_matrix, hermitian); |
|
142 |
|
143 #if 0 |
|
144 INSTALL_NCUNOP (op_incr, octave_sparse_complex_matrix, incr); |
|
145 INSTALL_NCUNOP (op_decr, octave_sparse_complex_matrix, decr); |
|
146 #endif |
|
147 |
|
148 INSTALL_BINOP (op_add, octave_sparse_complex_matrix, |
|
149 octave_sparse_complex_matrix, add); |
|
150 INSTALL_BINOP (op_sub, octave_sparse_complex_matrix, |
|
151 octave_sparse_complex_matrix, sub); |
|
152 INSTALL_BINOP (op_mul, octave_sparse_complex_matrix, |
|
153 octave_sparse_complex_matrix, mul); |
|
154 INSTALL_BINOP (op_div, octave_sparse_complex_matrix, |
|
155 octave_sparse_complex_matrix, div); |
|
156 INSTALL_BINOP (op_pow, octave_sparse_complex_matrix, |
|
157 octave_sparse_complex_matrix, pow); |
|
158 INSTALL_BINOP (op_ldiv, octave_sparse_complex_matrix, |
|
159 octave_sparse_complex_matrix, ldiv); |
|
160 INSTALL_BINOP (op_lt, octave_sparse_complex_matrix, |
|
161 octave_sparse_complex_matrix, lt); |
|
162 INSTALL_BINOP (op_le, octave_sparse_complex_matrix, |
|
163 octave_sparse_complex_matrix, le); |
|
164 INSTALL_BINOP (op_eq, octave_sparse_complex_matrix, |
|
165 octave_sparse_complex_matrix, eq); |
|
166 INSTALL_BINOP (op_ge, octave_sparse_complex_matrix, |
|
167 octave_sparse_complex_matrix, ge); |
|
168 INSTALL_BINOP (op_gt, octave_sparse_complex_matrix, |
|
169 octave_sparse_complex_matrix, gt); |
|
170 INSTALL_BINOP (op_ne, octave_sparse_complex_matrix, |
|
171 octave_sparse_complex_matrix, ne); |
|
172 INSTALL_BINOP (op_el_mul, octave_sparse_complex_matrix, |
|
173 octave_sparse_complex_matrix, el_mul); |
|
174 INSTALL_BINOP (op_el_div, octave_sparse_complex_matrix, |
|
175 octave_sparse_complex_matrix, el_div); |
|
176 INSTALL_BINOP (op_el_pow, octave_sparse_complex_matrix, |
|
177 octave_sparse_complex_matrix, el_pow); |
|
178 INSTALL_BINOP (op_el_ldiv, octave_sparse_complex_matrix, |
|
179 octave_sparse_complex_matrix, el_ldiv); |
|
180 INSTALL_BINOP (op_el_and, octave_sparse_complex_matrix, |
|
181 octave_sparse_complex_matrix, el_and); |
|
182 INSTALL_BINOP (op_el_or, octave_sparse_complex_matrix, |
|
183 octave_sparse_complex_matrix, el_or); |
|
184 |
|
185 INSTALL_CATOP (octave_sparse_complex_matrix, |
|
186 octave_sparse_complex_matrix, scm_scm); |
|
187 |
|
188 INSTALL_ASSIGNOP (op_asn_eq, octave_sparse_complex_matrix, |
|
189 octave_sparse_complex_matrix, assign); |
|
190 } |
|
191 |
|
192 /* |
|
193 ;;; Local Variables: *** |
|
194 ;;; mode: C++ *** |
|
195 ;;; End: *** |
|
196 */ |