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