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