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