comparison src/OPERATORS/op-sm-cs.cc @ 6221:8e0f1eda266b

[project @ 2007-01-03 17:23:33 by jwe]
author jwe
date Wed, 03 Jan 2007 17:23:34 +0000
parents 6b9cec830d72
children 93c65f2a5668
comparison
equal deleted inserted replaced
6220:0c3537d2a844 6221:8e0f1eda266b
72 72
73 DEFBINOP (ldiv, sparse_matrix, complex) 73 DEFBINOP (ldiv, sparse_matrix, complex)
74 { 74 {
75 CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex&); 75 CAST_BINOP_ARGS (const octave_sparse_matrix&, const octave_complex&);
76 76
77 MatrixType typ = v1.matrix_type (); 77 if (v1.rows() == 1 && v1.columns() == 1)
78 SparseMatrix m1 = v1.sparse_matrix_value (); 78 {
79 ComplexMatrix m2 = ComplexMatrix (1, 1, v2.complex_value ()); 79 double d = v1.scalar_value ();
80 ComplexMatrix ret = xleftdiv (m1, m2, typ);
81 v1.matrix_type (typ);
82 80
83 return ret; 81 if (d == 0.0)
82 gripe_divide_by_zero ();
83
84 return octave_value (v2.complex_value () / d);
85 }
86 else
87 {
88 MatrixType typ = v1.matrix_type ();
89 SparseMatrix m1 = v1.sparse_matrix_value ();
90 ComplexMatrix m2 = ComplexMatrix (1, 1, v2.complex_value ());
91 ComplexMatrix ret = xleftdiv (m1, m2, typ);
92 v1.matrix_type (typ);
93 return ret;
94 }
84 } 95 }
85 96
86 DEFBINOP_FN (lt, sparse_matrix, complex, mx_el_lt) 97 DEFBINOP_FN (lt, sparse_matrix, complex, mx_el_lt)
87 DEFBINOP_FN (le, sparse_matrix, complex, mx_el_le) 98 DEFBINOP_FN (le, sparse_matrix, complex, mx_el_le)
88 DEFBINOP_FN (eq, sparse_matrix, complex, mx_el_eq) 99 DEFBINOP_FN (eq, sparse_matrix, complex, mx_el_eq)