Mercurial > octave-nkf
annotate libinterp/corefcn/sparse-xdiv.cc @ 20614:10ec79b47808
use new string_value method to handle value extraction errors
* __voronoi__.cc, chol.cc, colamd.cc, fftw.cc:
Use new string_value method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 08 Oct 2015 18:15:56 -0400 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19443
diff
changeset
|
3 Copyright (C) 2004-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5164 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5164 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5164 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include <cassert> | |
29 | |
30 #include "Array-util.h" | |
19442
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
18712
diff
changeset
|
31 #include "lo-array-gripes.h" |
5164 | 32 #include "oct-cmplx.h" |
33 #include "quit.h" | |
34 #include "error.h" | |
9003
0631d397fbe0
replace lo_ieee_isnan by xisnan, add missing includes
Jaroslav Hajek <highegg@gmail.com>
parents:
8965
diff
changeset
|
35 #include "lo-ieee.h" |
5164 | 36 |
37 #include "dSparse.h" | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
38 #include "dDiagMatrix.h" |
5164 | 39 #include "CSparse.h" |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
40 #include "CDiagMatrix.h" |
5164 | 41 #include "oct-spparms.h" |
42 #include "sparse-xdiv.h" | |
43 | |
44 static void | |
45 solve_singularity_warning (double rcond) | |
46 { | |
19442
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
18712
diff
changeset
|
47 gripe_singular_matrix (rcond); |
5164 | 48 } |
49 | |
50 template <class T1, class T2> | |
51 bool | |
52 mx_leftdiv_conform (const T1& a, const T2& b) | |
53 { | |
5275 | 54 octave_idx_type a_nr = a.rows (); |
55 octave_idx_type b_nr = b.rows (); | |
5164 | 56 |
57 if (a_nr != b_nr) | |
58 { | |
5275 | 59 octave_idx_type a_nc = a.cols (); |
60 octave_idx_type b_nc = b.cols (); | |
5164 | 61 |
62 gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc); | |
63 return false; | |
64 } | |
65 | |
66 return true; | |
67 } | |
68 | |
69 #define INSTANTIATE_MX_LEFTDIV_CONFORM(T1, T2) \ | |
70 template bool mx_leftdiv_conform (const T1&, const T2&) | |
71 | |
72 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, SparseMatrix); | |
73 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, SparseComplexMatrix); | |
74 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, SparseMatrix); | |
75 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, SparseComplexMatrix); | |
76 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, Matrix); | |
77 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseMatrix, ComplexMatrix); | |
78 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, Matrix); | |
79 INSTANTIATE_MX_LEFTDIV_CONFORM (SparseComplexMatrix, ComplexMatrix); | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
80 INSTANTIATE_MX_LEFTDIV_CONFORM (DiagMatrix, SparseMatrix); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
81 INSTANTIATE_MX_LEFTDIV_CONFORM (DiagMatrix, SparseComplexMatrix); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
82 INSTANTIATE_MX_LEFTDIV_CONFORM (ComplexDiagMatrix, SparseMatrix); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
83 INSTANTIATE_MX_LEFTDIV_CONFORM (ComplexDiagMatrix, SparseComplexMatrix); |
5164 | 84 |
85 template <class T1, class T2> | |
86 bool | |
87 mx_div_conform (const T1& a, const T2& b) | |
88 { | |
5275 | 89 octave_idx_type a_nc = a.cols (); |
90 octave_idx_type b_nc = b.cols (); | |
5164 | 91 |
92 if (a_nc != b_nc) | |
93 { | |
5275 | 94 octave_idx_type a_nr = a.rows (); |
95 octave_idx_type b_nr = b.rows (); | |
5164 | 96 |
97 gripe_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc); | |
98 return false; | |
99 } | |
100 | |
101 return true; | |
102 } | |
103 | |
104 #define INSTANTIATE_MX_DIV_CONFORM(T1, T2) \ | |
105 template bool mx_div_conform (const T1&, const T2&) | |
106 | |
107 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, SparseMatrix); | |
108 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, SparseComplexMatrix); | |
109 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, SparseMatrix); | |
110 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, SparseComplexMatrix); | |
111 INSTANTIATE_MX_DIV_CONFORM (Matrix, SparseMatrix); | |
112 INSTANTIATE_MX_DIV_CONFORM (Matrix, SparseComplexMatrix); | |
113 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, SparseMatrix); | |
114 INSTANTIATE_MX_DIV_CONFORM (ComplexMatrix, SparseComplexMatrix); | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
115 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, DiagMatrix); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
116 INSTANTIATE_MX_DIV_CONFORM (SparseMatrix, ComplexDiagMatrix); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
117 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, DiagMatrix); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
118 INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, ComplexDiagMatrix); |
5164 | 119 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
120 // Right division functions. X / Y = X * inv (Y) = (inv (Y') * X')' |
5164 | 121 // |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
122 // Y / X: m cm sm scm |
5164 | 123 // +-- +---+----+----+----+ |
124 // sparse matrix | 1 | 3 | 5 | 7 | | |
125 // +---+----+----+----+ | |
126 // sparse complex_matrix | 2 | 4 | 6 | 8 | | |
127 // +---+----+----+----+ | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
128 // diagonal matrix | 9 | 11 | |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
129 // +----+----+ |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
130 // complex diag. matrix | 10 | 12 | |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
131 // +----+----+ |
5164 | 132 |
133 // -*- 1 -*- | |
134 Matrix | |
5785 | 135 xdiv (const Matrix& a, const SparseMatrix& b, MatrixType &typ) |
5164 | 136 { |
137 if (! mx_div_conform (a, b)) | |
138 return Matrix (); | |
139 | |
140 Matrix atmp = a.transpose (); | |
141 SparseMatrix btmp = b.transpose (); | |
5785 | 142 MatrixType btyp = typ.transpose (); |
5164 | 143 |
5275 | 144 octave_idx_type info; |
5681 | 145 double rcond = 0.0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
146 Matrix result = btmp.solve (btyp, atmp, info, rcond, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
147 solve_singularity_warning); |
5164 | 148 |
5322 | 149 typ = btyp.transpose (); |
5164 | 150 return result.transpose (); |
151 } | |
152 | |
153 // -*- 2 -*- | |
154 ComplexMatrix | |
5785 | 155 xdiv (const Matrix& a, const SparseComplexMatrix& b, MatrixType &typ) |
5164 | 156 { |
157 if (! mx_div_conform (a, b)) | |
158 return ComplexMatrix (); | |
159 | |
160 Matrix atmp = a.transpose (); | |
161 SparseComplexMatrix btmp = b.hermitian (); | |
5785 | 162 MatrixType btyp = typ.transpose (); |
5164 | 163 |
5275 | 164 octave_idx_type info; |
5681 | 165 double rcond = 0.0; |
166 ComplexMatrix result | |
167 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); | |
5164 | 168 |
5322 | 169 typ = btyp.transpose (); |
5164 | 170 return result.hermitian (); |
171 } | |
172 | |
173 // -*- 3 -*- | |
174 ComplexMatrix | |
5785 | 175 xdiv (const ComplexMatrix& a, const SparseMatrix& b, MatrixType &typ) |
5164 | 176 { |
177 if (! mx_div_conform (a, b)) | |
178 return ComplexMatrix (); | |
179 | |
180 ComplexMatrix atmp = a.hermitian (); | |
181 SparseMatrix btmp = b.transpose (); | |
5785 | 182 MatrixType btyp = typ.transpose (); |
5164 | 183 |
5275 | 184 octave_idx_type info; |
5681 | 185 double rcond = 0.0; |
186 ComplexMatrix result | |
187 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); | |
5164 | 188 |
5322 | 189 typ = btyp.transpose (); |
5164 | 190 return result.hermitian (); |
191 } | |
192 | |
193 // -*- 4 -*- | |
194 ComplexMatrix | |
5785 | 195 xdiv (const ComplexMatrix& a, const SparseComplexMatrix& b, MatrixType &typ) |
5164 | 196 { |
197 if (! mx_div_conform (a, b)) | |
198 return ComplexMatrix (); | |
199 | |
200 ComplexMatrix atmp = a.hermitian (); | |
201 SparseComplexMatrix btmp = b.hermitian (); | |
5785 | 202 MatrixType btyp = typ.transpose (); |
5164 | 203 |
5275 | 204 octave_idx_type info; |
5681 | 205 double rcond = 0.0; |
206 ComplexMatrix result | |
207 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); | |
5164 | 208 |
5322 | 209 typ = btyp.transpose (); |
5164 | 210 return result.hermitian (); |
211 } | |
212 | |
213 // -*- 5 -*- | |
214 SparseMatrix | |
5785 | 215 xdiv (const SparseMatrix& a, const SparseMatrix& b, MatrixType &typ) |
5164 | 216 { |
217 if (! mx_div_conform (a, b)) | |
218 return SparseMatrix (); | |
219 | |
220 SparseMatrix atmp = a.transpose (); | |
221 SparseMatrix btmp = b.transpose (); | |
5785 | 222 MatrixType btyp = typ.transpose (); |
5164 | 223 |
5275 | 224 octave_idx_type info; |
5681 | 225 double rcond = 0.0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
226 SparseMatrix result = btmp.solve (btyp, atmp, info, rcond, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
227 solve_singularity_warning); |
5164 | 228 |
5322 | 229 typ = btyp.transpose (); |
5164 | 230 return result.transpose (); |
231 } | |
232 | |
233 // -*- 6 -*- | |
234 SparseComplexMatrix | |
5785 | 235 xdiv (const SparseMatrix& a, const SparseComplexMatrix& b, MatrixType &typ) |
5164 | 236 { |
237 if (! mx_div_conform (a, b)) | |
238 return SparseComplexMatrix (); | |
239 | |
240 SparseMatrix atmp = a.transpose (); | |
241 SparseComplexMatrix btmp = b.hermitian (); | |
5785 | 242 MatrixType btyp = typ.transpose (); |
5164 | 243 |
5275 | 244 octave_idx_type info; |
5681 | 245 double rcond = 0.0; |
246 SparseComplexMatrix result | |
247 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); | |
5164 | 248 |
5322 | 249 typ = btyp.transpose (); |
5164 | 250 return result.hermitian (); |
251 } | |
252 | |
253 // -*- 7 -*- | |
254 SparseComplexMatrix | |
5785 | 255 xdiv (const SparseComplexMatrix& a, const SparseMatrix& b, MatrixType &typ) |
5164 | 256 { |
257 if (! mx_div_conform (a, b)) | |
258 return SparseComplexMatrix (); | |
259 | |
260 SparseComplexMatrix atmp = a.hermitian (); | |
261 SparseMatrix btmp = b.transpose (); | |
5785 | 262 MatrixType btyp = typ.transpose (); |
5164 | 263 |
5275 | 264 octave_idx_type info; |
5681 | 265 double rcond = 0.0; |
266 SparseComplexMatrix result | |
267 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); | |
5164 | 268 |
5322 | 269 typ = btyp.transpose (); |
5164 | 270 return result.hermitian (); |
271 } | |
272 | |
273 // -*- 8 -*- | |
274 SparseComplexMatrix | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
275 xdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
276 MatrixType &typ) |
5164 | 277 { |
278 if (! mx_div_conform (a, b)) | |
279 return SparseComplexMatrix (); | |
280 | |
281 SparseComplexMatrix atmp = a.hermitian (); | |
282 SparseComplexMatrix btmp = b.hermitian (); | |
5785 | 283 MatrixType btyp = typ.transpose (); |
5164 | 284 |
5275 | 285 octave_idx_type info; |
5681 | 286 double rcond = 0.0; |
287 SparseComplexMatrix result | |
288 = btmp.solve (btyp, atmp, info, rcond, solve_singularity_warning); | |
5164 | 289 |
5322 | 290 typ = btyp.transpose (); |
5164 | 291 return result.hermitian (); |
292 } | |
293 | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
294 template <typename RT, typename SM, typename DM> |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
295 RT do_rightdiv_sm_dm (const SM& a, const DM& d) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
296 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
297 const octave_idx_type d_nr = d.rows (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
298 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
299 const octave_idx_type a_nr = a.rows (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
300 const octave_idx_type a_nc = a.cols (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
301 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
302 using std::min; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
303 const octave_idx_type nc = min (d_nr, a_nc); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
304 |
18712
6113e0c6920b
maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
305 if (! mx_div_conform (a, d)) |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
306 return RT (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
307 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
308 const octave_idx_type nz = a.nnz (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
309 RT r (a_nr, nc, nz); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
310 |
9196
c229bfb14d8d
avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
311 typedef typename DM::element_type DM_elt_type; |
c229bfb14d8d
avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
312 const DM_elt_type zero = DM_elt_type (); |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
313 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
314 octave_idx_type k_result = 0; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
315 for (octave_idx_type j = 0; j < nc; ++j) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
316 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
317 octave_quit (); |
9196
c229bfb14d8d
avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
318 const DM_elt_type s = d.dgelem (j); |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
319 const octave_idx_type colend = a.cidx (j+1); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
320 r.xcidx (j) = k_result; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
321 if (s != zero) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
322 for (octave_idx_type k = a.cidx (j); k < colend; ++k) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
323 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
324 r.xdata (k_result) = a.data (k) / s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
325 r.xridx (k_result) = a.ridx (k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
326 ++k_result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
327 } |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
328 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
329 r.xcidx (nc) = k_result; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
330 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
331 r.maybe_compress (true); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
332 return r; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
333 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
334 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
335 // -*- 9 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
336 SparseMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
337 xdiv (const SparseMatrix& a, const DiagMatrix& b, MatrixType &) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
338 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
339 return do_rightdiv_sm_dm<SparseMatrix> (a, b); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
340 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
341 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
342 // -*- 10 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
343 SparseComplexMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
344 xdiv (const SparseMatrix& a, const ComplexDiagMatrix& b, MatrixType &) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
345 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
346 return do_rightdiv_sm_dm<SparseComplexMatrix> (a, b); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
347 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
348 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
349 // -*- 11 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
350 SparseComplexMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
351 xdiv (const SparseComplexMatrix& a, const DiagMatrix& b, MatrixType &) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
352 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
353 return do_rightdiv_sm_dm<SparseComplexMatrix> (a, b); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
354 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
355 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
356 // -*- 12 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
357 SparseComplexMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
358 xdiv (const SparseComplexMatrix& a, const ComplexDiagMatrix& b, MatrixType &) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
359 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
360 return do_rightdiv_sm_dm<SparseComplexMatrix> (a, b); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
361 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
362 |
5164 | 363 // Funny element by element division operations. |
364 // | |
365 // op2 \ op1: s cs | |
366 // +-- +---+----+ | |
367 // matrix | 1 | 3 | | |
368 // +---+----+ | |
369 // complex_matrix | 2 | 4 | | |
370 // +---+----+ | |
371 | |
372 Matrix | |
373 x_el_div (double a, const SparseMatrix& b) | |
374 { | |
5275 | 375 octave_idx_type nr = b.rows (); |
376 octave_idx_type nc = b.cols (); | |
5164 | 377 |
378 Matrix result; | |
379 if (a == 0.) | |
380 result = Matrix (nr, nc, octave_NaN); | |
381 else if (a > 0.) | |
382 result = Matrix (nr, nc, octave_Inf); | |
383 else | |
384 result = Matrix (nr, nc, -octave_Inf); | |
385 | |
386 | |
5275 | 387 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
388 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) |
5164 | 389 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
390 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
391 result.elem (b.ridx (i), j) = a / b.data (i); |
5164 | 392 } |
393 | |
394 return result; | |
395 } | |
396 | |
397 ComplexMatrix | |
398 x_el_div (double a, const SparseComplexMatrix& b) | |
399 { | |
5275 | 400 octave_idx_type nr = b.rows (); |
401 octave_idx_type nc = b.cols (); | |
5164 | 402 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
403 ComplexMatrix result (nr, nc, Complex (octave_NaN, octave_NaN)); |
5164 | 404 |
5275 | 405 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
406 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) |
5164 | 407 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
408 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
409 result.elem (b.ridx (i), j) = a / b.data (i); |
5164 | 410 } |
411 | |
412 return result; | |
413 } | |
414 | |
415 ComplexMatrix | |
416 x_el_div (const Complex a, const SparseMatrix& b) | |
417 { | |
5275 | 418 octave_idx_type nr = b.rows (); |
419 octave_idx_type nc = b.cols (); | |
5164 | 420 |
421 ComplexMatrix result (nr, nc, (a / 0.0)); | |
422 | |
5275 | 423 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
424 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) |
5164 | 425 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
426 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
427 result.elem (b.ridx (i), j) = a / b.data (i); |
5164 | 428 } |
429 | |
430 return result; | |
431 } | |
432 | |
433 ComplexMatrix | |
434 x_el_div (const Complex a, const SparseComplexMatrix& b) | |
435 { | |
5275 | 436 octave_idx_type nr = b.rows (); |
437 octave_idx_type nc = b.cols (); | |
5164 | 438 |
439 ComplexMatrix result (nr, nc, (a / 0.0)); | |
440 | |
5275 | 441 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
442 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) |
5164 | 443 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
444 octave_quit (); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
445 result.elem (b.ridx (i), j) = a / b.data (i); |
5164 | 446 } |
447 | |
448 return result; | |
449 } | |
450 | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
451 // Left division functions. X \ Y = inv (X) * Y |
5164 | 452 // |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
453 // Y \ X : sm scm dm dcm |
5164 | 454 // +-- +---+----+ |
455 // matrix | 1 | 5 | | |
456 // +---+----+ | |
457 // complex_matrix | 2 | 6 | | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
458 // +---+----+----+----+ |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
459 // sparse matrix | 3 | 7 | 9 | 11 | |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
460 // +---+----+----+----+ |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
461 // sparse complex_matrix | 4 | 8 | 10 | 12 | |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
462 // +---+----+----+----+ |
5164 | 463 |
464 // -*- 1 -*- | |
465 Matrix | |
5785 | 466 xleftdiv (const SparseMatrix& a, const Matrix& b, MatrixType &typ) |
5164 | 467 { |
468 if (! mx_leftdiv_conform (a, b)) | |
469 return Matrix (); | |
470 | |
5275 | 471 octave_idx_type info; |
5681 | 472 double rcond = 0.0; |
473 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 474 } |
475 | |
476 // -*- 2 -*- | |
477 ComplexMatrix | |
5785 | 478 xleftdiv (const SparseMatrix& a, const ComplexMatrix& b, MatrixType &typ) |
5164 | 479 { |
480 if (! mx_leftdiv_conform (a, b)) | |
481 return ComplexMatrix (); | |
482 | |
5275 | 483 octave_idx_type info; |
5681 | 484 double rcond = 0.0; |
485 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 486 } |
487 | |
488 // -*- 3 -*- | |
489 SparseMatrix | |
5785 | 490 xleftdiv (const SparseMatrix& a, const SparseMatrix& b, MatrixType &typ) |
5164 | 491 { |
492 if (! mx_leftdiv_conform (a, b)) | |
493 return SparseMatrix (); | |
494 | |
5275 | 495 octave_idx_type info; |
5681 | 496 double rcond = 0.0; |
497 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 498 } |
499 | |
500 // -*- 4 -*- | |
501 SparseComplexMatrix | |
5785 | 502 xleftdiv (const SparseMatrix& a, const SparseComplexMatrix& b, MatrixType &typ) |
5164 | 503 { |
504 if (! mx_leftdiv_conform (a, b)) | |
505 return SparseComplexMatrix (); | |
506 | |
5275 | 507 octave_idx_type info; |
5681 | 508 double rcond = 0.0; |
509 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 510 } |
511 | |
512 // -*- 5 -*- | |
513 ComplexMatrix | |
5785 | 514 xleftdiv (const SparseComplexMatrix& a, const Matrix& b, MatrixType &typ) |
5164 | 515 { |
516 if (! mx_leftdiv_conform (a, b)) | |
517 return ComplexMatrix (); | |
518 | |
5275 | 519 octave_idx_type info; |
5681 | 520 double rcond = 0.0; |
521 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 522 } |
523 | |
524 // -*- 6 -*- | |
525 ComplexMatrix | |
5785 | 526 xleftdiv (const SparseComplexMatrix& a, const ComplexMatrix& b, MatrixType &typ) |
5164 | 527 { |
528 if (! mx_leftdiv_conform (a, b)) | |
529 return ComplexMatrix (); | |
530 | |
5275 | 531 octave_idx_type info; |
5681 | 532 double rcond = 0.0; |
533 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 534 } |
535 | |
536 // -*- 7 -*- | |
537 SparseComplexMatrix | |
5785 | 538 xleftdiv (const SparseComplexMatrix& a, const SparseMatrix& b, MatrixType &typ) |
5164 | 539 { |
540 if (! mx_leftdiv_conform (a, b)) | |
541 return SparseComplexMatrix (); | |
542 | |
5275 | 543 octave_idx_type info; |
5681 | 544 double rcond = 0.0; |
545 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 546 } |
547 | |
548 // -*- 8 -*- | |
549 SparseComplexMatrix | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
550 xleftdiv (const SparseComplexMatrix& a, const SparseComplexMatrix& b, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
551 MatrixType &typ) |
5164 | 552 { |
553 if (! mx_leftdiv_conform (a, b)) | |
554 return SparseComplexMatrix (); | |
555 | |
5275 | 556 octave_idx_type info; |
5681 | 557 double rcond = 0.0; |
558 return a.solve (typ, b, info, rcond, solve_singularity_warning); | |
5164 | 559 } |
560 | |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
561 template <typename RT, typename DM, typename SM> |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
562 RT do_leftdiv_dm_sm (const DM& d, const SM& a) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
563 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
564 const octave_idx_type a_nr = a.rows (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
565 const octave_idx_type a_nc = a.cols (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
566 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
567 const octave_idx_type d_nc = d.cols (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
568 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
569 using std::min; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
570 const octave_idx_type nr = min (d_nc, a_nr); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
571 |
18712
6113e0c6920b
maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
572 if (! mx_leftdiv_conform (d, a)) |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
573 return RT (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
574 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
575 const octave_idx_type nz = a.nnz (); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
576 RT r (nr, a_nc, nz); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
577 |
9196
c229bfb14d8d
avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
578 typedef typename DM::element_type DM_elt_type; |
c229bfb14d8d
avoid apparent MSVC bug with typedef
John W. Eaton <jwe@octave.org>
parents:
9003
diff
changeset
|
579 const DM_elt_type zero = DM_elt_type (); |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
580 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
581 octave_idx_type k_result = 0; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
582 for (octave_idx_type j = 0; j < a_nc; ++j) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
583 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
584 octave_quit (); |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
585 const octave_idx_type colend = a.cidx (j+1); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
586 r.xcidx (j) = k_result; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
587 for (octave_idx_type k = a.cidx (j); k < colend; ++k) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
588 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
589 const octave_idx_type i = a.ridx (k); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
590 if (i < nr) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
591 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
592 const DM_elt_type s = d.dgelem (i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
593 if (s != zero) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
594 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
595 r.xdata (k_result) = a.data (k) / s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
596 r.xridx (k_result) = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
597 ++k_result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
598 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
599 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
600 } |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
601 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
602 r.xcidx (a_nc) = k_result; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
603 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
604 r.maybe_compress (true); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
605 return r; |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
606 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
607 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
608 // -*- 9 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
609 SparseMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
610 xleftdiv (const DiagMatrix& d, const SparseMatrix& a, MatrixType&) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
611 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
612 return do_leftdiv_dm_sm<SparseMatrix> (d, a); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
613 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
614 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
615 // -*- 10 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
616 SparseComplexMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
617 xleftdiv (const DiagMatrix& d, const SparseComplexMatrix& a, MatrixType&) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
618 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
619 return do_leftdiv_dm_sm<SparseComplexMatrix> (d, a); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
620 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
621 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
622 // -*- 11 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
623 SparseComplexMatrix |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
624 xleftdiv (const ComplexDiagMatrix& d, const SparseMatrix& a, MatrixType&) |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
625 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
626 return do_leftdiv_dm_sm<SparseComplexMatrix> (d, a); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
627 } |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
628 |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
629 // -*- 12 -*- |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
630 SparseComplexMatrix |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
631 xleftdiv (const ComplexDiagMatrix& d, const SparseComplexMatrix& a, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
632 MatrixType&) |
8965
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
633 { |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
634 return do_leftdiv_dm_sm<SparseComplexMatrix> (d, a); |
42aff15e059b
Implement diag \ sparse and sparse / diag.
Jason Riedy <jason@acm.org>
parents:
7017
diff
changeset
|
635 } |