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 "ov-cx-mat.h" |
|
32 #include "ops.h" |
|
33 #include "xdiv.h" |
|
34 |
|
35 #include "sparse-xpow.h" |
|
36 #include "sparse-xdiv.h" |
|
37 #include "smx-scm-cm.h" |
|
38 #include "smx-cm-scm.h" |
|
39 #include "ov-cx-sparse.h" |
|
40 |
|
41 // sparse complex matrix by complex matrix ops. |
|
42 |
|
43 DEFBINOP_OP (add, sparse_complex_matrix, complex_matrix, +) |
|
44 DEFBINOP_OP (sub, sparse_complex_matrix, complex_matrix, -) |
|
45 |
|
46 DEFBINOP (mul, sparse_complex_matrix, complex_matrix) |
|
47 { |
|
48 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
49 const octave_complex_matrix&); |
|
50 |
|
51 ComplexMatrix tmp (v1.complex_matrix_value ()); |
|
52 |
|
53 return octave_value ( tmp * v2.complex_matrix_value()); |
|
54 } |
|
55 |
|
56 DEFBINOP (div, sparse_complex_matrix, complex_matrix) |
|
57 { |
|
58 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
59 const octave_complex_matrix&); |
|
60 |
|
61 return xdiv (v1.complex_matrix_value (), v2.complex_matrix_value ()); |
|
62 } |
|
63 |
|
64 DEFBINOPX (pow, sparse_complex_matrix, complex_matrix) |
|
65 { |
|
66 error ("can't do A ^ B for A and B both matrices"); |
|
67 return octave_value (); |
|
68 } |
|
69 |
|
70 DEFBINOP (ldiv, sparse_complex_matrix, complex_matrix) |
|
71 { |
5322
|
72 CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_complex_matrix&); |
|
73 SparseType typ = v1.sparse_type (); |
|
74 |
|
75 ComplexMatrix ret = xleftdiv (v1.sparse_complex_matrix_value (), |
|
76 v2.complex_matrix_value (), typ); |
|
77 |
|
78 v1.sparse_type (typ); |
|
79 return ret; |
5164
|
80 } |
|
81 |
|
82 DEFBINOP_FN (lt, sparse_complex_matrix, complex_matrix, mx_el_lt) |
|
83 DEFBINOP_FN (le, sparse_complex_matrix, complex_matrix, mx_el_le) |
|
84 DEFBINOP_FN (eq, sparse_complex_matrix, complex_matrix, mx_el_eq) |
|
85 DEFBINOP_FN (ge, sparse_complex_matrix, complex_matrix, mx_el_ge) |
|
86 DEFBINOP_FN (gt, sparse_complex_matrix, complex_matrix, mx_el_gt) |
|
87 DEFBINOP_FN (ne, sparse_complex_matrix, complex_matrix, mx_el_ne) |
|
88 |
|
89 DEFBINOP_FN (el_mul, sparse_complex_matrix, complex_matrix, product) |
|
90 DEFBINOP_FN (el_div, sparse_complex_matrix, complex_matrix, quotient) |
|
91 |
|
92 DEFBINOP (el_pow, sparse_complex_matrix, complex_matrix) |
|
93 { |
|
94 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
95 const octave_complex_matrix&); |
|
96 |
|
97 return octave_value |
|
98 (elem_xpow (v1.sparse_complex_matrix_value (), SparseComplexMatrix |
|
99 (v2.complex_matrix_value ()))); |
|
100 } |
|
101 |
|
102 DEFBINOP (el_ldiv, sparse_complex_matrix, matrix) |
|
103 { |
|
104 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, |
|
105 const octave_complex_matrix&); |
|
106 |
|
107 return octave_value (quotient (v2.complex_matrix_value (), |
|
108 v1.sparse_complex_matrix_value ())); |
|
109 } |
|
110 |
|
111 DEFBINOP_FN (el_and, sparse_complex_matrix, complex_matrix, mx_el_and) |
|
112 DEFBINOP_FN (el_or, sparse_complex_matrix, complex_matrix, mx_el_or) |
|
113 |
|
114 DEFCATOP (scm_cm, sparse_complex_matrix, complex_matrix) |
|
115 { |
|
116 CAST_BINOP_ARGS (octave_sparse_complex_matrix&, |
|
117 const octave_complex_matrix&); |
|
118 SparseComplexMatrix tmp (v2.complex_matrix_value ()); |
|
119 return octave_value |
|
120 (v1.sparse_complex_matrix_value (). concat (tmp, ra_idx)); |
|
121 } |
|
122 |
|
123 DEFASSIGNOP (assign, sparse_complex_matrix, complex_matrix) |
|
124 { |
|
125 CAST_BINOP_ARGS (octave_sparse_complex_matrix&, |
|
126 const octave_complex_matrix&); |
|
127 |
|
128 SparseComplexMatrix tmp (v2.complex_matrix_value ()); |
|
129 v1.assign (idx, tmp); |
|
130 return octave_value (); |
|
131 } |
|
132 |
|
133 void |
|
134 install_scm_cm_ops (void) |
|
135 { |
|
136 INSTALL_BINOP (op_add, octave_sparse_complex_matrix, |
|
137 octave_complex_matrix, add); |
|
138 INSTALL_BINOP (op_sub, octave_sparse_complex_matrix, |
|
139 octave_complex_matrix, sub); |
|
140 INSTALL_BINOP (op_mul, octave_sparse_complex_matrix, |
|
141 octave_complex_matrix, mul); |
|
142 INSTALL_BINOP (op_div, octave_sparse_complex_matrix, |
|
143 octave_complex_matrix, div); |
|
144 INSTALL_BINOP (op_pow, octave_sparse_complex_matrix, |
|
145 octave_complex_matrix, pow); |
|
146 INSTALL_BINOP (op_ldiv, octave_sparse_complex_matrix, |
|
147 octave_complex_matrix, ldiv); |
|
148 INSTALL_BINOP (op_lt, octave_sparse_complex_matrix, |
|
149 octave_complex_matrix, lt); |
|
150 INSTALL_BINOP (op_le, octave_sparse_complex_matrix, |
|
151 octave_complex_matrix, le); |
|
152 INSTALL_BINOP (op_eq, octave_sparse_complex_matrix, |
|
153 octave_complex_matrix, eq); |
|
154 INSTALL_BINOP (op_ge, octave_sparse_complex_matrix, |
|
155 octave_complex_matrix, ge); |
|
156 INSTALL_BINOP (op_gt, octave_sparse_complex_matrix, |
|
157 octave_complex_matrix, gt); |
|
158 INSTALL_BINOP (op_ne, octave_sparse_complex_matrix, |
|
159 octave_complex_matrix, ne); |
|
160 INSTALL_BINOP (op_el_mul, octave_sparse_complex_matrix, |
|
161 octave_complex_matrix, el_mul); |
|
162 INSTALL_BINOP (op_el_div, octave_sparse_complex_matrix, |
|
163 octave_complex_matrix, el_div); |
|
164 INSTALL_BINOP (op_el_pow, octave_sparse_complex_matrix, |
|
165 octave_complex_matrix, el_pow); |
|
166 INSTALL_BINOP (op_el_ldiv, octave_sparse_complex_matrix, |
|
167 octave_complex_matrix, el_ldiv); |
|
168 INSTALL_BINOP (op_el_and, octave_sparse_complex_matrix, |
|
169 octave_complex_matrix, el_and); |
|
170 INSTALL_BINOP (op_el_or, octave_sparse_complex_matrix, |
|
171 octave_complex_matrix, el_or); |
|
172 |
|
173 INSTALL_CATOP (octave_sparse_complex_matrix, |
|
174 octave_complex_matrix, scm_cm); |
|
175 |
|
176 INSTALL_ASSIGNOP (op_asn_eq, octave_sparse_complex_matrix, |
|
177 octave_complex_matrix, assign); |
|
178 } |
|
179 |
|
180 /* |
|
181 ;;; Local Variables: *** |
|
182 ;;; mode: C++ *** |
|
183 ;;; End: *** |
|
184 */ |