Bug Summary

File:liboctave/numeric/dbleQRP.cc
Location:line 80, column 7
Description:Assigned value is garbage or undefined

Annotated Source Code

1/*
2
3Copyright (C) 1994-2013 John W. Eaton
4Copyright (C) 2009 VZLU Prague
5
6This file is part of Octave.
7
8Octave is free software; you can redistribute it and/or modify it
9under the terms of the GNU General Public License as published by the
10Free Software Foundation; either version 3 of the License, or (at your
11option) any later version.
12
13Octave is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with Octave; see the file COPYING. If not, see
20<http://www.gnu.org/licenses/>.
21
22*/
23
24#ifdef HAVE_CONFIG_H1
25#include <config.h>
26#endif
27
28#include <cassert>
29
30#include "dbleQRP.h"
31#include "f77-fcn.h"
32#include "lo-error.h"
33#include "oct-locbuf.h"
34
35extern "C"
36{
37 F77_RET_Tint
38 F77_FUNC (dgeqp3, DGEQP3)dgeqp3_ (const octave_idx_type&, const octave_idx_type&,
39 double*, const octave_idx_type&,
40 octave_idx_type*, double*, double*,
41 const octave_idx_type&, octave_idx_type&);
42}
43
44// It would be best to share some of this code with QR class...
45
46QRP::QRP (const Matrix& a, qr_type_t qr_type)
47 : QR (), p ()
48{
49 init (a, qr_type);
50}
51
52void
53QRP::init (const Matrix& a, qr_type_t qr_type)
54{
55 assert (qr_type != qr_type_raw)((qr_type != qr_type_raw) ? static_cast<void> (0) : __assert_fail
("qr_type != qr_type_raw", "numeric/dbleQRP.cc", 55, __PRETTY_FUNCTION__
))
;
56
57 octave_idx_type m = a.rows ();
58 octave_idx_type n = a.cols ();
59
60 octave_idx_type min_mn = m < n ? m : n;
1
'?' condition is false
61 OCTAVE_LOCAL_BUFFER (double, tau, min_mn)octave_local_buffer<double> _buffer_tau (min_mn); double
*tau = _buffer_tau
;
62
63 octave_idx_type info = 0;
64
65 Matrix afact = a;
66 if (m > n && qr_type == qr_type_std)
67 afact.resize (m, m);
68
69 MArray<octave_idx_type> jpvt (dim_vector (n, 1), 0);
70
71 if (m > 0)
2
Assuming 'm' is > 0
3
Taking true branch
72 {
73 // workspace query.
74 double rlwork;
4
'rlwork' declared without an initial value
75 F77_XFCN (dgeqp3, DGEQP3, (m, n, afact.fortran_vec (),do { octave_jmp_buf saved_context; sig_atomic_t saved_octave_interrupt_immediately
= octave_interrupt_immediately; f77_exception_encountered = 0
; octave_save_current_context (saved_context); if (_setjmp (current_context
)) { octave_interrupt_immediately = saved_octave_interrupt_immediately
; octave_restore_current_context (saved_context); if (f77_exception_encountered
) (*current_liboctave_error_handler) ("exception encountered in Fortran subroutine %s"
, "dgeqp3_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; dgeqp3_ (m, n, afact.fortran_vec (), m, jpvt.fortran_vec (
), tau, &rlwork, -1, info); octave_interrupt_immediately--
; octave_restore_current_context (saved_context); } } while (
0)
76 m, jpvt.fortran_vec (), tau,do { octave_jmp_buf saved_context; sig_atomic_t saved_octave_interrupt_immediately
= octave_interrupt_immediately; f77_exception_encountered = 0
; octave_save_current_context (saved_context); if (_setjmp (current_context
)) { octave_interrupt_immediately = saved_octave_interrupt_immediately
; octave_restore_current_context (saved_context); if (f77_exception_encountered
) (*current_liboctave_error_handler) ("exception encountered in Fortran subroutine %s"
, "dgeqp3_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; dgeqp3_ (m, n, afact.fortran_vec (), m, jpvt.fortran_vec (
), tau, &rlwork, -1, info); octave_interrupt_immediately--
; octave_restore_current_context (saved_context); } } while (
0)
77 &rlwork, -1, info))do { octave_jmp_buf saved_context; sig_atomic_t saved_octave_interrupt_immediately
= octave_interrupt_immediately; f77_exception_encountered = 0
; octave_save_current_context (saved_context); if (_setjmp (current_context
)) { octave_interrupt_immediately = saved_octave_interrupt_immediately
; octave_restore_current_context (saved_context); if (f77_exception_encountered
) (*current_liboctave_error_handler) ("exception encountered in Fortran subroutine %s"
, "dgeqp3_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; dgeqp3_ (m, n, afact.fortran_vec (), m, jpvt.fortran_vec (
), tau, &rlwork, -1, info); octave_interrupt_immediately--
; octave_restore_current_context (saved_context); } } while (
0)
;
78
79 // allocate buffer and do the job.
80 octave_idx_type lwork = rlwork;
5
Assigned value is garbage or undefined
81 lwork = std::max (lwork, static_cast<octave_idx_type> (1));
82 OCTAVE_LOCAL_BUFFER (double, work, lwork)octave_local_buffer<double> _buffer_work (lwork); double
*work = _buffer_work
;
83 F77_XFCN (dgeqp3, DGEQP3, (m, n, afact.fortran_vec (),do { octave_jmp_buf saved_context; sig_atomic_t saved_octave_interrupt_immediately
= octave_interrupt_immediately; f77_exception_encountered = 0
; octave_save_current_context (saved_context); if (_setjmp (current_context
)) { octave_interrupt_immediately = saved_octave_interrupt_immediately
; octave_restore_current_context (saved_context); if (f77_exception_encountered
) (*current_liboctave_error_handler) ("exception encountered in Fortran subroutine %s"
, "dgeqp3_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; dgeqp3_ (m, n, afact.fortran_vec (), m, jpvt.fortran_vec (
), tau, work, lwork, info); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
84 m, jpvt.fortran_vec (), tau,do { octave_jmp_buf saved_context; sig_atomic_t saved_octave_interrupt_immediately
= octave_interrupt_immediately; f77_exception_encountered = 0
; octave_save_current_context (saved_context); if (_setjmp (current_context
)) { octave_interrupt_immediately = saved_octave_interrupt_immediately
; octave_restore_current_context (saved_context); if (f77_exception_encountered
) (*current_liboctave_error_handler) ("exception encountered in Fortran subroutine %s"
, "dgeqp3_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; dgeqp3_ (m, n, afact.fortran_vec (), m, jpvt.fortran_vec (
), tau, work, lwork, info); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
85 work, lwork, info))do { octave_jmp_buf saved_context; sig_atomic_t saved_octave_interrupt_immediately
= octave_interrupt_immediately; f77_exception_encountered = 0
; octave_save_current_context (saved_context); if (_setjmp (current_context
)) { octave_interrupt_immediately = saved_octave_interrupt_immediately
; octave_restore_current_context (saved_context); if (f77_exception_encountered
) (*current_liboctave_error_handler) ("exception encountered in Fortran subroutine %s"
, "dgeqp3_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; dgeqp3_ (m, n, afact.fortran_vec (), m, jpvt.fortran_vec (
), tau, work, lwork, info); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
;
86 }
87 else
88 for (octave_idx_type i = 0; i < n; i++) jpvt(i) = i+1;
89
90 // Form Permutation matrix (if economy is requested, return the
91 // indices only!)
92
93 jpvt -= static_cast<octave_idx_type> (1);
94 p = PermMatrix (jpvt, true);
95
96
97 form (n, afact, tau, qr_type);
98}
99
100RowVector
101QRP::Pvec (void) const
102{
103 Array<double> pa (p.pvec ());
104 RowVector pv (MArray<double> (pa) + 1.0);
105 return pv;
106}