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