Mercurial > octave-nkf
comparison src/OPERATORS/op-cm-sm.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-sm-cm.h" | |
37 #include "smx-cm-sm.h" | |
38 #include "ov-re-sparse.h" | |
39 | |
40 // complex matrix by sparse matrix ops. | |
41 | |
42 DEFBINOP_OP (add, complex_matrix, sparse_matrix, +) | |
43 DEFBINOP_OP (sub, complex_matrix, sparse_matrix, -) | |
44 | |
45 DEFBINOP (mul, complex_matrix, sparse_matrix) | |
46 { | |
47 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
48 const octave_sparse_matrix&); | |
49 | |
50 Matrix tmp (v2.matrix_value ()); | |
51 | |
52 return octave_value (v1.complex_matrix_value() * tmp); | |
53 } | |
54 | |
55 DEFBINOP (div, complex_matrix, sparse_matrix) | |
56 { | |
57 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
58 const octave_sparse_matrix&); | |
59 | |
60 return xdiv (v1.complex_matrix_value (), v2.sparse_matrix_value ()); | |
61 } | |
62 | |
63 DEFBINOPX (pow, complex_matrix, sparse_matrix) | |
64 { | |
65 error ("can't do A ^ B for A and B both matrices"); | |
66 return octave_value (); | |
67 } | |
68 | |
69 DEFBINOP (ldiv, complex_matrix, sparse_matrix) | |
70 { | |
71 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
72 const octave_sparse_matrix&); | |
73 | |
74 return xleftdiv (v1.complex_matrix_value (), v2.matrix_value ()); | |
75 } | |
76 | |
77 DEFBINOP_FN (lt, complex_matrix, sparse_matrix, mx_el_lt) | |
78 DEFBINOP_FN (le, complex_matrix, sparse_matrix, mx_el_le) | |
79 DEFBINOP_FN (eq, complex_matrix, sparse_matrix, mx_el_eq) | |
80 DEFBINOP_FN (ge, complex_matrix, sparse_matrix, mx_el_ge) | |
81 DEFBINOP_FN (gt, complex_matrix, sparse_matrix, mx_el_gt) | |
82 DEFBINOP_FN (ne, complex_matrix, sparse_matrix, mx_el_ne) | |
83 | |
84 DEFBINOP_FN (el_mul, complex_matrix, sparse_matrix, product) | |
85 DEFBINOP_FN (el_div, complex_matrix, sparse_matrix, quotient) | |
86 | |
87 DEFBINOP (el_pow, complex_matrix, sparse_matrix) | |
88 { | |
89 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
90 const octave_sparse_matrix&); | |
91 | |
92 return octave_value | |
93 (elem_xpow ( SparseComplexMatrix (v1.complex_matrix_value ()), | |
94 v2.sparse_matrix_value ())); | |
95 } | |
96 | |
97 DEFBINOP (el_ldiv, complex_matrix, sparse_matrix) | |
98 { | |
99 CAST_BINOP_ARGS (const octave_complex_matrix&, | |
100 const octave_sparse_matrix&); | |
101 return octave_value | |
102 (quotient (v2.sparse_matrix_value (), v1.complex_matrix_value ())); | |
103 } | |
104 | |
105 DEFBINOP_FN (el_and, complex_matrix, sparse_matrix, mx_el_and) | |
106 DEFBINOP_FN (el_or, complex_matrix, sparse_matrix, mx_el_or) | |
107 | |
108 DEFCATOP (cm_sm, complex_matrix, sparse_matrix) | |
109 { | |
110 CAST_BINOP_ARGS (octave_complex_matrix&, const octave_sparse_matrix&); | |
111 SparseComplexMatrix tmp (v1.complex_matrix_value ()); | |
112 return octave_value (tmp. concat (v2.sparse_matrix_value (), ra_idx)); | |
113 } | |
114 | |
115 void | |
116 install_cm_sm_ops (void) | |
117 { | |
118 INSTALL_BINOP (op_add, octave_complex_matrix, octave_sparse_matrix, add); | |
119 INSTALL_BINOP (op_sub, octave_complex_matrix, octave_sparse_matrix, sub); | |
120 INSTALL_BINOP (op_mul, octave_complex_matrix, octave_sparse_matrix, mul); | |
121 INSTALL_BINOP (op_div, octave_complex_matrix, octave_sparse_matrix, div); | |
122 INSTALL_BINOP (op_pow, octave_complex_matrix, octave_sparse_matrix, pow); | |
123 INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_sparse_matrix, ldiv); | |
124 INSTALL_BINOP (op_lt, octave_complex_matrix, octave_sparse_matrix, lt); | |
125 INSTALL_BINOP (op_le, octave_complex_matrix, octave_sparse_matrix, le); | |
126 INSTALL_BINOP (op_eq, octave_complex_matrix, octave_sparse_matrix, eq); | |
127 INSTALL_BINOP (op_ge, octave_complex_matrix, octave_sparse_matrix, ge); | |
128 INSTALL_BINOP (op_gt, octave_complex_matrix, octave_sparse_matrix, gt); | |
129 INSTALL_BINOP (op_ne, octave_complex_matrix, octave_sparse_matrix, ne); | |
130 INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_sparse_matrix, | |
131 el_mul); | |
132 INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_sparse_matrix, | |
133 el_div); | |
134 INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_sparse_matrix, | |
135 el_pow); | |
136 INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_sparse_matrix, | |
137 el_ldiv); | |
138 INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_sparse_matrix, | |
139 el_and); | |
140 INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_sparse_matrix, | |
141 el_or); | |
142 | |
143 INSTALL_CATOP (octave_complex_matrix, octave_sparse_matrix, cm_sm); | |
144 | |
145 } | |
146 | |
147 /* | |
148 ;;; Local Variables: *** | |
149 ;;; mode: C++ *** | |
150 ;;; End: *** | |
151 */ |