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