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