GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SparseCmplxQR.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2005-2013 David Bateman
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_SparseCmplxQR_h)
24 #define octave_SparseCmplxQR_h 1
25 
26 #include <iosfwd>
27 
28 #include "dMatrix.h"
29 #include "CMatrix.h"
30 #include "dSparse.h"
31 #include "CSparse.h"
32 #include "oct-sparse.h"
33 
34 #ifdef USE_64_BIT_IDX_T
35 #define CXSPARSE_ZNAME(name) cs_cl ## name
36 #else
37 #define CXSPARSE_ZNAME(name) cs_ci ## name
38 #endif
39 
40 class
41 OCTAVE_API
43 {
44 protected:
46  {
47  public:
48  SparseComplexQR_rep (const SparseComplexMatrix& a, int order);
49 
50  ~SparseComplexQR_rep (void);
51 #ifdef HAVE_CXSPARSE
52  bool ok (void) const { return (N && S); }
53 #else
54  bool ok (void) const { return false; }
55 #endif
56  SparseComplexMatrix V (void) const;
57 
58  ColumnVector Pinv (void) const;
59 
60  ColumnVector P (void) const;
61 
62  SparseComplexMatrix R (const bool econ) const;
63 
64  ComplexMatrix C (const ComplexMatrix &b) const;
65 
66  ComplexMatrix Q (void) const;
67 
69 
71 #ifdef HAVE_CXSPARSE
73 
75 #endif
76  private:
77 
78  // No copying!
79 
81 
82  SparseComplexQR_rep operator = (const SparseComplexQR_rep&);
83 
84  };
85 private:
87 
88 public:
89  SparseComplexQR (void) :
90  rep (new SparseComplexQR_rep (SparseComplexMatrix (), 0)) { }
91 
92  SparseComplexQR (const SparseComplexMatrix& a, int order = 0) :
93  rep (new SparseComplexQR_rep (a, order)) { }
94 
95  SparseComplexQR (const SparseComplexQR& a) : rep (a.rep) { rep->count++; }
96 
98  {
99  if (--rep->count == 0)
100  delete rep;
101  }
102 
103  SparseComplexQR& operator = (const SparseComplexQR& a)
104  {
105  if (this != &a)
106  {
107  if (--rep->count == 0)
108  delete rep;
109 
110  rep = a.rep;
111  rep->count++;
112  }
113  return *this;
114  }
115 
116  bool ok (void) const { return rep->ok (); }
117 
118  SparseComplexMatrix V (void) const { return rep->V (); }
119 
120  ColumnVector Pinv (void) const { return rep->P (); }
121 
122  ColumnVector P (void) const { return rep->P (); }
123 
124  SparseComplexMatrix R (const bool econ = false) const
125  { return rep->R(econ); }
126 
127  ComplexMatrix C (const ComplexMatrix &b) const { return rep->C(b); }
128 
129  ComplexMatrix Q (void) const { return rep->Q (); }
130 
131  friend ComplexMatrix qrsolve (const SparseComplexMatrix &a, const Matrix &b,
132  octave_idx_type &info);
133 
135  const SparseMatrix &b,
136  octave_idx_type &info);
137 
138  friend ComplexMatrix qrsolve (const SparseComplexMatrix &a,
139  const ComplexMatrix &b,
140  octave_idx_type &info);
141 
143  const SparseComplexMatrix &b,
144  octave_idx_type &info);
145 
146 protected:
147 #ifdef HAVE_CXSPARSE
148  CXSPARSE_ZNAME (s) * S (void) { return rep->S; }
149 
150  CXSPARSE_ZNAME (n) * N (void) { return rep->N; }
151 #endif
152 };
153 
154 
155 // Publish externally used friend functions.
156 
157 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a, const Matrix &b,
158  octave_idx_type &info);
159 
160 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a,
161  const MArray<double> &b,
162  octave_idx_type &info);
163 
165  const SparseMatrix &b,
166  octave_idx_type &info);
167 
168 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a,
169  const ComplexMatrix &b,
170  octave_idx_type &info);
171 
172 extern ComplexMatrix qrsolve (const SparseComplexMatrix &a,
173  const MArray<Complex> &b,
174  octave_idx_type &info);
175 
177  const SparseComplexMatrix &b,
178  octave_idx_type &info);
179 #endif