00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028 #include "gripes.h"
00029 #include "oct-obj.h"
00030 #include "ov.h"
00031 #include "ov-typeinfo.h"
00032 #include "ov-cx-mat.h"
00033 #include "ov-complex.h"
00034 #include "ops.h"
00035 #include "xpow.h"
00036
00037 #include "sparse-xpow.h"
00038 #include "sparse-xdiv.h"
00039 #include "ov-cx-sparse.h"
00040
00041
00042
00043 DEFBINOP_OP (add, sparse_complex_matrix, complex, +)
00044 DEFBINOP_OP (sub, sparse_complex_matrix, complex, -)
00045 DEFBINOP_OP (mul, sparse_complex_matrix, complex, *)
00046
00047 DEFBINOP (div, sparse_complex_matrix, complex)
00048 {
00049 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&,
00050 const octave_complex&);
00051
00052 Complex d = v2.complex_value ();
00053 octave_value retval;
00054
00055 if (d == 0.0)
00056 gripe_divide_by_zero ();
00057
00058 retval = octave_value (v1.sparse_complex_matrix_value () / d);
00059
00060 return retval;
00061 }
00062
00063 DEFBINOP (pow, sparse_complex_matrix, complex)
00064 {
00065 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&,
00066 const octave_complex&);
00067 return xpow (v1.complex_matrix_value (), v2.complex_value ());
00068 }
00069
00070 DEFBINOP (ldiv, sparse_complex_matrix, complex)
00071 {
00072 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, const octave_complex&);
00073
00074 if (v1.rows() == 1 && v1.columns() == 1)
00075 {
00076 Complex d = v1.complex_value ();
00077
00078 if (d == 0.0)
00079 gripe_divide_by_zero ();
00080
00081 return octave_value (SparseComplexMatrix (1, 1, v2.complex_value () / d));
00082 }
00083 else
00084 {
00085 MatrixType typ = v1.matrix_type ();
00086 SparseComplexMatrix m1 = v1.sparse_complex_matrix_value ();
00087 ComplexMatrix m2 = ComplexMatrix (1, 1, v2.complex_value ());
00088 ComplexMatrix ret = xleftdiv (m1, m2, typ);
00089 v1.matrix_type (typ);
00090 return ret;
00091 }
00092 }
00093
00094 DEFBINOP_FN (lt, sparse_complex_matrix, complex, mx_el_lt)
00095 DEFBINOP_FN (le, sparse_complex_matrix, complex, mx_el_le)
00096 DEFBINOP_FN (eq, sparse_complex_matrix, complex, mx_el_eq)
00097 DEFBINOP_FN (ge, sparse_complex_matrix, complex, mx_el_ge)
00098 DEFBINOP_FN (gt, sparse_complex_matrix, complex, mx_el_gt)
00099 DEFBINOP_FN (ne, sparse_complex_matrix, complex, mx_el_ne)
00100
00101 DEFBINOP_OP (el_mul, sparse_complex_matrix, complex, *)
00102
00103 DEFBINOP (el_div, sparse_complex_matrix, complex)
00104 {
00105 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&,
00106 const octave_complex&);
00107
00108 octave_value retval;
00109
00110 Complex d = v2.complex_value ();
00111
00112 if (d == 0.0)
00113 gripe_divide_by_zero ();
00114
00115 retval = octave_value (v1.sparse_complex_matrix_value () / d);
00116
00117 return retval;
00118 }
00119
00120 DEFBINOP_FN (el_pow, sparse_complex_matrix, complex, elem_xpow)
00121
00122 DEFBINOP (el_ldiv, sparse_complex_matrix, complex)
00123 {
00124 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&,
00125 const octave_complex&);
00126
00127 return octave_value
00128 (x_el_div (v2.complex_value (), v1.sparse_complex_matrix_value ()));
00129 }
00130
00131 DEFBINOP_FN (el_and, sparse_complex_matrix, complex, mx_el_and)
00132 DEFBINOP_FN (el_or, sparse_complex_matrix, complex, mx_el_or)
00133
00134 DEFCATOP (scm_cs, sparse_complex_matrix, complex)
00135 {
00136 CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_complex&);
00137 SparseComplexMatrix tmp (1, 1, v2.complex_value ());
00138 return octave_value
00139 (v1.sparse_complex_matrix_value (). concat (tmp, ra_idx));
00140 }
00141
00142 DEFASSIGNOP (assign, sparse_complex_matrix, complex)
00143 {
00144 CAST_BINOP_ARGS (octave_sparse_complex_matrix&, const octave_complex&);
00145
00146 SparseComplexMatrix tmp (1, 1, v2.complex_value ());
00147 v1.assign (idx, tmp);
00148 return octave_value ();
00149 }
00150
00151 void
00152 install_scm_cs_ops (void)
00153 {
00154 INSTALL_BINOP (op_add, octave_sparse_complex_matrix, octave_complex, add);
00155 INSTALL_BINOP (op_sub, octave_sparse_complex_matrix, octave_complex, sub);
00156 INSTALL_BINOP (op_mul, octave_sparse_complex_matrix, octave_complex, mul);
00157 INSTALL_BINOP (op_div, octave_sparse_complex_matrix, octave_complex, div);
00158 INSTALL_BINOP (op_pow, octave_sparse_complex_matrix, octave_complex, pow);
00159 INSTALL_BINOP (op_ldiv, octave_sparse_complex_matrix, octave_complex,
00160 ldiv);
00161 INSTALL_BINOP (op_lt, octave_sparse_complex_matrix, octave_complex, lt);
00162 INSTALL_BINOP (op_le, octave_sparse_complex_matrix, octave_complex, le);
00163 INSTALL_BINOP (op_eq, octave_sparse_complex_matrix, octave_complex, eq);
00164 INSTALL_BINOP (op_ge, octave_sparse_complex_matrix, octave_complex, ge);
00165 INSTALL_BINOP (op_gt, octave_sparse_complex_matrix, octave_complex, gt);
00166 INSTALL_BINOP (op_ne, octave_sparse_complex_matrix, octave_complex, ne);
00167 INSTALL_BINOP (op_el_mul, octave_sparse_complex_matrix, octave_complex,
00168 el_mul);
00169 INSTALL_BINOP (op_el_div, octave_sparse_complex_matrix, octave_complex,
00170 el_div);
00171 INSTALL_BINOP (op_el_pow, octave_sparse_complex_matrix, octave_complex,
00172 el_pow);
00173 INSTALL_BINOP (op_el_ldiv, octave_sparse_complex_matrix, octave_complex,
00174 el_ldiv);
00175 INSTALL_BINOP (op_el_and, octave_sparse_complex_matrix, octave_complex,
00176 el_and);
00177 INSTALL_BINOP (op_el_or, octave_sparse_complex_matrix, octave_complex,
00178 el_or);
00179
00180 INSTALL_CATOP (octave_sparse_complex_matrix, octave_complex, scm_cs);
00181
00182 INSTALL_ASSIGNOP (op_asn_eq, octave_sparse_complex_matrix, octave_complex,
00183 assign);
00184 }