GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
numeric
fCmplxQRP.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 1994-2013 John W. Eaton
4
Copyright (C) 2009 VZLU Prague
5
6
This file is part of Octave.
7
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
12
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
21
22
*/
23
24
#ifdef HAVE_CONFIG_H
25
#include <config.h>
26
#endif
27
28
#include <cassert>
29
30
#include "
fCmplxQRP.h
"
31
#include "
f77-fcn.h
"
32
#include "
lo-error.h
"
33
#include "
oct-locbuf.h
"
34
35
extern
"C"
36
{
37
F77_RET_T
38
F77_FUNC
(cgeqp3, CGEQP3) (
const
octave_idx_type
&,
const
octave_idx_type&,
39
FloatComplex
*,
const
octave_idx_type&,
40
octave_idx_type*, FloatComplex*, FloatComplex*,
41
const
octave_idx_type&,
float
*, octave_idx_type&);
42
}
43
44
// It would be best to share some of this code with FloatComplexQR class...
45
46
FloatComplexQRP::FloatComplexQRP
(
const
FloatComplexMatrix
& a,
47
qr_type_t
qr_type)
48
:
FloatComplexQR
(), p ()
49
{
50
init
(a, qr_type);
51
}
52
53
void
54
FloatComplexQRP::init
(
const
FloatComplexMatrix
& a,
qr_type_t
qr_type)
55
{
56
assert (qr_type !=
qr_type_raw
);
57
58
octave_idx_type
m = a.
rows
();
59
octave_idx_type
n = a.
cols
();
60
61
octave_idx_type
min_mn = m < n ? m : n;
62
OCTAVE_LOCAL_BUFFER
(
FloatComplex
, tau, min_mn);
63
64
octave_idx_type
info = 0;
65
66
FloatComplexMatrix
afact = a;
67
if
(m > n && qr_type ==
qr_type_std
)
68
afact.
resize
(m, m);
69
70
MArray<octave_idx_type>
jpvt (
dim_vector
(n, 1), 0);
71
72
if
(m > 0)
73
{
74
OCTAVE_LOCAL_BUFFER
(
float
, rwork, 2*n);
75
76
// workspace query.
77
FloatComplex
clwork;
78
F77_XFCN
(cgeqp3, CGEQP3, (m, n, afact.
fortran_vec
(),
79
m, jpvt.
fortran_vec
(), tau,
80
&clwork, -1, rwork, info));
81
82
// allocate buffer and do the job.
83
octave_idx_type
lwork = clwork.real ();
84
lwork =
std::max
(lwork, static_cast<octave_idx_type> (1));
85
OCTAVE_LOCAL_BUFFER
(
FloatComplex
, work, lwork);
86
F77_XFCN
(cgeqp3, CGEQP3, (m, n, afact.
fortran_vec
(),
87
m, jpvt.
fortran_vec
(), tau,
88
work, lwork, rwork, info));
89
}
90
else
91
for
(
octave_idx_type
i = 0; i < n; i++) jpvt(i) = i+1;
92
93
// Form Permutation matrix (if economy is requested, return the
94
// indices only!)
95
96
jpvt -=
static_cast<
octave_idx_type
>
(1);
97
p
=
PermMatrix
(jpvt,
true
);
98
99
100
form
(n, afact, tau, qr_type);
101
}
102
103
FloatRowVector
104
FloatComplexQRP::Pvec
(
void
)
const
105
{
106
Array<float>
pa (
p
.
pvec
());
107
FloatRowVector
pv (
MArray<float>
(pa) + 1.0
f
);
108
return
pv;
109
}
Generated on Mon Dec 30 2013 03:04:49 for GNU Octave by
1.8.1.2