Mercurial > octave-nkf
comparison src/OPERATORS/op-cm-scm.cc @ 5164:57077d0ddc8e
[project @ 2005-02-25 19:55:24 by jwe]
author | jwe |
---|---|
date | Fri, 25 Feb 2005 19:55:28 +0000 |
parents | |
children | 4c8a2e4e0717 |
comparison
equal
deleted
inserted
replaced
5163:9f3299378193 | 5164:57077d0ddc8e |
---|---|
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 "ov-cx-mat.h" | |
31 #include "ops.h" | |
32 #include "xdiv.h" | |
33 | |
34 #include "sparse-xpow.h" | |
35 #include "sparse-xdiv.h" | |
36 #include "smx-scm-cm.h" | |
37 #include "smx-cm-scm.h" | |
38 #include "ov-cx-sparse.h" | |
39 | |
40 // complex matrix by sparse complex matrix ops. | |
41 | |
42 DEFBINOP_OP (add, complex_matrix, sparse_complex_matrix,+) | |
43 DEFBINOP_OP (sub, complex_matrix, sparse_complex_matrix,-) | |
44 | |
45 DEFBINOP (mul, complex_matrix, sparse_complex_matrix) | |
46 { | |
47 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
48 const octave_sparse_complex_matrix&); | |
49 | |
50 ComplexMatrix tmp (v2.complex_matrix_value ()); | |
51 | |
52 return octave_value ( v1.complex_matrix_value() * tmp); | |
53 } | |
54 | |
55 DEFBINOP (div, complex_matrix, sparse_complex_matrix) | |
56 { | |
57 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
58 const octave_sparse_complex_matrix&); | |
59 | |
60 return xdiv (v1.complex_matrix_value (), | |
61 v2.sparse_complex_matrix_value ()); | |
62 } | |
63 | |
64 DEFBINOPX (pow, complex_matrix, sparse_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, complex_matrix, sparse_complex_matrix) | |
71 { | |
72 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
73 const octave_sparse_complex_matrix&); | |
74 | |
75 return xleftdiv (v1.complex_matrix_value (), | |
76 v2.complex_matrix_value ()); | |
77 } | |
78 | |
79 DEFBINOP_FN (lt, complex_matrix, sparse_complex_matrix, mx_el_lt) | |
80 DEFBINOP_FN (le, complex_matrix, sparse_complex_matrix, mx_el_le) | |
81 DEFBINOP_FN (eq, complex_matrix, sparse_complex_matrix, mx_el_eq) | |
82 DEFBINOP_FN (ge, complex_matrix, sparse_complex_matrix, mx_el_ge) | |
83 DEFBINOP_FN (gt, complex_matrix, sparse_complex_matrix, mx_el_gt) | |
84 DEFBINOP_FN (ne, complex_matrix, sparse_complex_matrix, mx_el_ne) | |
85 | |
86 DEFBINOP_FN (el_mul, complex_matrix, sparse_complex_matrix, product) | |
87 DEFBINOP_FN (el_div, complex_matrix, sparse_complex_matrix, quotient) | |
88 | |
89 DEFBINOP (el_pow, complex_matrix, sparse_complex_matrix) | |
90 { | |
91 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
92 const octave_sparse_complex_matrix&); | |
93 | |
94 return octave_value | |
95 (elem_xpow (SparseComplexMatrix (v1.complex_matrix_value ()), | |
96 v2.sparse_complex_matrix_value ())); | |
97 } | |
98 | |
99 DEFBINOP (el_ldiv, sparse_complex_matrix, matrix) | |
100 { | |
101 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
102 const octave_sparse_complex_matrix&); | |
103 | |
104 return octave_value (quotient (v2.sparse_complex_matrix_value (), | |
105 v1.complex_matrix_value ())); | |
106 } | |
107 | |
108 DEFBINOP_FN (el_and, complex_matrix, sparse_complex_matrix, mx_el_and) | |
109 DEFBINOP_FN (el_or, complex_matrix, sparse_complex_matrix, mx_el_or) | |
110 | |
111 DEFCATOP (cm_scm, complex_matrix, sparse_complex_matrix) | |
112 { | |
113 CAST_BINOP_ARGS (octave_complex_matrix&, | |
114 const octave_sparse_complex_matrix&); | |
115 SparseComplexMatrix tmp (v1.complex_matrix_value ()); | |
116 return octave_value (tmp. concat (v2.sparse_complex_matrix_value (), | |
117 ra_idx)); | |
118 } | |
119 | |
120 DEFCONV (sparse_complex_matrix_conv, complex_matrix, | |
121 sparse_complex_matrix) | |
122 { | |
123 CAST_CONV_ARG (const octave_complex_matrix&); | |
124 return new octave_sparse_complex_matrix | |
125 (SparseComplexMatrix (v.complex_matrix_value ())); | |
126 } | |
127 | |
128 void | |
129 install_cm_scm_ops (void) | |
130 { | |
131 INSTALL_BINOP (op_add, octave_complex_matrix, | |
132 octave_sparse_complex_matrix, add); | |
133 INSTALL_BINOP (op_sub, octave_complex_matrix, | |
134 octave_sparse_complex_matrix, sub); | |
135 INSTALL_BINOP (op_mul, octave_complex_matrix, | |
136 octave_sparse_complex_matrix, mul); | |
137 INSTALL_BINOP (op_div, octave_complex_matrix, | |
138 octave_sparse_complex_matrix, div); | |
139 INSTALL_BINOP (op_pow, octave_complex_matrix, | |
140 octave_sparse_complex_matrix, pow); | |
141 INSTALL_BINOP (op_ldiv, octave_complex_matrix, | |
142 octave_sparse_complex_matrix, ldiv); | |
143 INSTALL_BINOP (op_lt, octave_complex_matrix, | |
144 octave_sparse_complex_matrix, lt); | |
145 INSTALL_BINOP (op_le, octave_complex_matrix, | |
146 octave_sparse_complex_matrix, le); | |
147 INSTALL_BINOP (op_eq, octave_complex_matrix, | |
148 octave_sparse_complex_matrix, eq); | |
149 INSTALL_BINOP (op_ge, octave_complex_matrix, | |
150 octave_sparse_complex_matrix, ge); | |
151 INSTALL_BINOP (op_gt, octave_complex_matrix, | |
152 octave_sparse_complex_matrix, gt); | |
153 INSTALL_BINOP (op_ne, octave_complex_matrix, | |
154 octave_sparse_complex_matrix, ne); | |
155 INSTALL_BINOP (op_el_mul, octave_complex_matrix, | |
156 octave_sparse_complex_matrix, el_mul); | |
157 INSTALL_BINOP (op_el_div, octave_complex_matrix, | |
158 octave_sparse_complex_matrix, el_div); | |
159 INSTALL_BINOP (op_el_pow, octave_complex_matrix, | |
160 octave_sparse_complex_matrix, el_pow); | |
161 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, | |
162 octave_sparse_complex_matrix, el_ldiv); | |
163 INSTALL_BINOP (op_el_and, octave_complex_matrix, | |
164 octave_sparse_complex_matrix, el_and); | |
165 INSTALL_BINOP (op_el_or, octave_complex_matrix, | |
166 octave_sparse_complex_matrix, el_or); | |
167 | |
168 INSTALL_CATOP (octave_complex_matrix, | |
169 octave_sparse_complex_matrix, cm_scm); | |
170 | |
171 INSTALL_ASSIGNCONV (octave_complex_matrix, octave_sparse_complex_matrix, | |
172 octave_sparse_complex_matrix); | |
173 | |
174 INSTALL_WIDENOP (octave_complex_matrix, octave_sparse_complex_matrix, | |
175 sparse_complex_matrix_conv); | |
176 } | |
177 | |
178 /* | |
179 ;;; Local Variables: *** | |
180 ;;; mode: C++ *** | |
181 ;;; End: *** | |
182 */ |