annotate liboctave/numeric/sparse-qr.cc @ 31249:de6fc38c78c6

Make Jacobian types offered by dlsode.f accessible by lsode (bug #31626). * liboctave/numeric/LSODE-opts.in: Add options "jacobian type", "lower jacobian subdiagonals", and "upper jacobian subdiagonals". * liboctave/numeric/LSODE.cc (file scope, lsode_j, LSODE::do_integrate (double)): Handle new configurable Jacobian types. * build-aux/mk-opts.pl: Don't implicitly convert to integer in condition.
author Olaf Till <olaf.till@uni-jena.de>
date Fri, 12 Nov 2010 08:53:05 +0100
parents 796f54d4ddbf
children fa4bb329a51a
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30520
diff changeset
3 // Copyright (C) 2005-2022 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 ////////////////////////////////////////////////////////////////////////
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21215
diff changeset
27 # include "config.h"
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
30 #include "CMatrix.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
31 #include "CSparse.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
32 #include "MArray.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
33 #include "dColVector.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
34 #include "dMatrix.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
35 #include "dSparse.h"
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "lo-error.h"
21186
7f35125714b4 don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents: 21177
diff changeset
37 #include "oct-locbuf.h"
7f35125714b4 don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents: 21177
diff changeset
38 #include "oct-sparse.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
39 #include "quit.h"
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "sparse-qr.h"
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
42 namespace octave
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
43 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
44 namespace math
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
45 {
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
46 #if defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
47 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
48 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
49 cxsparse_types
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
50 { };
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
51
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
52 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
53 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
54 cxsparse_types<SparseMatrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
55 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
56 public:
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
57 typedef CXSPARSE_DNAME (s) symbolic_type;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
58 typedef CXSPARSE_DNAME (n) numeric_type;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
59 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
60
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
61 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
62 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
63 cxsparse_types<SparseComplexMatrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
64 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
65 public:
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
66 typedef CXSPARSE_ZNAME (s) symbolic_type;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
67 typedef CXSPARSE_ZNAME (n) numeric_type;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
68 };
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
70
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
71 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
72 class sparse_qr<SPARSE_T>::sparse_qr_rep
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
73 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
74 public:
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
75
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
76 sparse_qr_rep (const SPARSE_T& a, int order);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
77
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
78 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
79
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
80 sparse_qr_rep (const sparse_qr_rep&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
81
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
82 sparse_qr_rep& operator = (const sparse_qr_rep&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
83
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
84 ~sparse_qr_rep (void);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
85
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
86 bool ok (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
87 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
88 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
89 return (m_H && m_Htau && m_HPinv && m_R && m_E);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
90 #elif defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
91 return (N && S);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 #else
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
93 return false;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
95 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
96
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
97 SPARSE_T V (void) const;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
98
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
99 ColumnVector Pinv (void) const;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
100
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
101 ColumnVector P (void) const;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
102
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
103 ColumnVector E (void) const;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
104
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
105 SPARSE_T R (bool econ) const;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
106
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
107 typename SPARSE_T::dense_matrix_type
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
108 C (const typename SPARSE_T::dense_matrix_type& b, bool econ = false);
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
109
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
110 typename SPARSE_T::dense_matrix_type Q (bool econ = false);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
111
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
112 octave_idx_type nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
113 octave_idx_type ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
114
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
115 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
116
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
117 template <typename RHS_T, typename RET_T>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
118 RET_T solve (const RHS_T& b, octave_idx_type& info) const;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
119
29260
18ad3c01fc2a sparse-qr.cc: Fix compilation with CXSparse and SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29259
diff changeset
120 #endif
18ad3c01fc2a sparse-qr.cc: Fix compilation with CXSparse and SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29259
diff changeset
121
18ad3c01fc2a sparse-qr.cc: Fix compilation with CXSparse and SPQR (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29259
diff changeset
122 #if defined (HAVE_CXSPARSE)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
123
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
124 typename cxsparse_types<SPARSE_T>::symbolic_type *S;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
125 typename cxsparse_types<SPARSE_T>::numeric_type *N;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
126
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
127 #endif
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
128
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
129 template <typename RHS_T, typename RET_T>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
130 RET_T tall_solve (const RHS_T& b, octave_idx_type& info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
131
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
132 template <typename RHS_T, typename RET_T>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
133 RET_T wide_solve (const RHS_T& b, octave_idx_type& info) const;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
134
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
135 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
136
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
137 private:
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
138
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
139 cholmod_common m_cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
140 cholmod_sparse *m_R; // R factor
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
141 // Column permutation for A. Fill-reducing ordering.
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
142 SuiteSparse_long *m_E;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
143 cholmod_sparse *m_H; // Householder vectors
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
144 cholmod_dense *m_Htau; // beta scalars
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
145 SuiteSparse_long *m_HPinv;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
146
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
147 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
148 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
149
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
150 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
151 ColumnVector
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
152 sparse_qr<SPARSE_T>::sparse_qr_rep::Pinv (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
153 {
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
154 #if defined (HAVE_CXSPARSE)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
155
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
156 ColumnVector ret (N->L->m);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
157
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
158 for (octave_idx_type i = 0; i < N->L->m; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
159 ret.xelem (i) = S->pinv[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
160
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
161 return ret;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
162
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
164
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
165 return ColumnVector ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
166
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
168 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
169
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
170 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
171 ColumnVector
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
172 sparse_qr<SPARSE_T>::sparse_qr_rep::P (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
173 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
174 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
175
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
176 ColumnVector ret (nrows);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
177
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
178 // FIXME: Is ret.xelem (m_HPinv[i]) = i + 1 correct?
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
179 for (octave_idx_type i = 0; i < nrows; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
180 ret.xelem (from_suitesparse_long (m_HPinv[i])) = i + 1;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
181
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
182 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
183
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
184 #elif defined (HAVE_CXSPARSE)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
185
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
186 ColumnVector ret (N->L->m);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
187
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
188 for (octave_idx_type i = 0; i < N->L->m; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
189 ret.xelem (S->pinv[i]) = i;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
190
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
191 return ret;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
192
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
194
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
195 return ColumnVector ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
196
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
198 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
199
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
200 template <typename SPARSE_T>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
201 ColumnVector
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
202 sparse_qr<SPARSE_T>::sparse_qr_rep::E (void) const
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
203 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
204 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
205
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
206 ColumnVector ret (ncols);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
207
30520
ab00b8b7355f sparse-qr.cc: SPQR E identity value is represented by nullptr.
Gene Harvey <gharveymn@gmail.com>
parents: 30394
diff changeset
208 if (m_E)
ab00b8b7355f sparse-qr.cc: SPQR E identity value is represented by nullptr.
Gene Harvey <gharveymn@gmail.com>
parents: 30394
diff changeset
209 for (octave_idx_type i = 0; i < ncols; i++)
ab00b8b7355f sparse-qr.cc: SPQR E identity value is represented by nullptr.
Gene Harvey <gharveymn@gmail.com>
parents: 30394
diff changeset
210 ret(i) = from_suitesparse_long (m_E[i]) + 1;
ab00b8b7355f sparse-qr.cc: SPQR E identity value is represented by nullptr.
Gene Harvey <gharveymn@gmail.com>
parents: 30394
diff changeset
211 else
ab00b8b7355f sparse-qr.cc: SPQR E identity value is represented by nullptr.
Gene Harvey <gharveymn@gmail.com>
parents: 30394
diff changeset
212 for (octave_idx_type i = 0; i < ncols; i++)
ab00b8b7355f sparse-qr.cc: SPQR E identity value is represented by nullptr.
Gene Harvey <gharveymn@gmail.com>
parents: 30394
diff changeset
213 ret(i) = i + 1;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
214
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
215 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
216
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
217 #else
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
218
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
219 return ColumnVector ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
220
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
221 #endif
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
222 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
223
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
224 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
225
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
226 // Convert real sparse octave matrix to real sparse cholmod matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
227 // Returns a "shallow" copy of a.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
228 static cholmod_sparse
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
229 ros2rcs (const SparseMatrix& a)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
230 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
231 cholmod_sparse A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
232
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
233 octave_idx_type ncols = a.cols ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
234 octave_idx_type nnz = a.nnz ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
235
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
236 A.ncol = ncols;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
237 A.nrow = a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
238 A.itype = CHOLMOD_LONG;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
239 A.nzmax = nnz;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
240 A.sorted = 0;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
241 A.packed = 1;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
242 A.stype = 0;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
243 A.xtype = CHOLMOD_REAL;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
244 A.dtype = CHOLMOD_DOUBLE;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
245 A.nz = nullptr;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
246 A.z = nullptr;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
247 if (sizeof (octave_idx_type) == sizeof (SuiteSparse_long))
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
248 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
249 A.p = reinterpret_cast<SuiteSparse_long *> (a.cidx ());
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
250 A.i = reinterpret_cast<SuiteSparse_long *> (a.ridx ());
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
251 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
252 else
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
253 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
254 SuiteSparse_long *A_p;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
255 A_p = new SuiteSparse_long[ncols+1];
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
256 for (octave_idx_type i = 0; i < ncols+1; i++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
257 A_p[i] = a.cidx (i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
258 A.p = A_p;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
259 SuiteSparse_long *A_i;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
260 A_i = new SuiteSparse_long[nnz];
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
261 for (octave_idx_type i = 0; i < nnz; i++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
262 A_i[i] = a.ridx (i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
263 A.i = A_i;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
264 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
265 A.x = const_cast<double *> (a.data ());
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
266
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
267 return A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
268 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
269
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
270 // Convert complex sparse octave matrix to complex sparse cholmod matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
271 // Returns a "shallow" copy of a.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
272 static cholmod_sparse
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
273 cos2ccs (const SparseComplexMatrix& a)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
274 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
275 cholmod_sparse A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
277 octave_idx_type ncols = a.cols ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
278 octave_idx_type nnz = a.nnz ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
279
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
280 A.ncol = ncols;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
281 A.nrow = a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
282 A.itype = CHOLMOD_LONG;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
283 A.nzmax = nnz;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
284 A.sorted = 0;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
285 A.packed = 1;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
286 A.stype = 0;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
287 A.xtype = CHOLMOD_COMPLEX;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
288 A.dtype = CHOLMOD_DOUBLE;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
289 A.nz = nullptr;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
290 A.z = nullptr;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
291 if (sizeof (octave_idx_type) == sizeof (SuiteSparse_long))
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
292 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
293 A.p = reinterpret_cast<SuiteSparse_long *> (a.cidx ());
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
294 A.i = reinterpret_cast<SuiteSparse_long *> (a.ridx ());
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
295 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
296 else
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
297 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
298 SuiteSparse_long *A_p;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
299 A_p = new SuiteSparse_long[ncols+1];
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
300 for (octave_idx_type i = 0; i < ncols+1; i++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
301 A_p[i] = a.cidx (i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
302 A.p = A_p;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
303 SuiteSparse_long *A_i;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
304 A_i = new SuiteSparse_long[nnz];
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
305 for (octave_idx_type i = 0; i < nnz; i++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
306 A_i[i] = a.ridx (i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
307 A.i = A_i;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
308 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
309 A.x = const_cast<Complex *>
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
310 (reinterpret_cast<const Complex *> (a.data ()));
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
311
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
312 return A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
313 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
314
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
315 // Convert real dense octave matrix to complex dense cholmod matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
316 // Returns a "deep" copy of a.
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
317 static cholmod_dense *
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
318 rod2ccd (const MArray<double>& a, cholmod_common *cc1)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
319 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
320 cholmod_dense *A
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
321 = cholmod_l_allocate_dense (a.rows (), a.cols (), a.rows(),
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
322 CHOLMOD_COMPLEX, cc1);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
323
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
324 const double *a_x = a.data ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
325
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
326 Complex *A_x = reinterpret_cast<Complex *> (A->x);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
327 for (octave_idx_type j = 0; j < a.cols() * a.rows() ; j++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
328 A_x[j] = Complex (a_x[j], 0.0);
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
329
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
330 return A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
331 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
332
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
333 // Convert real dense octave matrix to real dense cholmod matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
334 // Returns a "shallow" copy of a.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
335 static cholmod_dense
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
336 rod2rcd (const MArray<double>& a)
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
337 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
338 cholmod_dense A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
339
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
340 A.ncol = a.cols ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
341 A.nrow = a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
342 A.nzmax = a.cols () * a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
343 A.xtype = CHOLMOD_REAL;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
344 A.dtype = CHOLMOD_DOUBLE;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
345 A.z = nullptr;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
346 A.d = a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
347 A.x = const_cast<double *> (a.data ());
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
348
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
349 return A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
350 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
351
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
352 // Convert complex dense octave matrix to complex dense cholmod matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
353 // Returns a "shallow" copy of a.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
354 static cholmod_dense
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
355 cod2ccd (const ComplexMatrix& a)
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
356 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
357 cholmod_dense A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
358
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
359 A.ncol = a.cols ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
360 A.nrow = a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
361 A.nzmax = a.cols () * a.rows ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
362 A.xtype = CHOLMOD_COMPLEX;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
363 A.dtype = CHOLMOD_DOUBLE;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
364 A.z = nullptr;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
365 A.d = a.rows ();
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
366 A.x = const_cast<Complex *> (reinterpret_cast<const Complex *> (a.data ()));
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
367
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
368 return A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
369 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
370
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
371 // Convert real sparse cholmod matrix to real sparse octave matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
372 // Returns a "shallow" copy of y.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
373 static SparseMatrix
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
374 rcs2ros (const cholmod_sparse* y)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
375 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
376 octave_idx_type nrow = from_size_t (y->nrow);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
377 octave_idx_type ncol = from_size_t (y->ncol);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
378 octave_idx_type nz = from_size_t (y->nzmax);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
379 SparseMatrix ret (nrow, ncol, nz);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
380
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
381 SuiteSparse_long *y_p = reinterpret_cast<SuiteSparse_long *> (y->p);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
382 for (octave_idx_type j = 0; j < ncol + 1; j++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
383 ret.xcidx (j) = from_suitesparse_long (y_p[j]);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
384
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
385 SuiteSparse_long *y_i = reinterpret_cast<SuiteSparse_long *> (y->i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
386 double *y_x = reinterpret_cast<double *> (y->x);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
387 for (octave_idx_type j = 0; j < nz; j++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
388 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
389 ret.xridx (j) = from_suitesparse_long (y_i[j]);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
390 ret.xdata (j) = y_x[j];
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
391 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
392
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
393 return ret;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
394 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
395
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
396 // Convert complex sparse cholmod matrix to complex sparse octave matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
397 // Returns a "deep" copy of a.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
398 static SparseComplexMatrix
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
399 ccs2cos (const cholmod_sparse *a)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
400 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
401 octave_idx_type nrow = from_size_t (a->nrow);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
402 octave_idx_type ncol = from_size_t (a->ncol);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
403 octave_idx_type nz = from_size_t (a->nzmax);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
404 SparseComplexMatrix ret (nrow, ncol, nz);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
405
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
406 SuiteSparse_long *a_p = reinterpret_cast<SuiteSparse_long *> (a->p);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
407 for (octave_idx_type j = 0; j < ncol + 1; j++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
408 ret.xcidx(j) = from_suitesparse_long (a_p[j]);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
409
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
410 SuiteSparse_long *a_i = reinterpret_cast<SuiteSparse_long *> (a->i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
411 Complex *a_x = reinterpret_cast<Complex *> (a->x);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
412 for (octave_idx_type j = 0; j < nz; j++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
413 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
414 ret.xridx(j) = from_suitesparse_long (a_i[j]);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
415 ret.xdata(j) = a_x[j];
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
416 }
29434
91f32bf0d497 maint: strip trailing spaces from code base.
Rik <rik@octave.org>
parents: 29399
diff changeset
417
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
418 return ret;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
419 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
420
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
421 // Convert real sparse octave matrix to complex sparse cholmod matrix.
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
422 // Returns a "deep" copy of a.
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
423 static cholmod_sparse *
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
424 ros2ccs (const SparseMatrix& a, cholmod_common *cc)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
425 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
426 cholmod_sparse *A
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
427 = cholmod_l_allocate_sparse (a.rows (), a.cols (), a.nnz (), 0, 1, 0,
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
428 CHOLMOD_COMPLEX, cc);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
429
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
430 octave_idx_type ncol = a.cols ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
431 SuiteSparse_long *A_p = reinterpret_cast<SuiteSparse_long *> (A->p);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
432 for (octave_idx_type j = 0; j < ncol + 1; j++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
433 A_p[j] = a.cidx(j);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
434
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
435 const double *a_x = a.data ();
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
436 Complex *A_x = reinterpret_cast<Complex *> (A->x);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
437 SuiteSparse_long *A_i = reinterpret_cast<SuiteSparse_long *> (A->i);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
438 for (octave_idx_type j = 0; j < a.nnz (); j++)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
439 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
440 A_x[j] = Complex (a_x[j], 0.0);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
441 A_i[j] = a.ridx(j);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
442 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
443 return A;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
444 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
445
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
446 static suitesparse_integer
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
447 suitesparse_long_to_suitesparse_integer (SuiteSparse_long x)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
448 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
449 if (x < std::numeric_limits<suitesparse_integer>::min ()
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
450 || x > std::numeric_limits<suitesparse_integer>::max ())
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
451 (*current_liboctave_error_handler)
29276
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
452 ("integer dimension or index out of range for SuiteSparse's indexing type");
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
453
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
454 return static_cast<suitesparse_integer> (x);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
455 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
456
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
457 static void
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
458 spqr_error_handler (const cholmod_common *cc)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
459 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
460 if (cc->status >= 0)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
461 return;
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
462
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
463 switch (cc->status)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
464 {
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
465 case CHOLMOD_OUT_OF_MEMORY:
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
466 (*current_liboctave_error_handler)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
467 ("sparse_qr: sparse matrix QR factorization failed"
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
468 " - out of memory");
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
469 case CHOLMOD_TOO_LARGE:
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
470 (*current_liboctave_error_handler)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
471 ("sparse_qr: sparse matrix QR factorization failed"
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
472 " - integer overflow occurred");
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
473 default:
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
474 (*current_liboctave_error_handler)
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
475 ("sparse_qr: sparse matrix QR factorization failed"
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
476 " - error %d", cc->status);
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
477 }
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
478
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
479 // FIXME: Free memory?
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
480 // FIXME: Can cc-status > 0 (CHOLMOD_NOT_POSDEF, CHOLMOD_DSMALL) occur?
62198e9d525f sparse-qr.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents: 29274
diff changeset
481 }
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
482 #endif
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
483
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
484 // Specializations.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
485
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
486 // Real-valued matrices.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
487
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
488 // Arguments for parameter order (taken from SuiteSparseQR documentation).
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
489 // 0: fixed ordering 0 (no permutation of columns)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
490 // 1: natural ordering 1 (only singleton columns are permuted to the left of
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
491 // the matrix)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
492 // 2: colamd
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
493 // 3:
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
494 // 4: CHOLMOD best-effort (COLAMD, METIS,...)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
495 // 5: AMD(a'*a)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
496 // 6: metis(a'*a)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
497 // 7: SuiteSparseQR default ordering
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
498 // 8: try COLAMD, AMD, and METIS; pick best
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
499 // 9: try COLAMD and AMD; pick best
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
500 //FIXME: What is order = 3?
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
501 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
502 sparse_qr<SparseMatrix>::sparse_qr_rep::sparse_qr_rep
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
503 (const SparseMatrix& a, int order)
29564
bffdb54e78da use shared_ptr to manage memory for sparse chol and qr classes
John W. Eaton <jwe@octave.org>
parents: 29434
diff changeset
504 : nrows (a.rows ()), ncols (a.columns ())
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
505 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
506 , m_cc (), m_R (nullptr), m_E (nullptr), m_H (nullptr), m_Htau (nullptr),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
507 m_HPinv (nullptr)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
508 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
509 octave_idx_type nr = a.rows ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
510 octave_idx_type nc = a.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
511
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
512 if (nr <= 0 || nc <= 0)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
513 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
514 ("matrix dimension with negative or zero size");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
515
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
516 if (order < 0 || order > 9)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
517 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
518 ("ordering %d is not supported by SPQR", order);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
519
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
520 cholmod_l_start (&m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
521 cholmod_sparse A = ros2rcs (a);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
522
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
523 SuiteSparseQR<double> (order, static_cast<double> (SPQR_DEFAULT_TOL),
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
524 static_cast<SuiteSparse_long> (A.nrow),
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
525 &A, &m_R, &m_E, &m_H, &m_HPinv, &m_Htau, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
526 spqr_error_handler (&m_cc);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
527
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
528 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
529 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
530 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
531 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
532 }
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
533 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
534
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
535 #elif defined (HAVE_CXSPARSE)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23696
diff changeset
536 , S (nullptr), N (nullptr)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
537 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
538 CXSPARSE_DNAME () A;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
539
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
540 A.nzmax = a.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
541 A.m = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
542 A.n = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
543 // Cast away const on A, with full knowledge that CSparse won't touch it
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
544 // Prevents the methods below making a copy of the data.
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
545 A.p = const_cast<suitesparse_integer *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
546 (to_suitesparse_intptr (a.cidx ()));
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
547 A.i = const_cast<suitesparse_integer *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
548 (to_suitesparse_intptr (a.ridx ()));
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
549 A.x = const_cast<double *> (a.data ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
550 A.nz = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
551
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
552 S = CXSPARSE_DNAME (_sqr) (order, &A, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
553 N = CXSPARSE_DNAME (_qr) (&A, S);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
554
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
555 if (! N)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
556 (*current_liboctave_error_handler)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
557 ("sparse_qr: sparse matrix QR factorization filled");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
558
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
559 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
560
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
562
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
563 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
564 octave_unused_parameter (order);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
565
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
566 (*current_liboctave_error_handler)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
567 ("sparse_qr: support for SPQR or CXSparse was unavailable or disabled when liboctave was built");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
568 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
569
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
570 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
571
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
572 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
573 sparse_qr<SparseMatrix>::sparse_qr_rep::~sparse_qr_rep (void)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
574 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
575 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
576
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
577 cholmod_l_free_sparse (&m_R, &m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
578 cholmod_l_free_sparse (&m_H, &m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
579 cholmod_l_free_dense (&m_Htau, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
580 free (m_E); // FIXME: use cholmod_l_free
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
581 free (m_HPinv);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
582 cholmod_l_finish (&m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
583
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
584 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
585
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
586 CXSPARSE_DNAME (_sfree) (S);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
587 CXSPARSE_DNAME (_nfree) (N);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
588
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
590 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
591
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
592 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
593 SparseMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
594 sparse_qr<SparseMatrix>::sparse_qr_rep::V (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
595 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
596 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
597
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
598 return rcs2ros (m_H);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
599
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
600 #elif defined (HAVE_CXSPARSE)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
601
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
602 // Drop zeros from V and sort
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
603 // FIXME: Is the double transpose to sort necessary?
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
604
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
605 CXSPARSE_DNAME (_dropzeros) (N->L);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
606 CXSPARSE_DNAME () *D = CXSPARSE_DNAME (_transpose) (N->L, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
607 CXSPARSE_DNAME (_spfree) (N->L);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
608 N->L = CXSPARSE_DNAME (_transpose) (D, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
609 CXSPARSE_DNAME (_spfree) (D);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
610
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
611 octave_idx_type nc = N->L->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
612 octave_idx_type nz = N->L->nzmax;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
613 SparseMatrix ret (N->L->m, nc, nz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
614
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
615 for (octave_idx_type j = 0; j < nc+1; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
616 ret.xcidx (j) = N->L->p[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
617
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
618 for (octave_idx_type j = 0; j < nz; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
619 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
620 ret.xridx (j) = N->L->i[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
621 ret.xdata (j) = N->L->x[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
622 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
623
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
624 return ret;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
625
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
627
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
628 return SparseMatrix ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
629
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
631 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
632
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
633 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
634 SparseMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
635 sparse_qr<SparseMatrix>::sparse_qr_rep::R (bool econ) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
636 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
637 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
638
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
639 octave_idx_type nr = static_cast<octave_idx_type> (m_R->nrow);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
640 octave_idx_type nc = static_cast<octave_idx_type> (m_R->ncol);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
641 octave_idx_type nz = static_cast<octave_idx_type> (m_R->nzmax);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
642
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
643 // FIXME: Does this work if econ = true?
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
644 SparseMatrix ret ((econ ? (nc > nr ? nr : nc) : nr), nc, nz);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
645 SuiteSparse_long *Rp = reinterpret_cast<SuiteSparse_long *> (m_R->p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
646 SuiteSparse_long *Ri = reinterpret_cast<SuiteSparse_long *> (m_R->i);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
647
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
648 for (octave_idx_type j = 0; j < nc + 1; j++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
649 ret.xcidx (j) = from_suitesparse_long (Rp[j]);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
650
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
651 for (octave_idx_type j = 0; j < nz; j++)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
652 {
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
653 ret.xridx (j) = from_suitesparse_long (Ri[j]);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
654 ret.xdata (j) = (reinterpret_cast<double *> (m_R->x))[j];
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
655 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
656
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
657 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
658
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
659 #elif defined (HAVE_CXSPARSE)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
660
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
661 // Drop zeros from R and sort
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
662 // FIXME: Is the double transpose to sort necessary?
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
663
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
664 CXSPARSE_DNAME (_dropzeros) (N->U);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
665 CXSPARSE_DNAME () *D = CXSPARSE_DNAME (_transpose) (N->U, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
666 CXSPARSE_DNAME (_spfree) (N->U);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
667 N->U = CXSPARSE_DNAME (_transpose) (D, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
668 CXSPARSE_DNAME (_spfree) (D);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
669
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
670 octave_idx_type nc = N->U->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
671 octave_idx_type nz = N->U->nzmax;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
672
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
673 SparseMatrix ret ((econ ? (nc > nrows ? nrows : nc) : nrows), nc, nz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
674
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
675 for (octave_idx_type j = 0; j < nc+1; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
676 ret.xcidx (j) = N->U->p[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
677
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
678 for (octave_idx_type j = 0; j < nz; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
679 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
680 ret.xridx (j) = N->U->i[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
681 ret.xdata (j) = N->U->x[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
682 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
683
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
684 return ret;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
685
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
686 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
687
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
688 octave_unused_parameter (econ);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
689
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
690 return SparseMatrix ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
691
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
692 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
693 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
694
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
695 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
696 Matrix
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
697 sparse_qr<SparseMatrix>::sparse_qr_rep::C (const Matrix& b, bool econ)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
698 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
699 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
700 octave_idx_type nr = (econ
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
701 ? (ncols > nrows ? nrows : ncols)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
702 : nrows);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
703 octave_idx_type b_nr = b.rows ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
704 octave_idx_type b_nc = b.cols ();
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
705 Matrix ret (nr, b_nc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
706
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
707 if (nrows != b_nr)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
708 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
709 ("sparse_qr: matrix dimension mismatch");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
710 else if (b_nc <= 0 || b_nr <= 0)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
711 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
712 ("sparse_qr: matrix dimension with negative or zero size");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
713
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
714 cholmod_dense *QTB; // Q' * B
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
715 cholmod_dense B = rod2rcd (b);
29399
019130bd4a3d eliminate last uses of BEGIN/END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
716
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
717 QTB = SuiteSparseQR_qmult<double> (SPQR_QTX, m_H, m_Htau, m_HPinv, &B,
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
718 &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
719 spqr_error_handler (&m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
720
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
721 // copy QTB into ret
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
722 double *QTB_x = reinterpret_cast<double *> (QTB->x);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
723 double *ret_vec = reinterpret_cast<double *> (ret.fortran_vec ());
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
724 for (octave_idx_type j = 0; j < b_nc; j++)
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
725 for (octave_idx_type i = 0; i < nr; i++)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
726 ret_vec[j * nr + i] = QTB_x[j * b_nr + i];
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
727
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
728 cholmod_l_free_dense (&QTB, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
729
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
730 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
731
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
732 #elif defined (HAVE_CXSPARSE)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
733
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
734 if (econ)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
735 (*current_liboctave_error_handler)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
736 ("sparse-qr: economy mode with CXSparse not supported");
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
737
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
738 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
739 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
740
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
741 octave_idx_type nc = N->L->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
742 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
743
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29564
diff changeset
744 const double *bvec = b.data ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
745
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
746 Matrix ret (b_nr, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
747 double *vec = ret.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
748
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
749 if (nr < 0 || nc < 0 || nr != b_nr)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
750 (*current_liboctave_error_handler) ("matrix dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
751
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
752 if (nr == 0 || nc == 0 || b_nc == 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
753 ret = Matrix (nc, b_nc, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
754 else
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
755 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
756 OCTAVE_LOCAL_BUFFER (double, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
757
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
758 for (volatile octave_idx_type j = 0, idx = 0;
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
759 j < b_nc;
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
760 j++, idx += b_nr)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
761 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
762 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
763
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
764 for (octave_idx_type i = nr; i < S->m2; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
765 buf[i] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
766
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
767 volatile octave_idx_type nm = (nr < nc ? nr : nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
768
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
769 CXSPARSE_DNAME (_ipvec) (S->pinv, bvec + idx, buf, b_nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
770
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
771 for (volatile octave_idx_type i = 0; i < nm; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
772 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
773 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
774
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
775 CXSPARSE_DNAME (_happly) (N->L, i, N->B[i], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
776 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
777
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
778 for (octave_idx_type i = 0; i < b_nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
779 vec[i+idx] = buf[i];
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
780 }
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
782
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
783 return ret;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
784
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
785 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
786
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
787 octave_unused_parameter (b);
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
788 octave_unused_parameter (econ);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
789
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
790 return Matrix ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
791
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
792 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
793 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
794
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
795 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
796 Matrix
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
797 sparse_qr<SparseMatrix>::sparse_qr_rep::Q (bool econ)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
798 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
799 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
800
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
801 octave_idx_type nc = (econ
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
802 ? (ncols > nrows ? nrows : ncols)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
803 : nrows);
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
804 Matrix ret (nrows, nc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
805 cholmod_dense *q;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
806
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
807 // I is nrows x nrows identity matrix
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
808 cholmod_dense *I
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
809 = cholmod_l_allocate_dense (nrows, nrows, nrows, CHOLMOD_REAL, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
810
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
811 for (octave_idx_type i = 0; i < nrows * nrows; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
812 (reinterpret_cast<double *> (I->x))[i] = 0.0;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
813
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
814 for (octave_idx_type i = 0; i < nrows; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
815 (reinterpret_cast<double *> (I->x))[i * nrows + i] = 1.0;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
816
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
817 q = SuiteSparseQR_qmult<double> (SPQR_QX, m_H, m_Htau, m_HPinv, I, &m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
818 spqr_error_handler (&m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
819
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
820 double *q_x = reinterpret_cast<double *> (q->x);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
821 double *ret_vec = const_cast<double *> (ret.fortran_vec ());
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
822 for (octave_idx_type j = 0; j < nc; j++)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
823 for (octave_idx_type i = 0; i < nrows; i++)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
824 ret_vec[j * nrows + i] = q_x[j * nrows + i];
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
825
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
826 cholmod_l_free_dense (&q, &m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
827 cholmod_l_free_dense (&I, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
828
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
829 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
830
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
831 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
832
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
833 if (econ)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
834 (*current_liboctave_error_handler)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
835 ("sparse-qr: economy mode with CXSparse not supported");
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
836
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
837 octave_idx_type nc = N->L->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
838 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
839 Matrix ret (nr, nr);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
840 double *ret_vec = ret.fortran_vec ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
841
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
842 if (nr < 0 || nc < 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
843 (*current_liboctave_error_handler) ("matrix dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
844
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
845 if (nr == 0 || nc == 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
846 ret = Matrix (nc, nr, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
847 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
848 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
849 OCTAVE_LOCAL_BUFFER (double, bvec, nr + 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
850
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
851 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
852 bvec[i] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
853
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
854 OCTAVE_LOCAL_BUFFER (double, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
855
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
856 for (volatile octave_idx_type j = 0, idx = 0; j < nr; j++, idx += nr)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
857 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
858 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
859
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
860 bvec[j] = 1.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
861 for (octave_idx_type i = nr; i < S->m2; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
862 buf[i] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
863
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
864 volatile octave_idx_type nm = (nr < nc ? nr : nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
865
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
866 CXSPARSE_DNAME (_ipvec) (S->pinv, bvec, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
867
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
868 for (volatile octave_idx_type i = 0; i < nm; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
869 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
870 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
871
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
872 CXSPARSE_DNAME (_happly) (N->L, i, N->B[i], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
873 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
874
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
875 for (octave_idx_type i = 0; i < nr; i++)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
876 ret_vec[i+idx] = buf[i];
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
877
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
878 bvec[j] = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
879 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
880 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
881
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
882 return ret.transpose ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
883
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
884 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
885
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
886 octave_unused_parameter (econ);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
887
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
888 return Matrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
889
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
890 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
891 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
892
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
893 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
894 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
895 Matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
896 sparse_qr<SparseMatrix>::sparse_qr_rep::tall_solve<MArray<double>, Matrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
897 (const MArray<double>& b, octave_idx_type& info)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
898 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
899 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
900
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
901 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD) && defined (HAVE_CXSPARSE))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
902
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
903 octave_idx_type b_nr = b.rows ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
904 octave_idx_type b_nc = b.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
905 Matrix x (ncols, b_nc); // X = m_E'*(m_R\(Q'*B))
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
906
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
907 if (nrows <= 0 || ncols <= 0 || b_nc <= 0 || b_nr <= 0)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
908 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
909 ("matrix dimension with negative or zero size");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
910
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
911 if (nrows < 0 || ncols < 0 || nrows != b_nr)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
912 (*current_liboctave_error_handler) ("matrix dimension mismatch");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
913
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
914 cholmod_dense *QTB; // Q' * B
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
915 cholmod_dense B = rod2rcd (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
916
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
917 // FIXME: Process b column by column as in the CXSPARSE version below.
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
918 // This avoids a large dense matrix Q' * B in memory.
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
919 QTB = SuiteSparseQR_qmult<double> (SPQR_QTX, m_H, m_Htau, m_HPinv, &B,
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
920 &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
921
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
922 spqr_error_handler (&m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
923
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
924 // convert m_R into CXSPARSE matrix R2
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
925 CXSPARSE_DNAME (_sparse) R2;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
926 R2.n = ncols;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
927 R2.m = ncols;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
928 R2.nzmax = m_R->nzmax;
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
929 R2.x = reinterpret_cast<double *> (m_R->x);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
930 suitesparse_integer *R2_p;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
931 suitesparse_integer *R2_i;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
932 if (sizeof (suitesparse_integer) == sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
933 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
934 R2.p = reinterpret_cast<suitesparse_integer *> (m_R->p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
935 R2.i = reinterpret_cast<suitesparse_integer *> (m_R->i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
936 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
937 else
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
938 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
939 R2_p = new suitesparse_integer[ncols+1];
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
940 SuiteSparse_long *R_p = reinterpret_cast<SuiteSparse_long *> (m_R->p);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
941 for (octave_idx_type i = 0; i < ncols+1; i++)
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
942 R2_p[i] = suitesparse_long_to_suitesparse_integer (R_p[i]);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
943 R2.p = R2_p;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
944 octave_idx_type nnz = m_R->nzmax;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
945 R2_i = new suitesparse_integer[nnz];
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
946 SuiteSparse_long *R_i = reinterpret_cast<SuiteSparse_long *> (m_R->i);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
947 for (octave_idx_type i = 0; i < nnz; i++)
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
948 R2_i[i] = suitesparse_long_to_suitesparse_integer (R_i[i]);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
949 R2.i = R2_i;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
950 }
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
951 R2.nz = -1;
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
952 double *x_vec = const_cast<double *> (x.fortran_vec ());
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
953 suitesparse_integer *E;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
954 if (sizeof (suitesparse_integer) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
955 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
956 E = new suitesparse_integer [ncols];
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
957 for (octave_idx_type i = 0; i < ncols; i++)
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
958 E[i] = suitesparse_long_to_suitesparse_integer (m_E[i]);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
959 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
960 else
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
961 E = reinterpret_cast<suitesparse_integer *> (m_E);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
962 for (volatile octave_idx_type j = 0; j < b_nc; j++)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
963 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
964 // fill x(:,j)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
965 // solve (m_R\(Q'*B(:,j)) and store result in QTB(:,j)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
966 CXSPARSE_DNAME (_usolve)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
967 (&R2, &(reinterpret_cast<double *> (QTB->x)[j * b_nr]));
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
968 // x(:,j) = m_E' * (m_R\(Q'*B(:,j))
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
969 CXSPARSE_DNAME (_ipvec)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
970 (E, &(reinterpret_cast<double *> (QTB->x)[j * b_nr]),
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
971 &x_vec[j * ncols], ncols);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
972 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
973
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
974 if (sizeof (suitesparse_integer) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
975 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
976 delete [] R2_p;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
977 delete [] R2_i;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
978 delete [] E;
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
979 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
980 cholmod_l_free_dense (&QTB, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
981
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
982 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
983
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
984 return x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
985
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
986 #elif defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
987
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
988 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
989 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
990
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
991 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
992 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
993
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
994 const double *bvec = b.data ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
995
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
996 Matrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
997 double *vec = x.fortran_vec ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
998
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
999 OCTAVE_LOCAL_BUFFER (double, buf, S->m2);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1000
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1001 for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1002 i++, idx+=nc, bidx+=b_nr)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1003 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1004 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1005
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1006 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1007 buf[j] = 0.;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1008
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1009 CXSPARSE_DNAME (_ipvec) (S->pinv, bvec + bidx, buf, nr);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1010
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1011 for (volatile octave_idx_type j = 0; j < nc; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1012 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1014
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1015 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1016 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1017
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1018 CXSPARSE_DNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1019 CXSPARSE_DNAME (_ipvec) (S->q, buf, vec + idx, nc);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1020 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1021
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1022 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1023
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1024 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1025
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1026 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1027
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1028 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1029
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1030 return Matrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1031
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1032 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1033 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1034
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1035 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1036 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1037 Matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1038 sparse_qr<SparseMatrix>::sparse_qr_rep::wide_solve<MArray<double>, Matrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1039 (const MArray<double>& b, octave_idx_type& info) const
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1040 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1041 info = -1;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1042 #if defined (HAVE_CXSPARSE)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1043
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1044 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1045 // sparse_qr<SparseMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1046
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1047 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1048 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1049
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1050 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1051 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1052
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1053 const double *bvec = b.data ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1054
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1055 Matrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1056 double *vec = x.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1057
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1058 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1059
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1060 OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1061
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1062 for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1063 i++, idx+=nc, bidx+=b_nr)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1064 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1065 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1066
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1067 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1068 buf[j] = 0.;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1069
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1070 CXSPARSE_DNAME (_pvec) (S->q, bvec + bidx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1071 CXSPARSE_DNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1072
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1073 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1074 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1075 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1076
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1077 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1078 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1079
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1080 CXSPARSE_DNAME (_pvec) (S->pinv, buf, vec + idx, nc);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1081 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1082
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1083 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1084
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1085 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1086
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1087 #else
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1088 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1089
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1090 return Matrix ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1091
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1092 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1093 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1094
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1095 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1096 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1097 SparseMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1098 sparse_qr<SparseMatrix>::sparse_qr_rep::tall_solve<SparseMatrix, SparseMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1099 (const SparseMatrix& b, octave_idx_type& info)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1100 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1101 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1102
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1103 #if defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1104
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1105 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1106 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1107
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1108 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1109 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1110
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1111 SparseMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1112 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1113
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1114 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1115 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1116
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1117 OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1118 OCTAVE_LOCAL_BUFFER (double, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1119
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1120 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1121 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1122 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1123
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1124 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1125 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1126
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1127 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1128 buf[j] = 0.;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1129
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1130 CXSPARSE_DNAME (_ipvec) (S->pinv, Xx, buf, nr);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1131
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1132 for (volatile octave_idx_type j = 0; j < nc; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1133 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1134 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1135
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1136 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1137 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1138
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1139 CXSPARSE_DNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1140 CXSPARSE_DNAME (_ipvec) (S->q, buf, Xx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1141
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1142 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1143 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1144 double tmp = Xx[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1145
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1146 if (tmp != 0.0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1147 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1148 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1149 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1150 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1151 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1152 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1153 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1154 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1155 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1156
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1157 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1158 x.xridx (ii++) = j;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1159 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1160 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1161
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1162 x.xcidx (i+1) = ii;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1163 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1164
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1165 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1166
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1167 return x;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1168
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1169 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1170
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1171 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1172
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1173 return SparseMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1174
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1175 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1176 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1177
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1178 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1179 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1180 SparseMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1181 sparse_qr<SparseMatrix>::sparse_qr_rep::wide_solve<SparseMatrix, SparseMatrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1182 (const SparseMatrix& b, octave_idx_type& info) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1183 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1184 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1185
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1186 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1187
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1188 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1189 // sparse_qr<SparseMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1190
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1191 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1192 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1193
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1194 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1195 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1196
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1197 SparseMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1198 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1199
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1200 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1201 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1202 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1203
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1204 OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1205 OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1206
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1207 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1208 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1209 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1210
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1211 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1212 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1213
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1214 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1215 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1216
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1217 CXSPARSE_DNAME (_pvec) (S->q, Xx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1218 CXSPARSE_DNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1219
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1220 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1221 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1222 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1223
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1224 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1225 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1226
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1227 CXSPARSE_DNAME (_pvec) (S->pinv, buf, Xx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1228
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1229 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1230 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1231 double tmp = Xx[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1232
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1233 if (tmp != 0.0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1234 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1235 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1236 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1237 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1238 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1239 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1240 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1241 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1242 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1243
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1244 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1245 x.xridx (ii++) = j;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1246 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1247 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1248
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1249 x.xcidx (i+1) = ii;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1250 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1251
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1252 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1253
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1254 x.maybe_compress ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1255
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1256 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1257
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1258 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1259
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1260 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1261
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1262 return SparseMatrix ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1263
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1264 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1265 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1266
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1267 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1268 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1269 ComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1270 sparse_qr<SparseMatrix>::sparse_qr_rep::tall_solve<MArray<Complex>, ComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1271 (const MArray<Complex>& b, octave_idx_type& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1272 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1273 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1274
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1275 #if defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1276
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1277 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1278 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1279
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1280 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1281 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1282
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1283 ComplexMatrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1284 Complex *vec = x.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1285
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1286 OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1287 OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1288 OCTAVE_LOCAL_BUFFER (double, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1289
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1290 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1291 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1292 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1293
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1294 for (octave_idx_type j = 0; j < b_nr; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1295 {
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1296 Complex c = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1297 Xx[j] = c.real ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1298 Xz[j] = c.imag ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1299 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1300
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1301 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1302 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1303
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1304 CXSPARSE_DNAME (_ipvec) (S->pinv, Xx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1305
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1306 for (volatile octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1307 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1308 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1309
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1310 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1311 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1312
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1313 CXSPARSE_DNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1314 CXSPARSE_DNAME (_ipvec) (S->q, buf, Xx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1315
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1316 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1317 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1318
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1319 CXSPARSE_DNAME (_ipvec) (S->pinv, Xz, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1320
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1321 for (volatile octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1322 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1323 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1324
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1325 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1326 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1327
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1328 CXSPARSE_DNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1329 CXSPARSE_DNAME (_ipvec) (S->q, buf, Xz, nc);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1330
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1331 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1332 vec[j+idx] = Complex (Xx[j], Xz[j]);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1333 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1334
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1335 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1336
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1337 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1338
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1339 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1340
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1341 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1342
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1343 return ComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1344
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1345 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1346 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1347
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1348 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1349 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1350 ComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1351 sparse_qr<SparseMatrix>::sparse_qr_rep::wide_solve<MArray<Complex>, ComplexMatrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1352 (const MArray<Complex>& b, octave_idx_type& info) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1353 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1354 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1355
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1356 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1357
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1358 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1359 // sparse_qr<SparseMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1360
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1361 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1362 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1363
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1364 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1365 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1366
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1367 ComplexMatrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1368 Complex *vec = x.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1369
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1370 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1371
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1372 OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1373 OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1374 OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1375
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1376 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1377 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1378 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1379
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1380 for (octave_idx_type j = 0; j < b_nr; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1381 {
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1382 Complex c = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1383 Xx[j] = c.real ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1384 Xz[j] = c.imag ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1385 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1386
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1387 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1388 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1389
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1390 CXSPARSE_DNAME (_pvec) (S->q, Xx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1391 CXSPARSE_DNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1392
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1393 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1394 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1395 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1396
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1397 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1398 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1399
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1400 CXSPARSE_DNAME (_pvec) (S->pinv, buf, Xx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1401
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1402 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1403 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1404
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1405 CXSPARSE_DNAME (_pvec) (S->q, Xz, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1406 CXSPARSE_DNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1407
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1408 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1409 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1410 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1411
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1412 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1413 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1414
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1415 CXSPARSE_DNAME (_pvec) (S->pinv, buf, Xz, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1416
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1417 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1418 vec[j+idx] = Complex (Xx[j], Xz[j]);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1419 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1420
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1421 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1422
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1423 return x;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1424
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1425 #else
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1426
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1427 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1428
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1429 return ComplexMatrix ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1430
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1431 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1432 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1433
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1434 // Complex-valued matrices.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1435
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1436 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1437 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::sparse_qr_rep
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1438 (const SparseComplexMatrix& a, int order)
29564
bffdb54e78da use shared_ptr to manage memory for sparse chol and qr classes
John W. Eaton <jwe@octave.org>
parents: 29434
diff changeset
1439 : nrows (a.rows ()), ncols (a.columns ())
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1440 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1441 , m_cc (), m_R (nullptr), m_E (nullptr), m_H (nullptr),
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1442 m_Htau (nullptr), m_HPinv (nullptr)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1443 {
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1444 octave_idx_type nr = a.rows ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1445 octave_idx_type nc = a.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1446
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1447 if (nr <= 0 || nc <= 0)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1448 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1449 ("matrix dimension with negative or zero size");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1450
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1451 if (order < 0 || order > 9)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1452 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1453 ("ordering %d is not supported by SPQR", order);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1454
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1455 cholmod_l_start (&m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1456 cholmod_sparse A = cos2ccs (a);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1457
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1458 SuiteSparseQR<Complex> (order, static_cast<double> (SPQR_DEFAULT_TOL),
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1459 static_cast<SuiteSparse_long> (A.nrow),
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1460 &A, &m_R, &m_E, &m_H,
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1461 &m_HPinv, &m_Htau, &m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1462 spqr_error_handler (&m_cc);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1463
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1464 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1465 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1466 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1467 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1468 }
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1469 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1470
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1471 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1472 , S (nullptr), N (nullptr)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1473 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1474 CXSPARSE_ZNAME () A;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1475
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1476 A.nzmax = a.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1477 A.m = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1478 A.n = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1479 // Cast away const on A, with full knowledge that CSparse won't touch it
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1480 // Prevents the methods below making a copy of the data.
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1481 A.p = const_cast<suitesparse_integer *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1482 (to_suitesparse_intptr (a.cidx ()));
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1483 A.i = const_cast<suitesparse_integer *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1484 (to_suitesparse_intptr (a.ridx ()));
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1485 A.x = const_cast<cs_complex_t *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1486 (reinterpret_cast<const cs_complex_t *> (a.data ()));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1487 A.nz = -1;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1488
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1489 S = CXSPARSE_ZNAME (_sqr) (order, &A, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1490 N = CXSPARSE_ZNAME (_qr) (&A, S);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1491
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1492 if (! N)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1493 (*current_liboctave_error_handler)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1494 ("sparse_qr: sparse matrix QR factorization filled");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1495
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1496 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1497
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1498 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1499
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1500 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1501 octave_unused_parameter (order);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1502
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1503 (*current_liboctave_error_handler)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1504 ("sparse_qr: support for CXSparse was unavailable or disabled when liboctave was built");
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1505 }
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1506
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1507 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1508
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1509 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1510 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::~sparse_qr_rep (void)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1511 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1512 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1513
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1514 cholmod_l_free_sparse (&m_R, &m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1515 cholmod_l_free_sparse (&m_H, &m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1516 cholmod_l_free_dense (&m_Htau, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1517 free (m_E); // FIXME: use cholmod_l_free
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1518 free (m_HPinv);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1519 cholmod_l_finish (&m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1520
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1521 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1522
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1523 CXSPARSE_ZNAME (_sfree) (S);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1524 CXSPARSE_ZNAME (_nfree) (N);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1525
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1526 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1527 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1528
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1529 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1530 SparseComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1531 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::V (void) const
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1532 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1533 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1534 // Drop zeros from V and sort
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1535 // FIXME: Is the double transpose to sort necessary?
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1536
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1537 CXSPARSE_ZNAME (_dropzeros) (N->L);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1538 CXSPARSE_ZNAME () *D = CXSPARSE_ZNAME (_transpose) (N->L, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1539 CXSPARSE_ZNAME (_spfree) (N->L);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1540 N->L = CXSPARSE_ZNAME (_transpose) (D, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1541 CXSPARSE_ZNAME (_spfree) (D);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1542
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1543 octave_idx_type nc = N->L->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1544 octave_idx_type nz = N->L->nzmax;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1545 SparseComplexMatrix ret (N->L->m, nc, nz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1546
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1547 for (octave_idx_type j = 0; j < nc+1; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1548 ret.xcidx (j) = N->L->p[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1549
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1550 for (octave_idx_type j = 0; j < nz; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1551 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1552 ret.xridx (j) = N->L->i[j];
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1553 ret.xdata (j) = reinterpret_cast<Complex *> (N->L->x)[j];
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1554 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1555
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1556 return ret;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1557
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1558 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1559
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1560 return SparseComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1561
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1562 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1563 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1564
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1565 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1566 SparseComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1567 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::R (bool econ) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1568 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1569 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1570
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1571 octave_idx_type nr = from_size_t (m_R->nrow);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1572 octave_idx_type nc = from_size_t (m_R->ncol);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1573 octave_idx_type nz = from_size_t (m_R->nzmax);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1574
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1575 // FIXME: Does this work if econ = true?
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1576 SparseComplexMatrix ret ((econ ? (nc > nr ? nr : nc) : nr), nc, nz);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1577 SuiteSparse_long *Rp = reinterpret_cast<SuiteSparse_long *> (m_R->p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1578 SuiteSparse_long *Ri = reinterpret_cast<SuiteSparse_long *> (m_R->i);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1579
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1580 for (octave_idx_type j = 0; j < nc + 1; j++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1581 ret.xcidx (j) = from_suitesparse_long (Rp[j]);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1582
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1583 for (octave_idx_type j = 0; j < nz; j++)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1584 {
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1585 ret.xridx (j) = from_suitesparse_long (Ri[j]);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1586 ret.xdata (j) = (reinterpret_cast<Complex *> (m_R->x))[j];
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1587 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1588
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1589 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1590
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1591 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1592
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1593 // Drop zeros from R and sort
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1594 // FIXME: Is the double transpose to sort necessary?
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1595
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1596 CXSPARSE_ZNAME (_dropzeros) (N->U);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1597 CXSPARSE_ZNAME () *D = CXSPARSE_ZNAME (_transpose) (N->U, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1598 CXSPARSE_ZNAME (_spfree) (N->U);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1599 N->U = CXSPARSE_ZNAME (_transpose) (D, 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1600 CXSPARSE_ZNAME (_spfree) (D);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1601
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1602 octave_idx_type nc = N->U->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1603 octave_idx_type nz = N->U->nzmax;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1604
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1605 SparseComplexMatrix ret ((econ ? (nc > nrows ? nrows : nc) : nrows),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1606 nc, nz);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1607
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1608 for (octave_idx_type j = 0; j < nc+1; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1609 ret.xcidx (j) = N->U->p[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1610
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1611 for (octave_idx_type j = 0; j < nz; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1612 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1613 ret.xridx (j) = N->U->i[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1614 ret.xdata (j) = reinterpret_cast<Complex *>(N->U->x)[j];
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1615 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1616
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1617 return ret;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1618
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1619 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1620
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1621 octave_unused_parameter (econ);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1622
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1623 return SparseComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1624
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1625 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1626 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1627
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1628 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1629 ComplexMatrix
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1630 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::C
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1631 (const ComplexMatrix& b, bool econ)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1632 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1633 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1634
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1635 // FIXME: not tested
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1636 octave_idx_type nr = (econ
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1637 ? (ncols > nrows ? nrows : ncols)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1638 : nrows);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1639 octave_idx_type b_nr = b.rows ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1640 octave_idx_type b_nc = b.cols ();
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1641 ComplexMatrix ret (nr, b_nc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1642
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1643 if (nrows != b_nr)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1644 (*current_liboctave_error_handler) ("matrix dimension mismatch");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1645
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1646 if (b_nc <= 0 || b_nr <= 0)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1647 (*current_liboctave_error_handler)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1648 ("matrix dimension with negative or zero size");
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1649
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1650 cholmod_dense *QTB; // Q' * B
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1651 cholmod_dense B = cod2ccd (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1652
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1653 QTB = SuiteSparseQR_qmult<Complex> (SPQR_QTX, m_H, m_Htau, m_HPinv, &B,
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1654 &m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1655 spqr_error_handler (&m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1656
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1657 // copy QTB into ret
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1658 Complex *QTB_x = reinterpret_cast<Complex *> (QTB->x);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1659 Complex *ret_vec = reinterpret_cast<Complex *> (ret.fortran_vec ());
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1660 for (octave_idx_type j = 0; j < b_nc; j++)
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1661 for (octave_idx_type i = 0; i < nr; i++)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1662 ret_vec[j * nr + i] = QTB_x[j * b_nr + i];
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1663
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1664 cholmod_l_free_dense (&QTB, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1665
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1666 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1667
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1668 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1669
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1670 if (econ)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1671 (*current_liboctave_error_handler)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1672 ("sparse-qr: economy mode with CXSparse not supported");
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1673
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1674 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1675 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1676 octave_idx_type nc = N->L->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1677 octave_idx_type nr = nrows;
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23391
diff changeset
1678 const cs_complex_t *bvec
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29564
diff changeset
1679 = reinterpret_cast<const cs_complex_t *> (b.data ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1680 ComplexMatrix ret (b_nr, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1681 Complex *vec = ret.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1682
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1683 if (nr < 0 || nc < 0 || nr != b_nr)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1684 (*current_liboctave_error_handler) ("matrix dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1685
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1686 if (nr == 0 || nc == 0 || b_nc == 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1687 ret = ComplexMatrix (nc, b_nc, Complex (0.0, 0.0));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1688 else
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1689 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1690 OCTAVE_LOCAL_BUFFER (Complex, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1691
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1692 for (volatile octave_idx_type j = 0, idx = 0;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1693 j < b_nc;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1694 j++, idx += b_nr)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1695 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1696 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1697
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1698 volatile octave_idx_type nm = (nr < nc ? nr : nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1699
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1700 CXSPARSE_ZNAME (_ipvec) (S->pinv, bvec + idx,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1701 reinterpret_cast<cs_complex_t *> (buf),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1702 b_nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1703
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1704 for (volatile octave_idx_type i = 0; i < nm; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1705 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1706 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1707
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1708 CXSPARSE_ZNAME (_happly) (N->L, i, N->B[i],
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1709 reinterpret_cast<cs_complex_t *> (buf));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1710 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1711
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1712 for (octave_idx_type i = 0; i < b_nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1713 vec[i+idx] = buf[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1714 }
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1715 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1716
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1717 return ret;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1718
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1719 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1720
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1721 octave_unused_parameter (b);
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1722 octave_unused_parameter (econ);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1723
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1724 return ComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1725
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1726 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1727 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1728
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1729 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1730 ComplexMatrix
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1731 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::Q (bool econ)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1732 {
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1733 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1734
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1735 octave_idx_type nc = (econ
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1736 ? (ncols > nrows ? nrows : ncols)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1737 : nrows);
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1738 ComplexMatrix ret (nrows, nc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1739 cholmod_dense *q;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1740
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1741 // I is nrows x nrows identity matrix
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1742 cholmod_dense *I
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1743 = reinterpret_cast<cholmod_dense *>
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1744 (cholmod_l_allocate_dense (nrows, nrows, nrows, CHOLMOD_COMPLEX, &m_cc));
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1745
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1746 for (octave_idx_type i = 0; i < nrows * nrows; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1747 (reinterpret_cast<Complex *> (I->x))[i] = 0.0;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1748
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1749 for (octave_idx_type i = 0; i < nrows; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1750 (reinterpret_cast<Complex *> (I->x))[i * nrows + i] = 1.0;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1751
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1752 q = SuiteSparseQR_qmult<Complex> (SPQR_QX, m_H, m_Htau, m_HPinv, I,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1753 &m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1754 spqr_error_handler (&m_cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1755
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1756 Complex *q_x = reinterpret_cast<Complex *> (q->x);
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1757 Complex *ret_vec = const_cast<Complex *> (ret.fortran_vec ());
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1758
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1759 for (octave_idx_type j = 0; j < nc; j++)
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1760 for (octave_idx_type i = 0; i < nrows; i++)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1761 ret_vec[j * nrows + i] = q_x[j * nrows + i];
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1762
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1763 cholmod_l_free_dense (&q, &m_cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
1764 cholmod_l_free_dense (&I, &m_cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1765
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1766 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1767
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1768 #elif defined (HAVE_CXSPARSE)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1769
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1770 if (econ)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1771 (*current_liboctave_error_handler)
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1772 ("sparse-qr: economy mode with CXSparse not supported");
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1773
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1774 octave_idx_type nc = N->L->n;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1775 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1776 ComplexMatrix ret (nr, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1777 Complex *vec = ret.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1778
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1779 if (nr < 0 || nc < 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1780 (*current_liboctave_error_handler) ("matrix dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1781
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1782 if (nr == 0 || nc == 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1783 ret = ComplexMatrix (nc, nr, Complex (0.0, 0.0));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1784 else
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1785 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1786 OCTAVE_LOCAL_BUFFER (cs_complex_t, bvec, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1787
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1788 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1789 bvec[i] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1790
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1791 OCTAVE_LOCAL_BUFFER (Complex, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1792
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1793 for (volatile octave_idx_type j = 0, idx = 0; j < nr; j++, idx+=nr)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1794 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1795 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1796
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1797 bvec[j] = cs_complex_t (1.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1798
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1799 volatile octave_idx_type nm = (nr < nc ? nr : nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1800
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1801 CXSPARSE_ZNAME (_ipvec) (S->pinv, bvec,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1802 reinterpret_cast<cs_complex_t *> (buf),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1803 nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1804
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1805 for (volatile octave_idx_type i = 0; i < nm; i++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1806 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1807 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1808
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1809 CXSPARSE_ZNAME (_happly) (N->L, i, N->B[i],
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1810 reinterpret_cast<cs_complex_t *> (buf));
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1811 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1812
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1813 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1814 vec[i+idx] = buf[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1815
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1816 bvec[j] = cs_complex_t (0.0, 0.0);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1817 }
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1818 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1819
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1820 return ret.hermitian ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1821
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1822 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1823
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
1824 octave_unused_parameter (econ);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1825
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1826 return ComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1827
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1828 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1829 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1830
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1831 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1832 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1833 SparseComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1834 sparse_qr<SparseMatrix>::sparse_qr_rep::tall_solve<SparseComplexMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1835 SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
1836 (const SparseComplexMatrix& b, octave_idx_type& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1837 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1838 info = -1;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1839
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1840 #if defined (HAVE_CXSPARSE)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1841
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1842 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1843 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1844
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1845 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1846 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1847
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1848 SparseComplexMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1849 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1850
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1851 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1852 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1853
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1854 OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1855 OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1856 OCTAVE_LOCAL_BUFFER (double, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1857
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1858 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1859 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1860 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1861
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1862 for (octave_idx_type j = 0; j < b_nr; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1863 {
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1864 Complex c = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1865 Xx[j] = c.real ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1866 Xz[j] = c.imag ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1867 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1868
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1869 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1870 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1871
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1872 CXSPARSE_DNAME (_ipvec) (S->pinv, Xx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1873
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1874 for (volatile octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1875 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1876 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1877
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1878 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1879 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1880
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1881 CXSPARSE_DNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1882 CXSPARSE_DNAME (_ipvec) (S->q, buf, Xx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1883
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1884 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1885 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1886
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1887 CXSPARSE_DNAME (_ipvec) (S->pinv, Xz, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1888
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1889 for (volatile octave_idx_type j = 0; j < nc; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1890 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1891 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1892
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1893 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1894 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1895
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1896 CXSPARSE_DNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1897 CXSPARSE_DNAME (_ipvec) (S->q, buf, Xz, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1898
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1899 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1900 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1901 Complex tmp = Complex (Xx[j], Xz[j]);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1902
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1903 if (tmp != 0.0)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1904 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1905 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1906 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1907 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1908 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1909 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1910 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1911 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1912 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1913
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1914 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1915 x.xridx (ii++) = j;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1916 }
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1917 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1918
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1919 x.xcidx (i+1) = ii;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1920 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1921
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1922 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1923
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1924 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1925
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1926 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1927
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1928 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1929
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1930 return SparseComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1931
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1932 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1933 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1934
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1935 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1936 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1937 SparseComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1938 sparse_qr<SparseMatrix>::sparse_qr_rep::wide_solve<SparseComplexMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1939 SparseComplexMatrix>
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1940 (const SparseComplexMatrix& b, octave_idx_type& info) const
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1941 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1942 info = -1;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1943
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1944 #if defined (HAVE_CXSPARSE)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1945
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1946 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1947 // sparse_qr<SparseMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1948
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1949 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1950 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1951
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1952 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1953 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1954
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1955 SparseComplexMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1956 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1957
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1958 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1959 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1960 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1961
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1962 OCTAVE_LOCAL_BUFFER (double, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1963 OCTAVE_LOCAL_BUFFER (double, Xz, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1964 OCTAVE_LOCAL_BUFFER (double, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1965
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1966 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1967 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1968 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
1969
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1970 for (octave_idx_type j = 0; j < b_nr; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1971 {
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
1972 Complex c = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1973 Xx[j] = c.real ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1974 Xz[j] = c.imag ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1975 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1976
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1977 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1978 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1979
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1980 CXSPARSE_DNAME (_pvec) (S->q, Xx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1981 CXSPARSE_DNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1982
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1983 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1984 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1985 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1986
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1987 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1988 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1989
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1990 CXSPARSE_DNAME (_pvec) (S->pinv, buf, Xx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1991
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1992 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1993 buf[j] = 0.;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1994
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1995 CXSPARSE_DNAME (_pvec) (S->q, Xz, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1996 CXSPARSE_DNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1997
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1998 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1999 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2000 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2001
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2002 CXSPARSE_DNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2003 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2004
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2005 CXSPARSE_DNAME (_pvec) (S->pinv, buf, Xz, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2006
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2007 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2008 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2009 Complex tmp = Complex (Xx[j], Xz[j]);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2010
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2011 if (tmp != 0.0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2012 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2013 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2014 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2015 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2016 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2017 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2018 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2019 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2020 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2021
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2022 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2023 x.xridx (ii++) = j;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2024 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2025 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2026
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2027 x.xcidx (i+1) = ii;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2028 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2029
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2030 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2031
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2032 x.maybe_compress ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2033
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2034 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2035
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2036 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2037
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2038 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2039
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2040 return SparseComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2041
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2042 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2043 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2044
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2045 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2046 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2047 ComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2048 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::tall_solve<MArray<double>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2049 ComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2050 (const MArray<double>& b, octave_idx_type& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2051 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2052 info = -1;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2053
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2054 #if defined (HAVE_CXSPARSE)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2055
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2056 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2057 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2058
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2059 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2060 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2061
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2062 ComplexMatrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2063 cs_complex_t *vec = reinterpret_cast<cs_complex_t *> (x.fortran_vec ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2064
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2065 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2066 OCTAVE_LOCAL_BUFFER (Complex, Xx, b_nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2067
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2068 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2069 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2070 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2071
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2072 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2073 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2074
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2075 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2076 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2077
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2078 CXSPARSE_ZNAME (_ipvec) (S->pinv,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2079 reinterpret_cast<cs_complex_t *>(Xx),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2080 buf, nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2081
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2082 for (volatile octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2083 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2084 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2085
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2086 CXSPARSE_ZNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2087 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2088
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2089 CXSPARSE_ZNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2090 CXSPARSE_ZNAME (_ipvec) (S->q, buf, vec + idx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2091 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2092
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2093 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2094
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2095 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2096
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2097 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2098
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2099 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2100
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2101 return ComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2102
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2103 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2104 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2105
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2106 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2107 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2108 ComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2109 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::wide_solve<MArray<double>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2110 ComplexMatrix>
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2111 (const MArray<double>& b, octave_idx_type& info) const
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2112 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2113 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2114
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2115 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2116
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2117 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2118 // sparse_qr<SparseComplexMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2119
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2120 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2121 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2122
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2123 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2124 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2125
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2126 ComplexMatrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2127 cs_complex_t *vec = reinterpret_cast<cs_complex_t *> (x.fortran_vec ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2128
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2129 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2130
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2131 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2132 OCTAVE_LOCAL_BUFFER (Complex, Xx, b_nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2133 OCTAVE_LOCAL_BUFFER (double, B, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2134
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2135 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2136 B[i] = N->B[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2137
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2138 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2139 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2140 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2141
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2142 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2143 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2144
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2145 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2146 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2147
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2148 CXSPARSE_ZNAME (_pvec) (S->q, reinterpret_cast<cs_complex_t *> (Xx),
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2149 buf, nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2150 CXSPARSE_ZNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2151
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2152 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2153 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2154 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2155
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2156 CXSPARSE_ZNAME (_happly) (N->L, j, B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2157 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2158
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2159 CXSPARSE_ZNAME (_pvec) (S->pinv, buf, vec + idx, nc);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2160 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2161
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2162 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2163
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2164 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2165
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2166 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2167
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2168 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2169
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2170 return ComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2171
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2172 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2173 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2174
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2175 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2176 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2177 SparseComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2178 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::tall_solve<SparseMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2179 SparseComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2180 (const SparseMatrix& b, octave_idx_type& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2181 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2182 info = -1;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2183
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2184 #if defined (HAVE_CXSPARSE)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2185
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2186 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2187 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2188
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2189 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2190 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2191
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2192 SparseComplexMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2193 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2194
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2195 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2196 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2197
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2198 OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2199 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2200
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2201 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2202 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2203 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2204
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2205 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2206 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2207
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2208 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2209 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2210
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2211 CXSPARSE_ZNAME (_ipvec) (S->pinv,
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2212 reinterpret_cast<cs_complex_t *> (Xx),
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2213 buf, nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2214
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2215 for (volatile octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2216 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2217 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2218
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2219 CXSPARSE_ZNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2220 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2221
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2222 CXSPARSE_ZNAME (_usolve) (N->U, buf);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2223 CXSPARSE_ZNAME (_ipvec) (S->q, buf,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2224 reinterpret_cast<cs_complex_t *> (Xx),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2225 nc);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2226
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2227 for (octave_idx_type j = 0; j < nc; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2228 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2229 Complex tmp = Xx[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2230
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2231 if (tmp != 0.0)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2232 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2233 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2234 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2235 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2236 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2237 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2238 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2239 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2240 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2241
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2242 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2243 x.xridx (ii++) = j;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2244 }
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2245 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2246
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2247 x.xcidx (i+1) = ii;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2248 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2249
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2250 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2251
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2252 x.maybe_compress ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2253
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2254 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2255
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2256 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2257
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2258 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2259
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2260 return SparseComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2261
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2262 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2263 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2264
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2265 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2266 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2267 SparseComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2268 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::wide_solve<SparseMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2269 SparseComplexMatrix>
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2270 (const SparseMatrix& b, octave_idx_type& info) const
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2271 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2272 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2273
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2274 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2275
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2276 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2277 // sparse_qr<SparseComplexMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2278
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2279 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2280 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2281
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2282 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2283 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2284
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2285 SparseComplexMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2286 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2287
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2288 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2289 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2290 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2291
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2292 OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2293 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2294 OCTAVE_LOCAL_BUFFER (double, B, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2295
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2296 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2297 B[i] = N->B[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2298
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2299 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2300 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2301 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2302
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2303 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2304 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2305
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2306 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2307 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2308
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2309 CXSPARSE_ZNAME (_pvec) (S->q,
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2310 reinterpret_cast<cs_complex_t *> (Xx),
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2311 buf, nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2312 CXSPARSE_ZNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2313
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2314 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2315 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2316 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2317
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2318 CXSPARSE_ZNAME (_happly) (N->L, j, B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2319 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2320
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2321 CXSPARSE_ZNAME (_pvec) (S->pinv, buf,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2322 reinterpret_cast<cs_complex_t *> (Xx),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2323 nc);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2324
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2325 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2326 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2327 Complex tmp = Xx[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2328
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2329 if (tmp != 0.0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2330 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2331 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2332 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2333 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2334 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2335 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2336 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2337 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2338 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2339
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2340 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2341 x.xridx (ii++) = j;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2342 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2343 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2344
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2345 x.xcidx (i+1) = ii;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2346 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2347
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2348 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2349
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2350 x.maybe_compress ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2351
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2352 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2353
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2354 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2355
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2356 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2357
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2358 return SparseComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2359
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2360 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2361 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2362
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2363 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2364 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2365 ComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2366 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::tall_solve<MArray<Complex>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2367 ComplexMatrix>
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2368 (const MArray<Complex>& b, octave_idx_type& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2369 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2370 info = -1;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2371
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2372 #if defined (HAVE_CXSPARSE)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2373
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2374 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2375 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2376
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2377 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2378 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2379
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2380 const cs_complex_t *bvec = reinterpret_cast<const cs_complex_t *>
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29564
diff changeset
2381 (b.data ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2382
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2383 ComplexMatrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2384 cs_complex_t *vec = reinterpret_cast<cs_complex_t *>
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2385 (x.fortran_vec ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2386
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2387 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2388
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2389 for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2390 i++, idx+=nc, bidx+=b_nr)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2391 {
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2392 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2393
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2394 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2395 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2396
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2397 CXSPARSE_ZNAME (_ipvec) (S->pinv, bvec + bidx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2398
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2399 for (volatile octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2400 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2401 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2402
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2403 CXSPARSE_ZNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2404 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2405
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2406 CXSPARSE_ZNAME (_usolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2407 CXSPARSE_ZNAME (_ipvec) (S->q, buf, vec + idx, nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2408 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2409
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2410 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2411
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2412 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2413
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2414 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2415
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2416 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2417
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2418 return ComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2419
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2420 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2421 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2422
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2423 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2424 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2425 ComplexMatrix
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2426 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::wide_solve<MArray<Complex>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2427 ComplexMatrix>
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2428 (const MArray<Complex>& b, octave_idx_type& info) const
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2429 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2430 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2431
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2432 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2433
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2434 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2435 // sparse_qr<SparseComplexMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2436
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2437 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2438 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2439
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2440 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2441 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2442
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2443 const cs_complex_t *bvec = reinterpret_cast<const cs_complex_t *>
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29564
diff changeset
2444 (b.data ());
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2445
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2446 ComplexMatrix x (nc, b_nc);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2447 cs_complex_t *vec = reinterpret_cast<cs_complex_t *> (x.fortran_vec ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2448
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2449 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2450
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2451 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2452 OCTAVE_LOCAL_BUFFER (double, B, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2453
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2454 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2455 B[i] = N->B[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2456
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2457 for (volatile octave_idx_type i = 0, idx = 0, bidx = 0; i < b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2458 i++, idx+=nc, bidx+=b_nr)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2459 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2460 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2461
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2462 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2463 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2464
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2465 CXSPARSE_ZNAME (_pvec) (S->q, bvec + bidx, buf, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2466 CXSPARSE_ZNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2467
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2468 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2469 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2470 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2471
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2472 CXSPARSE_ZNAME (_happly) (N->L, j, B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2473 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2474
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2475 CXSPARSE_ZNAME (_pvec) (S->pinv, buf, vec + idx, nc);
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2476 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2477
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2478 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2479
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2480 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2481
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2482 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2483
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2484 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2485
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2486 return ComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2487
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2488 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2489 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2490
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2491 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2492 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2493 SparseComplexMatrix
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2494 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::tall_solve<SparseComplexMatrix,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2495 SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2496 (const SparseComplexMatrix& b, octave_idx_type& info)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2497 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2498 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2499
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2500 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2501
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2502 octave_idx_type nr = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2503 octave_idx_type nc = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2504
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2505 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2506 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2507
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2508 SparseComplexMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2509 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2510
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2511 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2512 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2513
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2514 OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2515 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2516
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2517 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2518 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2519 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2520
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2521 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2522 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2523
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2524 for (octave_idx_type j = nr; j < S->m2; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2525 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2526
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2527 CXSPARSE_ZNAME (_ipvec) (S->pinv,
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2528 reinterpret_cast<cs_complex_t *> (Xx),
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2529 buf, nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2530
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2531 for (volatile octave_idx_type j = 0; j < nc; j++)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2532 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2533 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2534
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2535 CXSPARSE_ZNAME (_happly) (N->L, j, N->B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2536 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2537
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2538 CXSPARSE_ZNAME (_usolve) (N->U, buf);
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2539 CXSPARSE_ZNAME (_ipvec) (S->q, buf,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2540 reinterpret_cast<cs_complex_t *> (Xx),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2541 nc);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2542
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2543 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2544 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2545 Complex tmp = Xx[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2546
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2547 if (tmp != 0.0)
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2548 {
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2549 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2550 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2551 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2552 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2553 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2554 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2555 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2556 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2557
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2558 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2559 x.xridx (ii++) = j;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2560 }
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2561 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2562
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2563 x.xcidx (i+1) = ii;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2564 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
2565
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2566 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2567
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2568 x.maybe_compress ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2569
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2570 return x;
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2571
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2572 #else
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2573
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2574 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2575
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2576 return SparseComplexMatrix ();
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2577
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2578 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2579 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2580
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2581 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2582 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2583 SparseComplexMatrix
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2584 sparse_qr<SparseComplexMatrix>::sparse_qr_rep::wide_solve<SparseComplexMatrix,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2585 SparseComplexMatrix>
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2586 (const SparseComplexMatrix& b, octave_idx_type& info) const
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2587 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2588 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2589
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2590 #if defined (HAVE_CXSPARSE)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2591
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2592 // These are swapped because the original matrix was transposed in
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2593 // sparse_qr<SparseComplexMatrix>::solve.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2594
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2595 octave_idx_type nr = ncols;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2596 octave_idx_type nc = nrows;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2597
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2598 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2599 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2600
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2601 SparseComplexMatrix x (nc, b_nc, b.nnz ());
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2602 x.xcidx (0) = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2603
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2604 volatile octave_idx_type x_nz = b.nnz ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2605 volatile octave_idx_type ii = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2606 volatile octave_idx_type nbuf = (nc > S->m2 ? nc : S->m2);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2607
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2608 OCTAVE_LOCAL_BUFFER (Complex, Xx, (b_nr > nc ? b_nr : nc));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2609 OCTAVE_LOCAL_BUFFER (cs_complex_t, buf, nbuf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2610 OCTAVE_LOCAL_BUFFER (double, B, nr);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2611
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2612 for (octave_idx_type i = 0; i < nr; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2613 B[i] = N->B[i];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2614
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2615 for (volatile octave_idx_type i = 0, idx = 0; i < b_nc; i++, idx+=nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2616 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2617 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2618
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2619 for (octave_idx_type j = 0; j < b_nr; j++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2620 Xx[j] = b.xelem (j, i);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2621
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2622 for (octave_idx_type j = nr; j < nbuf; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2623 buf[j] = cs_complex_t (0.0, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2624
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2625 CXSPARSE_ZNAME (_pvec) (S->q, reinterpret_cast<cs_complex_t *>(Xx),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2626 buf, nr);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2627 CXSPARSE_ZNAME (_utsolve) (N->U, buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2628
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2629 for (volatile octave_idx_type j = nr-1; j >= 0; j--)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2630 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2631 octave_quit ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2632
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2633 CXSPARSE_ZNAME (_happly) (N->L, j, B[j], buf);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2634 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2635
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2636 CXSPARSE_ZNAME (_pvec) (S->pinv, buf,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
2637 reinterpret_cast<cs_complex_t *>(Xx), nc);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2638
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2639 for (octave_idx_type j = 0; j < nc; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2640 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2641 Complex tmp = Xx[j];
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2642
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2643 if (tmp != 0.0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2644 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2645 if (ii == x_nz)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2646 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2647 // Resize the sparse matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2648 octave_idx_type sz = x_nz * (b_nc - i) / b_nc;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2649 sz = (sz > 10 ? sz : 10) + x_nz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2650 x.change_capacity (sz);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2651 x_nz = sz;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2652 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2653
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2654 x.xdata (ii) = tmp;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2655 x.xridx (ii++) = j;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2656 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2657 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2658
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2659 x.xcidx (i+1) = ii;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2660 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2661
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2662 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2663
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2664 x.maybe_compress ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2665
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2666 return x;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2667
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2668 #else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2669
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2670 octave_unused_parameter (b);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2671
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2672 return SparseComplexMatrix ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2673
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2674 #endif
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2675 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2676
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2677 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2678 sparse_qr<SPARSE_T>::sparse_qr (void)
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2679 : m_rep (new sparse_qr_rep (SPARSE_T (), 0))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2680 { }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2681
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2682 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2683 sparse_qr<SPARSE_T>::sparse_qr (const SPARSE_T& a, int order)
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2684 : m_rep (new sparse_qr_rep (a, order))
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2685 { }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2686
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2687 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2688 bool
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2689 sparse_qr<SPARSE_T>::ok (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2690 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2691 return m_rep->ok ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2692 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2693
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2694 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2695 SPARSE_T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2696 sparse_qr<SPARSE_T>::V (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2697 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2698 return m_rep->V ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2699 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2700
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2701 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2702 ColumnVector
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2703 sparse_qr<SPARSE_T>::Pinv (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2704 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2705 return m_rep->P ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2706 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2707
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2708 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2709 ColumnVector
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2710 sparse_qr<SPARSE_T>::P (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2711 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2712 return m_rep->P ();
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2713 }
29434
91f32bf0d497 maint: strip trailing spaces from code base.
Rik <rik@octave.org>
parents: 29399
diff changeset
2714
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2715 template <typename SPARSE_T>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2716 ColumnVector
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2717 sparse_qr<SPARSE_T>::E (void) const
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2718 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2719 return m_rep->E();
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2720 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2721
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2722
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2723 template <typename SPARSE_T>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2724 SparseMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2725 sparse_qr<SPARSE_T>::E_MAT (void) const
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2726 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2727 ColumnVector perm = m_rep->E ();
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2728 octave_idx_type nrows = perm.rows ();
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2729 SparseMatrix ret (nrows, nrows, nrows);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2730 for (octave_idx_type i = 0; i < nrows; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2731 ret(perm(i) - 1, i) = 1.0;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2732 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2733 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2734
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2735
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2736 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2737 SPARSE_T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2738 sparse_qr<SPARSE_T>::R (bool econ) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2739 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2740 return m_rep->R (econ);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2741 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2742
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2743 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2744 typename SPARSE_T::dense_matrix_type
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2745 sparse_qr<SPARSE_T>::C (const typename SPARSE_T::dense_matrix_type& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2746 bool econ) const
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2747 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2748 return m_rep->C (b, econ);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2749 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2750
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2751 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2752 typename SPARSE_T::dense_matrix_type
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2753 sparse_qr<SPARSE_T>::Q (bool econ) const
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2754 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
2755 return m_rep->Q (econ);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2756 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2757
29265
ecf5b2d9c2d3 sparse-qr.cc: Simplify code by using default parameters (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29260
diff changeset
2758 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2759 //specializations of function min2norm_solve
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2760 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2761 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2762 OCTAVE_API Matrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2763 sparse_qr<SparseMatrix>::min2norm_solve<MArray<double>, Matrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2764 (const SparseMatrix& a, const MArray<double>& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2765 octave_idx_type& info, int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2766 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2767 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2768 octave_idx_type b_nc = b.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2769 octave_idx_type nc = a.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2770 Matrix x (nc, b_nc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2771 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2772
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2773 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2774 cholmod_sparse A = ros2rcs (a);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2775 cholmod_dense B = rod2rcd (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2776 cholmod_dense *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2777
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2778 X = SuiteSparseQR_min2norm<double> (order, SPQR_DEFAULT_TOL, &A, &B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2779 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2780
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2781 double *vec = x.fortran_vec ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2782 for (volatile octave_idx_type i = 0; i < nc * b_nc; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2783 vec[i] = reinterpret_cast<double *> (X->x)[i];
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2784
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2785 info = 0;
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2786 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2787 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2788 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2789 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2790 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2791 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2792
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2793 return x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2794
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2795 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2796
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2797 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2798 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2799 OCTAVE_API SparseMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2800 sparse_qr<SparseMatrix>::min2norm_solve<SparseMatrix, SparseMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2801 (const SparseMatrix& a, const SparseMatrix& b, octave_idx_type& info,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2802 int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2803 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2804 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2805 SparseMatrix x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2806 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2807
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2808 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2809 cholmod_sparse A = ros2rcs (a);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2810 cholmod_sparse B = ros2rcs (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2811 cholmod_sparse *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2812
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2813 X = SuiteSparseQR_min2norm<double> (order, SPQR_DEFAULT_TOL, &A, &B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2814 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2815
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2816 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2817 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2818 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2819 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2820 delete [] reinterpret_cast<SuiteSparse_long *> (B.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2821 delete [] reinterpret_cast<SuiteSparse_long *> (B.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2822 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2823
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2824 x = rcs2ros (X);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2825 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2826 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2827
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2828 return x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2829
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2830 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2831
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2832 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2833 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2834 OCTAVE_API ComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2835 sparse_qr<SparseMatrix>::min2norm_solve<MArray<Complex>, ComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2836 (const SparseMatrix& a, const MArray<Complex>& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2837 octave_idx_type& info, int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2838 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2839 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2840
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2841 octave_idx_type b_nc = b.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2842 octave_idx_type nc = a.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2843
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2844 ComplexMatrix x (nc, b_nc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2845
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2846 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2847
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2848 cholmod_l_start (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2849
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2850 cholmod_sparse *A = ros2ccs (a, &cc);
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2851 cholmod_dense B = cod2ccd (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2852 cholmod_dense *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2853
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2854 X = SuiteSparseQR_min2norm<Complex> (order, SPQR_DEFAULT_TOL, A, &B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2855 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2856
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2857 Complex *vec = x.fortran_vec ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2858 for (volatile octave_idx_type i = 0; i < nc * b_nc; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2859 vec[i] = reinterpret_cast<Complex *> (X->x)[i];
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2860
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2861 cholmod_l_free_sparse (&A, &cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2862 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2863
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2864 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2865
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2866 return x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2867
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2868 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2869
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2870 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2871 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2872 OCTAVE_API SparseComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2873 sparse_qr<SparseMatrix>::min2norm_solve<SparseComplexMatrix,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2874 SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2875 (const SparseMatrix& a, const SparseComplexMatrix& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2876 octave_idx_type& info, int order)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2877 {
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2878 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2879
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2880 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2881
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2882 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2883
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2884 cholmod_sparse *A = ros2ccs (a, &cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2885 cholmod_sparse B = cos2ccs (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2886 cholmod_sparse *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2887
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2888 X = SuiteSparseQR_min2norm<Complex> (order, SPQR_DEFAULT_TOL, A, &B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2889 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2890
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2891 cholmod_l_free_sparse (&A, &cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2892 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2893 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2894 delete [] reinterpret_cast<SuiteSparse_long *> (B.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2895 delete [] reinterpret_cast<SuiteSparse_long *> (B.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2896 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2897 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2898
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2899 SparseComplexMatrix ret = ccs2cos(X);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2900
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2901 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2902
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2903 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2904
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2905 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2906
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2907 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2908 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2909 OCTAVE_API ComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2910 sparse_qr<SparseComplexMatrix>::min2norm_solve<MArray<Complex>,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2911 ComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2912 (const SparseComplexMatrix& a, const MArray<Complex>& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2913 octave_idx_type& info,int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2914 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2915 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2916 octave_idx_type b_nc = b.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2917 octave_idx_type nc = a.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2918 ComplexMatrix x (nc, b_nc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2919
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2920 cholmod_common cc;
29434
91f32bf0d497 maint: strip trailing spaces from code base.
Rik <rik@octave.org>
parents: 29399
diff changeset
2921
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2922 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2923
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2924 cholmod_sparse A = cos2ccs (a);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2925 cholmod_dense B = cod2ccd (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2926 cholmod_dense *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2927
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2928 X = SuiteSparseQR_min2norm<Complex> (order, SPQR_DEFAULT_TOL, &A, &B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2929 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2930
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2931 Complex *vec = x.fortran_vec ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2932 for (volatile octave_idx_type i = 0; i < nc * b_nc; i++)
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2933 vec[i] = reinterpret_cast<Complex *> (X->x)[i];
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2934
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2935 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2936 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2937 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2938 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2939 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2940 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2941
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2942 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2943
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2944 return x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2945
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2946 }
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2947
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2948 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2949 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2950 OCTAVE_API ComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2951 sparse_qr<SparseComplexMatrix>::min2norm_solve<MArray<double>,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2952 ComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2953 (const SparseComplexMatrix& a, const MArray<double>& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2954 octave_idx_type& info, int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2955 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2956 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2957
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2958 octave_idx_type b_nc = b.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2959 octave_idx_type nc = a.cols ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2960 ComplexMatrix x (nc, b_nc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2961
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2962 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2963
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2964 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2965
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2966 cholmod_sparse A = cos2ccs (a);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2967 cholmod_dense *B = rod2ccd (b, &cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2968 cholmod_dense *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2969
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2970 X = SuiteSparseQR_min2norm<Complex> (order, SPQR_DEFAULT_TOL, &A, B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2971 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2972
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2973 Complex *vec = x.fortran_vec ();
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2974
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2975 for (volatile octave_idx_type i = 0; i < nc * b_nc; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30127
diff changeset
2976 vec[i] = reinterpret_cast<Complex *> (X->x)[i];
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2977
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2978 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2979 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2980 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2981 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2982 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2983 cholmod_l_free_dense (&B, &cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
2984 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2985
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2986 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2987
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2988 return x;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2989
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2990 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2991
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2992 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2993 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2994 OCTAVE_API SparseComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2995 sparse_qr<SparseComplexMatrix>::min2norm_solve<SparseComplexMatrix,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2996 SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2997 (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2998 octave_idx_type& info, int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
2999 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3000 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3001
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3002 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3003
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3004 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3005
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3006 cholmod_sparse A = cos2ccs (a);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3007 cholmod_sparse B = cos2ccs (b);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3008 cholmod_sparse *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3009
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3010 X = SuiteSparseQR_min2norm<Complex> (order, SPQR_DEFAULT_TOL, &A, &B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3011 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3012
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3013 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3014 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3015 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3016 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3017 delete [] reinterpret_cast<SuiteSparse_long *> (B.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3018 delete [] reinterpret_cast<SuiteSparse_long *> (B.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3019 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3020 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3021
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3022 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3023
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3024 return ccs2cos (X);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3025
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3026 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3027
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3028 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3029 template <>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3030 OCTAVE_API SparseComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3031 sparse_qr<SparseComplexMatrix>::min2norm_solve<SparseMatrix,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3032 SparseComplexMatrix>
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3033 (const SparseComplexMatrix& a, const SparseMatrix& b,
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3034 octave_idx_type& info,int order)
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3035 {
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3036 info = -1;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3037
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3038 cholmod_common cc;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3039
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3040 cholmod_l_start (&cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3041
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3042 cholmod_sparse A = cos2ccs (a);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3043 cholmod_sparse *B = ros2ccs (b, &cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3044 cholmod_sparse *X;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3045
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3046 X = SuiteSparseQR_min2norm<Complex> (order, SPQR_DEFAULT_TOL, &A, B, &cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3047 spqr_error_handler (&cc);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3048
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3049 SparseComplexMatrix ret = ccs2cos(X);
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3050
29274
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3051 if (sizeof (octave_idx_type) != sizeof (SuiteSparse_long))
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3052 {
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3053 delete [] reinterpret_cast<SuiteSparse_long *> (A.p);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3054 delete [] reinterpret_cast<SuiteSparse_long *> (A.i);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3055 }
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3056 cholmod_l_free_sparse (&B, &cc);
fed765133d53 sparse-qr.cc: Use correct integer types (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29266
diff changeset
3057 cholmod_l_finish (&cc);
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3058
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3059 info = 0;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3060
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3061 return ret;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3062
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3063 }
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3064 #endif
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3065
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3066 // FIXME: Why is the "order" of the QR calculation as used in the
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3067 // CXSparse function sqr 3 for real matrices and 2 for complex? These
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3068 // values seem to be required but there was no explanation in David
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3069 // Bateman's original code.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3070
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3071 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3072 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3073 cxsparse_defaults
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3074 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3075 public:
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3076 enum { order = -1 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3077 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3078
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3079 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3080 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3081 cxsparse_defaults<SparseMatrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3082 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3083 public:
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3084 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3085 enum { order = SPQR_ORDERING_DEFAULT };
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3086 #elif defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3087 enum { order = 3 };
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3088 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3089 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3090
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3091 template <>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3092 class
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3093 cxsparse_defaults<SparseComplexMatrix>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3094 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3095 public:
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3096 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3097 enum { order = SPQR_ORDERING_DEFAULT };
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3098 #elif defined (HAVE_CXSPARSE)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3099 enum { order = 2 };
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3100 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3101 };
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3102
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3103 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3104 template <typename RHS_T, typename RET_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3105 RET_T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3106 sparse_qr<SPARSE_T>::solve (const SPARSE_T& a, const RHS_T& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3107 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3108 {
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3109 #if (defined (HAVE_SPQR) && defined (HAVE_CHOLMOD))
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3110
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3111 info = -1;
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3112
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3113 octave_idx_type nr = a.rows ();
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3114 octave_idx_type nc = a.cols ();
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3115
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3116 octave_idx_type b_nc = b.cols ();
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3117 octave_idx_type b_nr = b.rows ();
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3118
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3119 int order = cxsparse_defaults<SPARSE_T>::order;
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3120
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3121 if (nr <= 0 || nc <= 0 || b_nc <= 0 || b_nr <= 0)
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3122 (*current_liboctave_error_handler)
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3123 ("matrix dimension with negative or zero size");
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3124
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3125 if ( nr != b_nr)
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3126 (*current_liboctave_error_handler)
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3127 ("matrix dimension mismatch in solution of minimum norm problem");
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3128
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3129 info = 0;
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3130
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3131 return min2norm_solve<RHS_T, RET_T> (a, b, info, order);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3132
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3133 #elif defined (HAVE_CXSPARSE)
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3134
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3135 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3136
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3137 octave_idx_type nr = a.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3138 octave_idx_type nc = a.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3139
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3140 octave_idx_type b_nc = b.cols ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3141 octave_idx_type b_nr = b.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3142
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3143 int order = cxsparse_defaults<SPARSE_T>::order;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3144
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3145 if (nr < 0 || nc < 0 || nr != b_nr)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3146 (*current_liboctave_error_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3147 ("matrix dimension mismatch in solution of minimum norm problem");
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3148
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3149 if (nr == 0 || nc == 0 || b_nc == 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3150 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3151 info = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3152
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3153 return RET_T (nc, b_nc, 0.0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3154 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3155 else if (nr >= nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3156 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3157 sparse_qr<SPARSE_T> q (a, order);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3158
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3159 return q.ok () ? q.tall_solve<RHS_T, RET_T> (b, info) : RET_T ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3160 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3161 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3162 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3163 sparse_qr<SPARSE_T> q (a.hermitian (), order);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3164
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3165 return q.ok () ? q.wide_solve<RHS_T, RET_T> (b, info) : RET_T ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3166 }
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3167
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3168 #else
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3169
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3170 octave_unused_parameter (a);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3171 octave_unused_parameter (b);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3172 octave_unused_parameter (info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3173
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3174 return RET_T ();
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3175
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3176 #endif
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3177 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3178
29266
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3179 //explicit instantiations of static member function solve
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3180 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3181 OCTAVE_API Matrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3182 sparse_qr<SparseMatrix>::solve<MArray<double>, Matrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3183 (const SparseMatrix& a, const MArray<double>& b, octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3184
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3185 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3186 OCTAVE_API SparseMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3187 sparse_qr<SparseMatrix>::solve<SparseMatrix, SparseMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3188 (const SparseMatrix& a, const SparseMatrix& b, octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3189
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3190 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3191 OCTAVE_API ComplexMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3192 sparse_qr<SparseMatrix>::solve<MArray<Complex>, ComplexMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3193 (const SparseMatrix& a, const MArray<Complex>& b, octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3194
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3195 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3196 OCTAVE_API SparseComplexMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3197 sparse_qr<SparseMatrix>::solve<SparseComplexMatrix, SparseComplexMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3198 (const SparseMatrix& a, const SparseComplexMatrix& b,
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3199 octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3200
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3201 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3202 OCTAVE_API ComplexMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3203 sparse_qr<SparseComplexMatrix>::solve<MArray<Complex>, ComplexMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3204 (const SparseComplexMatrix& a, const MArray<Complex>& b,
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3205 octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3206
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3207 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3208 OCTAVE_API SparseComplexMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3209 sparse_qr<SparseComplexMatrix>::solve<
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3210 SparseComplexMatrix, SparseComplexMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3211 (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3212 octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3213
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3214 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3215 OCTAVE_API ComplexMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3216 sparse_qr<SparseComplexMatrix>::solve<MArray<double>, ComplexMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3217 (const SparseComplexMatrix& a, const MArray<double>& b,
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3218 octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3219
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3220 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3221 OCTAVE_API SparseComplexMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3222 sparse_qr<SparseComplexMatrix>::solve<SparseMatrix, SparseComplexMatrix>
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3223 (const SparseComplexMatrix& a, const SparseMatrix& b,
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3224 octave_idx_type& info);
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3225
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3226 //explicit instantiations of member function E_MAT
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3227 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3228 OCTAVE_API SparseMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3229 sparse_qr<SparseMatrix>::E_MAT (void) const;
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3230
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3231 template
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3232 OCTAVE_API SparseMatrix
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3233 sparse_qr<SparseComplexMatrix>::E_MAT (void) const;
1f182126f0c2 sparse-qr.cc: Fix compilation with clang (bug #57033).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29265
diff changeset
3234
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3235 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3236 template <typename RHS_T, typename RET_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3237 RET_T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3238 sparse_qr<SPARSE_T>::tall_solve (const RHS_T& b, octave_idx_type& info) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3239 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
3240 return m_rep->template tall_solve<RHS_T, RET_T> (b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3241 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3242
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3243 template <typename SPARSE_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3244 template <typename RHS_T, typename RET_T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3245 RET_T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3246 sparse_qr<SPARSE_T>::wide_solve (const RHS_T& b, octave_idx_type& info) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3247 {
30127
441f0ab6e5ad maint: use "m_" prefix for member variables in class sparse_qr.
Rik <rik@octave.org>
parents: 29931
diff changeset
3248 return m_rep->template wide_solve<RHS_T, RET_T> (b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3249 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3250
29242
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3251 // Explicitly instantiate all member functions
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3252
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3253 template OCTAVE_API sparse_qr<SparseMatrix>::sparse_qr (void);
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3254 template OCTAVE_API
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3255 sparse_qr<SparseMatrix>::sparse_qr (const SparseMatrix& a, int order);
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3256 template OCTAVE_API bool sparse_qr<SparseMatrix>::ok (void) const;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3257 template OCTAVE_API ColumnVector sparse_qr<SparseMatrix>::E (void) const;
29242
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3258 template OCTAVE_API SparseMatrix sparse_qr<SparseMatrix>::V (void) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3259 template OCTAVE_API ColumnVector sparse_qr<SparseMatrix>::Pinv (void) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3260 template OCTAVE_API ColumnVector sparse_qr<SparseMatrix>::P (void) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3261 template OCTAVE_API SparseMatrix
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3262 sparse_qr<SparseMatrix>::R (bool econ) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3263 template OCTAVE_API Matrix
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3264 sparse_qr<SparseMatrix>::C (const Matrix& b, bool econ) const;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3265 template OCTAVE_API Matrix sparse_qr<SparseMatrix>::Q (bool econ) const;
29242
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3266
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3267 template OCTAVE_API sparse_qr<SparseComplexMatrix>::sparse_qr (void);
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3268 template OCTAVE_API
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3269 sparse_qr<SparseComplexMatrix>::sparse_qr
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3270 (const SparseComplexMatrix& a, int order);
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3271 template OCTAVE_API bool sparse_qr<SparseComplexMatrix>::ok (void) const;
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3272 template OCTAVE_API ColumnVector
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3273 sparse_qr<SparseComplexMatrix>::E (void) const;
29242
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3274 template OCTAVE_API SparseComplexMatrix
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3275 sparse_qr<SparseComplexMatrix>::V (void) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3276 template OCTAVE_API ColumnVector
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3277 sparse_qr<SparseComplexMatrix>::Pinv (void) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3278 template OCTAVE_API ColumnVector
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3279 sparse_qr<SparseComplexMatrix>::P (void) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3280 template OCTAVE_API SparseComplexMatrix
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3281 sparse_qr<SparseComplexMatrix>::R (bool econ) const;
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3282 template OCTAVE_API ComplexMatrix
29259
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3283 sparse_qr<SparseComplexMatrix>::C (const ComplexMatrix& b, bool econ) const;
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3284 template OCTAVE_API ComplexMatrix
66f162b6fa03 Replacement of CXSPARSE by SPQR for QR factorization (bug #57033).
Simon Hau <simon.hau79@gmail.com>
parents: 29242
diff changeset
3285 sparse_qr<SparseComplexMatrix>::Q (bool econ) const;
29242
f207504ae98d sparse-qr: Export member function instantiations (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29228
diff changeset
3286
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3287 Matrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3288 qrsolve (const SparseMatrix& a, const MArray<double>& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3289 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3290 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3291 return sparse_qr<SparseMatrix>::solve<MArray<double>, Matrix> (a, b,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3292 info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3293 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3294
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3295 SparseMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3296 qrsolve (const SparseMatrix& a, const SparseMatrix& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3297 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3298 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3299 return sparse_qr<SparseMatrix>::solve<SparseMatrix, SparseMatrix> (a, b,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3300 info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3301 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3302
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3303 ComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3304 qrsolve (const SparseMatrix& a, const MArray<Complex>& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3305 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3306 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3307 return sparse_qr<SparseMatrix>::solve<MArray<Complex>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3308 ComplexMatrix> (a, b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3309 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3310
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3311 SparseComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3312 qrsolve (const SparseMatrix& a, const SparseComplexMatrix& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3313 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3314 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3315 return sparse_qr<SparseMatrix>::solve<SparseComplexMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3316 SparseComplexMatrix> (a, b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3317 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3318
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3319 ComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3320 qrsolve (const SparseComplexMatrix& a, const MArray<double>& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3321 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3322 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3323 return sparse_qr<SparseComplexMatrix>::solve<MArray<double>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3324 ComplexMatrix> (a, b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3325 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3326
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3327 SparseComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3328 qrsolve (const SparseComplexMatrix& a, const SparseMatrix& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3329 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3330 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3331 return sparse_qr<SparseComplexMatrix>::solve<SparseMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3332 SparseComplexMatrix>
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3333 (a, b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3334 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3335
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3336 ComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3337 qrsolve (const SparseComplexMatrix& a, const MArray<Complex>& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3338 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3339 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3340 return sparse_qr<SparseComplexMatrix>::solve<MArray<Complex>,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3341 ComplexMatrix> (a, b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3342 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3343
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3344 SparseComplexMatrix
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3345 qrsolve (const SparseComplexMatrix& a, const SparseComplexMatrix& b,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3346 octave_idx_type& info)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3347 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3348 return sparse_qr<SparseComplexMatrix>::solve<SparseComplexMatrix,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3349 SparseComplexMatrix>
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
3350 (a, b, info);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3351 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3352 }
21176
791dcb32b657 revamp sparse QR factorizatino classes
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3353 }