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