annotate libinterp/operators/op-dm-scm.cc @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents bd51beb6205e
children b260322f6730
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 2009-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21647
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
28 #endif
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
29
19269
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
30 #include "mx-cm-s.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
31 #include "mx-s-cm.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
32
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
33 #include "mx-dm-cs.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
34 #include "mx-cs-dm.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
35
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
36 #include "mx-m-cs.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
37 #include "mx-cs-m.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
38
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 19697
diff changeset
39 #include "ovl.h"
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
40 #include "ov.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
41 #include "ov-typeinfo.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
42 #include "ops.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
43
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
44 #include "ov-re-diag.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
45 #include "ov-cx-diag.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
46 #include "ov-re-sparse.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
47 #include "ov-cx-sparse.h"
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
48
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
49 #include "sparse-xdiv.h"
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
50
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
51 // diagonal matrix by sparse matrix ops
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
52
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
53 DEFBINOP (mul_dm_scm, diag_matrix, sparse_complex_matrix)
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
54 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
55 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
56 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
57 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
58
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
59 if (v2.rows () == 1 && v2.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
60 // If v2 is a scalar in disguise, return a diagonal matrix rather than
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
61 // a sparse matrix.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
62 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
63 std::complex<double> d = v2.complex_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
64
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
65 return octave_value (v1.diag_matrix_value () * d);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
66 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
67 else
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
68 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
69 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 SparseComplexMatrix ret = v1.diag_matrix_value () *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
71 v2.sparse_complex_matrix_value ();
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
72 octave_value out = octave_value (ret);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
73 typ.mark_as_unsymmetric ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
74 out.matrix_type (typ);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
75 return out;
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
76 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
77 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
78
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
79 DEFBINOP (mul_cdm_sm, complex_diag_matrix, sparse_matrix)
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
80 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
81 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
82 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
83 const octave_sparse_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
84 = dynamic_cast<const octave_sparse_matrix&> (a2);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
85
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
86 if (v2.rows () == 1 && v2.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
87 // If v2 is a scalar in disguise, return a diagonal matrix rather than
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
88 // a sparse matrix.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
89 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
90 std::complex<double> d = v2.scalar_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
91
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
92 return octave_value (v1.complex_diag_matrix_value () * d);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
93 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
94 else
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
95 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
96 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
97 SparseComplexMatrix ret = v1.complex_diag_matrix_value () *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
98 v2.sparse_matrix_value ();
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
99 octave_value out = octave_value (ret);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
100 typ.mark_as_unsymmetric ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
101 out.matrix_type (typ);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
102 return out;
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
103 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
104 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
105
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
106 DEFBINOP (mul_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
107 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
108 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
109 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
110 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
111 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
112
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
113 if (v2.rows () == 1 && v2.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
114 // If v2 is a scalar in disguise, return a diagonal matrix rather than
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
115 // a sparse matrix.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
116 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
117 std::complex<double> d = v2.complex_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
118
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
119 return octave_value (v1.complex_diag_matrix_value () * d);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
120 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
121 else
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
122 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
123 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
124 SparseComplexMatrix ret = v1.complex_diag_matrix_value () *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
125 v2.sparse_complex_matrix_value ();
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
126 octave_value out = octave_value (ret);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
127 typ.mark_as_unsymmetric ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
128 out.matrix_type (typ);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
129 return out;
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
130 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
131 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
132
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
133 DEFBINOP (ldiv_dm_scm, diag_matrix, sparse_complex_matrix)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
134 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
135 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
136 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
137 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
138
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
139 MatrixType typ = v2.matrix_type ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
140 return xleftdiv (v1.diag_matrix_value (), v2.sparse_complex_matrix_value (),
9931
fb6b6fcafa62 untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents: 9732
diff changeset
141 typ);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
142 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
143
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
144 DEFBINOP (ldiv_cdm_sm, complex_diag_matrix, sparse_matrix)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
145 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
146 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
147 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
148 const octave_sparse_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
149 = dynamic_cast<const octave_sparse_matrix&> (a2);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
150
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
151 MatrixType typ = v2.matrix_type ();
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
152 return xleftdiv (v1.complex_diag_matrix_value (), v2.sparse_matrix_value (),
9931
fb6b6fcafa62 untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents: 9732
diff changeset
153 typ);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
154 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
155
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
156 DEFBINOP (ldiv_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
157 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
158 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
159 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
160 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
161 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
162
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
163 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
164 return xleftdiv (v1.complex_diag_matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
165 v2.sparse_complex_matrix_value (),
9931
fb6b6fcafa62 untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents: 9732
diff changeset
166 typ);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
167 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
168
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
169 DEFBINOP (add_dm_scm, diag_matrix, sparse_complex_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
170 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
171 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
172 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
173 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
174
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
175 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
176 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
177 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
178 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
179 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
180
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8966
diff changeset
181 return octave_value (v1.matrix_value () + d);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
182 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
183 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
184 return v1.diag_matrix_value () + v2.sparse_complex_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
185 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
186
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
187 DEFBINOP (add_cdm_sm, complex_diag_matrix, sparse_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
188 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
189 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
190 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
191 const octave_sparse_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
192 = dynamic_cast<const octave_sparse_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
193
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
194 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
195 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
196 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
197 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
198 double d = v2.scalar_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
199
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8966
diff changeset
200 return octave_value (v1.complex_matrix_value () + d);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
201 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
202 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
203 return v1.complex_diag_matrix_value () + v2.sparse_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
204 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
205
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
206 DEFBINOP (add_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
207 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
208 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
209 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
210 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
211 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
212
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
213 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
214 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
215 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
216 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
217 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
218
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8966
diff changeset
219 return octave_value (v1.complex_matrix_value () + d);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
220 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
221 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
222 return v1.complex_diag_matrix_value () + v2.sparse_complex_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
223 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
224
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
225 DEFBINOP (sub_dm_scm, diag_matrix, sparse_complex_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
226 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
227 const octave_diag_matrix& v1 = dynamic_cast<const octave_diag_matrix&> (a1);
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
228 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
229 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
230
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
231 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
232 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
233 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
234 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
235 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
236
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8966
diff changeset
237 return octave_value (v1.matrix_value () + (-d));
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
238 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
239 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
240 return v1.diag_matrix_value () - v2.sparse_complex_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
241 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
242
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
243 DEFBINOP (sub_cdm_sm, complex_diag_matrix, sparse_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
244 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
245 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
246 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
247 const octave_sparse_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
248 = dynamic_cast<const octave_sparse_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
249
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
250 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
251 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
252 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
253 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
254 double d = v2.scalar_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
255
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8966
diff changeset
256 return octave_value (v1.complex_matrix_value () + (-d));
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
257 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
258 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
259 return v1.complex_diag_matrix_value () - v2.sparse_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
260 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
261
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
262 DEFBINOP (sub_cdm_scm, complex_diag_matrix, sparse_complex_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
263 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
264 const octave_complex_diag_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
265 = dynamic_cast<const octave_complex_diag_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
266 const octave_sparse_complex_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
267 = dynamic_cast<const octave_sparse_complex_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
268
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
269 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
270 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
271 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
272 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
273 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
274
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 8966
diff changeset
275 return octave_value (v1.complex_matrix_value () + (-d));
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
276 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
277 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
278 return v1.complex_diag_matrix_value () - v2.sparse_complex_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
279 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
280
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
281 // sparse matrix by diagonal matrix ops
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
282
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
283 DEFBINOP (mul_scm_dm, sparse_complex_matrix, diag_matrix)
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
284 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
285 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
286 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
287 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
288
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
289 if (v1.rows () == 1 && v1.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
290 // If v1 is a scalar in disguise, return a diagonal matrix rather than
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
291 // a sparse matrix.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
292 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
293 std::complex<double> d = v1.complex_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
294
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
295 return octave_value (d * v2.diag_matrix_value ());
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
296 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
297 else
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
298 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
299 MatrixType typ = v1.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
300 SparseComplexMatrix ret = v1.sparse_complex_matrix_value () *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
301 v2.diag_matrix_value ();
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
302 octave_value out = octave_value (ret);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
303 typ.mark_as_unsymmetric ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
304 out.matrix_type (typ);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
305 return out;
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
306 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
307 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
308
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
309 DEFBINOP (mul_sm_cdm, sparse_matrix, complex_diag_matrix)
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
310 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
311 const octave_sparse_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
312 = dynamic_cast<const octave_sparse_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
313 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
314 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
315
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
316 if (v1.rows () == 1 && v1.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
317 // If v1 is a scalar in disguise, return a diagonal matrix rather than
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
318 // a sparse matrix.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
319 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
320 std::complex<double> d = v1.complex_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
321
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
322 return octave_value (d * v2.complex_diag_matrix_value ());
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
323 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
324 else
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
325 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
326 MatrixType typ = v1.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
327 SparseComplexMatrix ret = v1.sparse_matrix_value () *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
328 v2.complex_diag_matrix_value ();
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
329 octave_value out = octave_value (ret);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
330 typ.mark_as_unsymmetric ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
331 out.matrix_type (typ);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
332 return out;
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
333 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
334 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
335
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
336 DEFBINOP (mul_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
337 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
338 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
339 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
340 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
341 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
342
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
343 if (v1.rows () == 1 && v1.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
344 // If v1 is a scalar in disguise, return a diagonal matrix rather than
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
345 // a sparse matrix.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
346 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
347 std::complex<double> d = v1.complex_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
348
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
349 return octave_value (d * v2.complex_diag_matrix_value ());
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
350 }
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
351 else if (v2.rows () == 1 && v2.columns () == 1)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
352 // If v2 is a scalar in disguise, don't bother with further dispatching.
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
353 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
354 std::complex<double> d = v2.complex_value ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
355
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
356 return octave_value (v1.sparse_complex_matrix_value () * d);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
357 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
358 else
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
359 {
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
360 MatrixType typ = v1.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
361 SparseComplexMatrix ret = v1.sparse_complex_matrix_value () *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
362 v2.complex_diag_matrix_value ();
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
363 octave_value out = octave_value (ret);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
364 typ.mark_as_unsymmetric ();
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
365 out.matrix_type (typ);
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
366 return out;
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
367 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
368 }
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
369
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
370 DEFBINOP (div_scm_dm, sparse_complex_matrix, diag_matrix)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
371 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
372 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
373 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
374 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
375
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
376 if (v2.rows () == 1 && v2.columns () == 1)
26596
cc0d942d0e20 Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26376
diff changeset
377 return octave_value (v1.sparse_complex_matrix_value () / v2.scalar_value ());
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
378 else
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
379 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
380 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
381 return xdiv (v1.sparse_complex_matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
382 v2.diag_matrix_value (), typ);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
383 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
384 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
385
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
386 DEFBINOP (div_sm_cdm, sparse_matrix, complex_diag_matrix)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
387 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
388 const octave_sparse_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
389 = dynamic_cast<const octave_sparse_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
390 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
391 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
392
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
393 if (v2.rows () == 1 && v2.columns () == 1)
26596
cc0d942d0e20 Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26376
diff changeset
394 return octave_value (v1.sparse_matrix_value () / v2.complex_value ());
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
395 else
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
396 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
397 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
398 return xdiv (v1.sparse_matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
399 v2.complex_diag_matrix_value (), typ);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
400 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
401 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
402
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
403 DEFBINOP (div_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
404 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
405 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
406 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
407 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
408 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
409
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
410 if (v2.rows () == 1 && v2.columns () == 1)
26596
cc0d942d0e20 Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26376
diff changeset
411 return octave_value (v1.sparse_complex_matrix_value () / v2.complex_value ());
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
412 else
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
413 {
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
414 MatrixType typ = v2.matrix_type ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
415 return xdiv (v1.sparse_complex_matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
416 v2.complex_diag_matrix_value (), typ);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
417 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
418 }
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
419
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
420 DEFBINOP (add_sm_cdm, sparse_matrix, complex_diag_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
421 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
422 const octave_sparse_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
423 = dynamic_cast<const octave_sparse_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
424 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
425 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
426
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
427 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
428 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
429 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
430 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
431 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
432
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
433 return octave_value (v1.sparse_matrix_value () + d);
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
434 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
435 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
436 return v1.sparse_matrix_value () + v2.complex_diag_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
437 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
438
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
439 DEFBINOP (add_scm_dm, sparse_complex_matrix, diag_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
440 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
441 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
442 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
443 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
444
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
445 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
446 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
447 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
448 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
449 double d = v2.scalar_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
450
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
451 return octave_value (v1.sparse_complex_matrix_value () + d);
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
452 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
453 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
454 return v1.sparse_complex_matrix_value () + v2.diag_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
455 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
456
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
457 DEFBINOP (add_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
458 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
459 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
460 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
461 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
462 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
463
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
464 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
465 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
466 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
467 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
468 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
469
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
470 return octave_value (v1.sparse_complex_matrix_value () + d);
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
471 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
472 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
473 return v1.sparse_complex_matrix_value () + v2.complex_diag_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
474 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
475
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
476 DEFBINOP (sub_sm_cdm, sparse_matrix, complex_diag_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
477 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
478 const octave_sparse_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
479 = dynamic_cast<const octave_sparse_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
480 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
481 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
482
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
483 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
484 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
485 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
486 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
487 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
488
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
489 return octave_value (v1.sparse_matrix_value () + (-d));
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
490 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
491 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
492 return v1.sparse_matrix_value () - v2.complex_diag_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
493 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
494
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
495 DEFBINOP (sub_scm_dm, sparse_complex_matrix, diag_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
496 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
497 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
498 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
499 const octave_diag_matrix& v2 = dynamic_cast<const octave_diag_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
500
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
501 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
502 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
503 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
504 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
505 double d = v2.scalar_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
506
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
507 return octave_value (v1.sparse_complex_matrix_value () + (-d));
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
508 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
509 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
510 return v1.sparse_complex_matrix_value () - v2.diag_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
511 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
512
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
513 DEFBINOP (sub_scm_cdm, sparse_complex_matrix, complex_diag_matrix)
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
514 {
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
515 const octave_sparse_complex_matrix& v1
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
516 = dynamic_cast<const octave_sparse_complex_matrix&> (a1);
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
517 const octave_complex_diag_matrix& v2
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
518 = dynamic_cast<const octave_complex_diag_matrix&> (a2);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
519
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
520 if (v2.rows () == 1 && v2.columns () == 1)
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
521 // If v2 is a scalar in disguise, return a diagonal matrix rather than
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
522 // a sparse matrix.
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
523 {
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
524 std::complex<double> d = v2.complex_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
525
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
526 return octave_value (v1.sparse_complex_matrix_value () + (-d));
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
527 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
528 else
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
529 return v1.sparse_complex_matrix_value () - v2.complex_diag_matrix_value ();
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
530 }
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
531
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
532 void
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
533 install_dm_scm_ops (octave::type_info& ti)
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
534 {
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
535 INSTALL_BINOP_TI (ti, op_mul, octave_diag_matrix, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
536 mul_dm_scm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
537 INSTALL_BINOP_TI (ti, op_mul, octave_complex_diag_matrix, octave_sparse_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
538 mul_cdm_sm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
539 INSTALL_BINOP_TI (ti, op_mul, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
540 octave_sparse_complex_matrix, mul_cdm_scm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
541 INSTALL_BINOP_TI (ti, op_ldiv, octave_diag_matrix, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
542 ldiv_dm_scm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
543 INSTALL_BINOP_TI (ti, op_ldiv, octave_complex_diag_matrix, octave_sparse_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
544 ldiv_cdm_sm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
545 INSTALL_BINOP_TI (ti, op_ldiv, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
546 octave_sparse_complex_matrix, ldiv_cdm_scm);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
547
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
548 INSTALL_BINOP_TI (ti, op_add, octave_diag_matrix, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
549 add_dm_scm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
550 INSTALL_BINOP_TI (ti, op_add, octave_complex_diag_matrix, octave_sparse_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
551 add_cdm_sm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
552 INSTALL_BINOP_TI (ti, op_add, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
553 octave_sparse_complex_matrix, add_cdm_scm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
554 INSTALL_BINOP_TI (ti, op_sub, octave_diag_matrix, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
555 sub_dm_scm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
556 INSTALL_BINOP_TI (ti, op_sub, octave_complex_diag_matrix, octave_sparse_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
557 sub_cdm_sm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
558 INSTALL_BINOP_TI (ti, op_sub, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
559 octave_sparse_complex_matrix, sub_cdm_scm);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
560
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
561 INSTALL_BINOP_TI (ti, op_mul, octave_sparse_complex_matrix, octave_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
562 mul_scm_dm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
563 INSTALL_BINOP_TI (ti, op_mul, octave_sparse_matrix, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
564 mul_sm_cdm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
565 INSTALL_BINOP_TI (ti, op_mul, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
566 octave_complex_diag_matrix, mul_scm_cdm);
8965
42aff15e059b Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents: 8964
diff changeset
567
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
568 INSTALL_BINOP_TI (ti, op_div, octave_sparse_complex_matrix, octave_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
569 div_scm_dm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
570 INSTALL_BINOP_TI (ti, op_div, octave_sparse_matrix, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
571 div_sm_cdm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
572 INSTALL_BINOP_TI (ti, op_div, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
573 octave_complex_diag_matrix, div_scm_cdm);
8966
1bba53c0a38d Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag.
Jason Riedy <jason@acm.org>
parents: 8965
diff changeset
574
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
575 INSTALL_BINOP_TI (ti, op_add, octave_sparse_complex_matrix, octave_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
576 add_scm_dm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
577 INSTALL_BINOP_TI (ti, op_add, octave_sparse_matrix, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
578 add_sm_cdm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
579 INSTALL_BINOP_TI (ti, op_add, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
580 octave_complex_diag_matrix, add_scm_cdm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
581 INSTALL_BINOP_TI (ti, op_sub, octave_sparse_complex_matrix, octave_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
582 sub_scm_dm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
583 INSTALL_BINOP_TI (ti, op_sub, octave_sparse_matrix, octave_complex_diag_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
584 sub_sm_cdm);
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
585 INSTALL_BINOP_TI (ti, op_sub, octave_sparse_complex_matrix,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
586 octave_complex_diag_matrix, sub_scm_cdm);
8964
f4f4d65faaa0 Implement sparse * diagonal and diagonal * sparse operations, double-prec only.
Jason Riedy <jason@acm.org>
parents:
diff changeset
587 }