comparison libinterp/operators/op-dm-scm.cc @ 21647:66cae7a6dc47

eliminate some macros for operator definitions * ops.h (CAST_UNOP_ARG, CAST_BINOP_ARGS, CAST_CONV_ARG, ASSIGNOPDECL, NULLASSIGNOPDECL, ASSIGNANYOPDECL, DEFASSIGNOP, DEFASSIGNOP_FN, UNOPDECL, BINOPDECL, CATOPDECL): Delete macros. * make_int.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-flt-cx-diag.cc, ov-flt-re-diag.cc, ov-lazy-idx.cc, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-scalar.cc, ov-str-mat.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-int-conv.cc, op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, ops.h: Expand eliminated macros in place.
author John W. Eaton <jwe@octave.org>
date Wed, 27 Apr 2016 16:13:40 -0400
parents 40de9f8f23a6
children aba2e6293dd8
comparison
equal deleted inserted replaced
21646:3cddf1e65ccf 21647:66cae7a6dc47
48 48
49 // diagonal matrix by sparse matrix ops 49 // diagonal matrix by sparse matrix ops
50 50
51 DEFBINOP (mul_dm_scm, diag_matrix, sparse_complex_matrix) 51 DEFBINOP (mul_dm_scm, diag_matrix, sparse_complex_matrix)
52 { 52 {
53 CAST_BINOP_ARGS (const octave_diag_matrix&, 53 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
54 const octave_sparse_complex_matrix&); 54 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
55 55
56 if (v2.rows () == 1 && v2.columns () == 1) 56 if (v2.rows () == 1 && v2.columns () == 1)
57 // If v2 is a scalar in disguise, return a diagonal matrix rather than 57 // If v2 is a scalar in disguise, return a diagonal matrix rather than
58 // a sparse matrix. 58 // a sparse matrix.
59 { 59 {
73 } 73 }
74 } 74 }
75 75
76 DEFBINOP (mul_cdm_sm, complex_diag_matrix, sparse_matrix) 76 DEFBINOP (mul_cdm_sm, complex_diag_matrix, sparse_matrix)
77 { 77 {
78 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 78 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
79 const octave_sparse_matrix&); 79 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2);
80 80
81 if (v2.rows () == 1 && v2.columns () == 1) 81 if (v2.rows () == 1 && v2.columns () == 1)
82 // If v2 is a scalar in disguise, return a diagonal matrix rather than 82 // If v2 is a scalar in disguise, return a diagonal matrix rather than
83 // a sparse matrix. 83 // a sparse matrix.
84 { 84 {
98 } 98 }
99 } 99 }
100 100
101 DEFBINOP (mul_cdm_scm, complex_diag_matrix, sparse_complex_matrix) 101 DEFBINOP (mul_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
102 { 102 {
103 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 103 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
104 const octave_sparse_complex_matrix&); 104 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
105 105
106 if (v2.rows () == 1 && v2.columns () == 1) 106 if (v2.rows () == 1 && v2.columns () == 1)
107 // If v2 is a scalar in disguise, return a diagonal matrix rather than 107 // If v2 is a scalar in disguise, return a diagonal matrix rather than
108 // a sparse matrix. 108 // a sparse matrix.
109 { 109 {
123 } 123 }
124 } 124 }
125 125
126 DEFBINOP (ldiv_dm_scm, diag_matrix, sparse_complex_matrix) 126 DEFBINOP (ldiv_dm_scm, diag_matrix, sparse_complex_matrix)
127 { 127 {
128 CAST_BINOP_ARGS (const octave_diag_matrix&, 128 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
129 const octave_sparse_complex_matrix&); 129 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
130 130
131 MatrixType typ = v2.matrix_type (); 131 MatrixType typ = v2.matrix_type ();
132 return xleftdiv (v1.diag_matrix_value (), v2.sparse_complex_matrix_value (), 132 return xleftdiv (v1.diag_matrix_value (), v2.sparse_complex_matrix_value (),
133 typ); 133 typ);
134 } 134 }
135 135
136 DEFBINOP (ldiv_cdm_sm, complex_diag_matrix, sparse_matrix) 136 DEFBINOP (ldiv_cdm_sm, complex_diag_matrix, sparse_matrix)
137 { 137 {
138 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 138 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
139 const octave_sparse_matrix&); 139 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2);
140 140
141 MatrixType typ = v2.matrix_type (); 141 MatrixType typ = v2.matrix_type ();
142 return xleftdiv (v1.complex_diag_matrix_value (), v2.sparse_matrix_value (), 142 return xleftdiv (v1.complex_diag_matrix_value (), v2.sparse_matrix_value (),
143 typ); 143 typ);
144 } 144 }
145 145
146 DEFBINOP (ldiv_cdm_scm, complex_diag_matrix, sparse_complex_matrix) 146 DEFBINOP (ldiv_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
147 { 147 {
148 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 148 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
149 const octave_sparse_complex_matrix&); 149 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
150 150
151 MatrixType typ = v2.matrix_type (); 151 MatrixType typ = v2.matrix_type ();
152 return xleftdiv (v1.complex_diag_matrix_value (), 152 return xleftdiv (v1.complex_diag_matrix_value (),
153 v2.sparse_complex_matrix_value (), 153 v2.sparse_complex_matrix_value (),
154 typ); 154 typ);
155 } 155 }
156 156
157 DEFBINOP (add_dm_scm, diag_matrix, sparse_complex_matrix) 157 DEFBINOP (add_dm_scm, diag_matrix, sparse_complex_matrix)
158 { 158 {
159 CAST_BINOP_ARGS (const octave_diag_matrix&, 159 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
160 const octave_sparse_complex_matrix&); 160 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
161 161
162 if (v2.rows () == 1 && v2.columns () == 1) 162 if (v2.rows () == 1 && v2.columns () == 1)
163 // If v2 is a scalar in disguise, return a diagonal matrix rather than 163 // If v2 is a scalar in disguise, return a diagonal matrix rather than
164 // a sparse matrix. 164 // a sparse matrix.
165 { 165 {
171 return v1.diag_matrix_value () + v2.sparse_complex_matrix_value (); 171 return v1.diag_matrix_value () + v2.sparse_complex_matrix_value ();
172 } 172 }
173 173
174 DEFBINOP (add_cdm_sm, complex_diag_matrix, sparse_matrix) 174 DEFBINOP (add_cdm_sm, complex_diag_matrix, sparse_matrix)
175 { 175 {
176 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 176 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
177 const octave_sparse_matrix&); 177 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2);
178 178
179 if (v2.rows () == 1 && v2.columns () == 1) 179 if (v2.rows () == 1 && v2.columns () == 1)
180 // If v2 is a scalar in disguise, return a diagonal matrix rather than 180 // If v2 is a scalar in disguise, return a diagonal matrix rather than
181 // a sparse matrix. 181 // a sparse matrix.
182 { 182 {
188 return v1.complex_diag_matrix_value () + v2.sparse_matrix_value (); 188 return v1.complex_diag_matrix_value () + v2.sparse_matrix_value ();
189 } 189 }
190 190
191 DEFBINOP (add_cdm_scm, complex_diag_matrix, sparse_complex_matrix) 191 DEFBINOP (add_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
192 { 192 {
193 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 193 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
194 const octave_sparse_complex_matrix&); 194 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
195 195
196 if (v2.rows () == 1 && v2.columns () == 1) 196 if (v2.rows () == 1 && v2.columns () == 1)
197 // If v2 is a scalar in disguise, return a diagonal matrix rather than 197 // If v2 is a scalar in disguise, return a diagonal matrix rather than
198 // a sparse matrix. 198 // a sparse matrix.
199 { 199 {
205 return v1.complex_diag_matrix_value () + v2.sparse_complex_matrix_value (); 205 return v1.complex_diag_matrix_value () + v2.sparse_complex_matrix_value ();
206 } 206 }
207 207
208 DEFBINOP (sub_dm_scm, diag_matrix, sparse_complex_matrix) 208 DEFBINOP (sub_dm_scm, diag_matrix, sparse_complex_matrix)
209 { 209 {
210 CAST_BINOP_ARGS (const octave_diag_matrix&, 210 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
211 const octave_sparse_complex_matrix&); 211 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
212 212
213 if (v2.rows () == 1 && v2.columns () == 1) 213 if (v2.rows () == 1 && v2.columns () == 1)
214 // If v2 is a scalar in disguise, return a diagonal matrix rather than 214 // If v2 is a scalar in disguise, return a diagonal matrix rather than
215 // a sparse matrix. 215 // a sparse matrix.
216 { 216 {
222 return v1.diag_matrix_value () - v2.sparse_complex_matrix_value (); 222 return v1.diag_matrix_value () - v2.sparse_complex_matrix_value ();
223 } 223 }
224 224
225 DEFBINOP (sub_cdm_sm, complex_diag_matrix, sparse_matrix) 225 DEFBINOP (sub_cdm_sm, complex_diag_matrix, sparse_matrix)
226 { 226 {
227 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 227 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
228 const octave_sparse_matrix&); 228 const octave_sparse_matrix& v2 = dynamic_cast<const octave_sparse_matrix&> (a2);
229 229
230 if (v2.rows () == 1 && v2.columns () == 1) 230 if (v2.rows () == 1 && v2.columns () == 1)
231 // If v2 is a scalar in disguise, return a diagonal matrix rather than 231 // If v2 is a scalar in disguise, return a diagonal matrix rather than
232 // a sparse matrix. 232 // a sparse matrix.
233 { 233 {
239 return v1.complex_diag_matrix_value () - v2.sparse_matrix_value (); 239 return v1.complex_diag_matrix_value () - v2.sparse_matrix_value ();
240 } 240 }
241 241
242 DEFBINOP (sub_cdm_scm, complex_diag_matrix, sparse_complex_matrix) 242 DEFBINOP (sub_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
243 { 243 {
244 CAST_BINOP_ARGS (const octave_complex_diag_matrix&, 244 const octave_complex_diag_matrix& v1 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
245 const octave_sparse_complex_matrix&); 245 const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
246 246
247 if (v2.rows () == 1 && v2.columns () == 1) 247 if (v2.rows () == 1 && v2.columns () == 1)
248 // If v2 is a scalar in disguise, return a diagonal matrix rather than 248 // If v2 is a scalar in disguise, return a diagonal matrix rather than
249 // a sparse matrix. 249 // a sparse matrix.
250 { 250 {
258 258
259 // sparse matrix by diagonal matrix ops 259 // sparse matrix by diagonal matrix ops
260 260
261 DEFBINOP (mul_scm_dm, sparse_complex_matrix, diag_matrix) 261 DEFBINOP (mul_scm_dm, sparse_complex_matrix, diag_matrix)
262 { 262 {
263 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 263 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
264 const octave_diag_matrix&); 264 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
265 265
266 if (v1.rows () == 1 && v1.columns () == 1) 266 if (v1.rows () == 1 && v1.columns () == 1)
267 // If v1 is a scalar in disguise, return a diagonal matrix rather than 267 // If v1 is a scalar in disguise, return a diagonal matrix rather than
268 // a sparse matrix. 268 // a sparse matrix.
269 { 269 {
283 } 283 }
284 } 284 }
285 285
286 DEFBINOP (mul_sm_cdm, sparse_matrix, complex_diag_matrix) 286 DEFBINOP (mul_sm_cdm, sparse_matrix, complex_diag_matrix)
287 { 287 {
288 CAST_BINOP_ARGS (const octave_sparse_matrix&, 288 const octave_sparse_matrix& v1 = dynamic_cast<const octave_sparse_matrix&> (a1);
289 const octave_complex_diag_matrix&); 289 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
290 290
291 if (v1.rows () == 1 && v1.columns () == 1) 291 if (v1.rows () == 1 && v1.columns () == 1)
292 // If v1 is a scalar in disguise, return a diagonal matrix rather than 292 // If v1 is a scalar in disguise, return a diagonal matrix rather than
293 // a sparse matrix. 293 // a sparse matrix.
294 { 294 {
308 } 308 }
309 } 309 }
310 310
311 DEFBINOP (mul_scm_cdm, sparse_complex_matrix, complex_diag_matrix) 311 DEFBINOP (mul_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
312 { 312 {
313 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 313 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
314 const octave_complex_diag_matrix&); 314 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
315 315
316 if (v1.rows () == 1 && v1.columns () == 1) 316 if (v1.rows () == 1 && v1.columns () == 1)
317 // If v1 is a scalar in disguise, return a diagonal matrix rather than 317 // If v1 is a scalar in disguise, return a diagonal matrix rather than
318 // a sparse matrix. 318 // a sparse matrix.
319 { 319 {
340 } 340 }
341 } 341 }
342 342
343 DEFBINOP (div_scm_dm, sparse_complex_matrix, diag_matrix) 343 DEFBINOP (div_scm_dm, sparse_complex_matrix, diag_matrix)
344 { 344 {
345 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 345 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
346 const octave_diag_matrix&); 346 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
347 347
348 if (v2.rows () == 1 && v2.columns () == 1) 348 if (v2.rows () == 1 && v2.columns () == 1)
349 { 349 {
350 double d = v2.scalar_value (); 350 double d = v2.scalar_value ();
351 351
362 } 362 }
363 } 363 }
364 364
365 DEFBINOP (div_sm_cdm, sparse_matrix, complex_diag_matrix) 365 DEFBINOP (div_sm_cdm, sparse_matrix, complex_diag_matrix)
366 { 366 {
367 CAST_BINOP_ARGS (const octave_sparse_matrix&, 367 const octave_sparse_matrix& v1 = dynamic_cast<const octave_sparse_matrix&> (a1);
368 const octave_complex_diag_matrix&); 368 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
369 369
370 if (v2.rows () == 1 && v2.columns () == 1) 370 if (v2.rows () == 1 && v2.columns () == 1)
371 { 371 {
372 std::complex<double> d = v2.complex_value (); 372 std::complex<double> d = v2.complex_value ();
373 373
384 } 384 }
385 } 385 }
386 386
387 DEFBINOP (div_scm_cdm, sparse_complex_matrix, complex_diag_matrix) 387 DEFBINOP (div_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
388 { 388 {
389 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 389 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
390 const octave_complex_diag_matrix&); 390 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
391 391
392 if (v2.rows () == 1 && v2.columns () == 1) 392 if (v2.rows () == 1 && v2.columns () == 1)
393 { 393 {
394 std::complex<double> d = v2.complex_value (); 394 std::complex<double> d = v2.complex_value ();
395 395
406 } 406 }
407 } 407 }
408 408
409 DEFBINOP (add_sm_cdm, sparse_matrix, complex_diag_matrix) 409 DEFBINOP (add_sm_cdm, sparse_matrix, complex_diag_matrix)
410 { 410 {
411 CAST_BINOP_ARGS (const octave_sparse_matrix&, 411 const octave_sparse_matrix& v1 = dynamic_cast<const octave_sparse_matrix&> (a1);
412 const octave_complex_diag_matrix&); 412 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
413 413
414 if (v2.rows () == 1 && v2.columns () == 1) 414 if (v2.rows () == 1 && v2.columns () == 1)
415 // If v2 is a scalar in disguise, return a diagonal matrix rather than 415 // If v2 is a scalar in disguise, return a diagonal matrix rather than
416 // a sparse matrix. 416 // a sparse matrix.
417 { 417 {
423 return v1.sparse_matrix_value () + v2.complex_diag_matrix_value (); 423 return v1.sparse_matrix_value () + v2.complex_diag_matrix_value ();
424 } 424 }
425 425
426 DEFBINOP (add_scm_dm, sparse_complex_matrix, diag_matrix) 426 DEFBINOP (add_scm_dm, sparse_complex_matrix, diag_matrix)
427 { 427 {
428 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 428 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
429 const octave_diag_matrix&); 429 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
430 430
431 if (v2.rows () == 1 && v2.columns () == 1) 431 if (v2.rows () == 1 && v2.columns () == 1)
432 // If v2 is a scalar in disguise, return a diagonal matrix rather than 432 // If v2 is a scalar in disguise, return a diagonal matrix rather than
433 // a sparse matrix. 433 // a sparse matrix.
434 { 434 {
440 return v1.sparse_complex_matrix_value () + v2.diag_matrix_value (); 440 return v1.sparse_complex_matrix_value () + v2.diag_matrix_value ();
441 } 441 }
442 442
443 DEFBINOP (add_scm_cdm, sparse_complex_matrix, complex_diag_matrix) 443 DEFBINOP (add_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
444 { 444 {
445 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 445 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
446 const octave_complex_diag_matrix&); 446 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
447 447
448 if (v2.rows () == 1 && v2.columns () == 1) 448 if (v2.rows () == 1 && v2.columns () == 1)
449 // If v2 is a scalar in disguise, return a diagonal matrix rather than 449 // If v2 is a scalar in disguise, return a diagonal matrix rather than
450 // a sparse matrix. 450 // a sparse matrix.
451 { 451 {
457 return v1.sparse_complex_matrix_value () + v2.complex_diag_matrix_value (); 457 return v1.sparse_complex_matrix_value () + v2.complex_diag_matrix_value ();
458 } 458 }
459 459
460 DEFBINOP (sub_sm_cdm, sparse_matrix, complex_diag_matrix) 460 DEFBINOP (sub_sm_cdm, sparse_matrix, complex_diag_matrix)
461 { 461 {
462 CAST_BINOP_ARGS (const octave_sparse_matrix&, 462 const octave_sparse_matrix& v1 = dynamic_cast<const octave_sparse_matrix&> (a1);
463 const octave_complex_diag_matrix&); 463 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
464 464
465 if (v2.rows () == 1 && v2.columns () == 1) 465 if (v2.rows () == 1 && v2.columns () == 1)
466 // If v2 is a scalar in disguise, return a diagonal matrix rather than 466 // If v2 is a scalar in disguise, return a diagonal matrix rather than
467 // a sparse matrix. 467 // a sparse matrix.
468 { 468 {
474 return v1.sparse_matrix_value () - v2.complex_diag_matrix_value (); 474 return v1.sparse_matrix_value () - v2.complex_diag_matrix_value ();
475 } 475 }
476 476
477 DEFBINOP (sub_scm_dm, sparse_complex_matrix, diag_matrix) 477 DEFBINOP (sub_scm_dm, sparse_complex_matrix, diag_matrix)
478 { 478 {
479 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 479 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
480 const octave_diag_matrix&); 480 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
481 481
482 if (v2.rows () == 1 && v2.columns () == 1) 482 if (v2.rows () == 1 && v2.columns () == 1)
483 // If v2 is a scalar in disguise, return a diagonal matrix rather than 483 // If v2 is a scalar in disguise, return a diagonal matrix rather than
484 // a sparse matrix. 484 // a sparse matrix.
485 { 485 {
491 return v1.sparse_complex_matrix_value () - v2.diag_matrix_value (); 491 return v1.sparse_complex_matrix_value () - v2.diag_matrix_value ();
492 } 492 }
493 493
494 DEFBINOP (sub_scm_cdm, sparse_complex_matrix, complex_diag_matrix) 494 DEFBINOP (sub_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
495 { 495 {
496 CAST_BINOP_ARGS (const octave_sparse_complex_matrix&, 496 const octave_sparse_complex_matrix& v1 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
497 const octave_complex_diag_matrix&); 497 const octave_complex_diag_matrix& v2 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
498 498
499 if (v2.rows () == 1 && v2.columns () == 1) 499 if (v2.rows () == 1 && v2.columns () == 1)
500 // If v2 is a scalar in disguise, return a diagonal matrix rather than 500 // If v2 is a scalar in disguise, return a diagonal matrix rather than
501 // a sparse matrix. 501 // a sparse matrix.
502 { 502 {