Bug Summary

File:liboctave/numeric/floatHESS.cc
Location:line 125, column 3
Description:Undefined or garbage value returned to caller

Annotated Source Code

1/*
2
3Copyright (C) 1994-2013 John W. Eaton
4
5This file is part of Octave.
6
7Octave is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 3 of the License, or (at your
10option) any later version.
11
12Octave is distributed in the hope that it will be useful, but WITHOUT
13ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with Octave; see the file COPYING. If not, see
19<http://www.gnu.org/licenses/>.
20
21*/
22
23#ifdef HAVE_CONFIG_H1
24#include <config.h>
25#endif
26
27#include "floatHESS.h"
28#include "f77-fcn.h"
29#include "lo-error.h"
30
31extern "C"
32{
33 F77_RET_Tint
34 F77_FUNC (sgebal, SGEBAL)sgebal_ (F77_CONST_CHAR_ARG_DECLconst char *,
35 const octave_idx_type&, float*,
36 const octave_idx_type&, octave_idx_type&,
37 octave_idx_type&, float*, octave_idx_type&
38 F77_CHAR_ARG_LEN_DECL, long);
39
40 F77_RET_Tint
41 F77_FUNC (sgehrd, SGEHRD)sgehrd_ (const octave_idx_type&, const octave_idx_type&,
42 const octave_idx_type&, float*,
43 const octave_idx_type&, float*, float*,
44 const octave_idx_type&, octave_idx_type&);
45
46 F77_RET_Tint
47 F77_FUNC (sorghr, SORGHR)sorghr_ (const octave_idx_type&, const octave_idx_type&,
48 const octave_idx_type&, float*,
49 const octave_idx_type&, float*, float*,
50 const octave_idx_type&, octave_idx_type&);
51
52 F77_RET_Tint
53 F77_FUNC (sgebak, SGEBAK)sgebak_ (F77_CONST_CHAR_ARG_DECLconst char *,
54 F77_CONST_CHAR_ARG_DECLconst char *,
55 const octave_idx_type&, const octave_idx_type&,
56 const octave_idx_type&, float*,
57 const octave_idx_type&, float*,
58 const octave_idx_type&, octave_idx_type&
59 F77_CHAR_ARG_LEN_DECL, long
60 F77_CHAR_ARG_LEN_DECL, long);
61}
62
63octave_idx_type
64FloatHESS::init (const FloatMatrix& a)
65{
66 octave_idx_type a_nr = a.rows ();
67 octave_idx_type a_nc = a.cols ();
68
69 if (a_nr != a_nc)
1
Taking false branch
70 {
71 (*current_liboctave_error_handler) ("FloatHESS requires square matrix");
72 return -1;
73 }
74
75 char job = 'N';
76 char side = 'R';
77
78 octave_idx_type n = a_nc;
79 octave_idx_type lwork = 32 * n;
80 octave_idx_type info;
2
'info' declared without an initial value
81 octave_idx_type ilo;
82 octave_idx_type ihi;
83
84 hess_mat = a;
85 float *h = hess_mat.fortran_vec ();
86
87 Array<float> scale (dim_vector (n, 1));
88 float *pscale = scale.fortran_vec ();
89
90 F77_XFCN (sgebal, SGEBAL, (F77_CONST_CHAR_ARG2 (&job, 1),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"
, "sgebal_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebal_ (&job, n, h, n, ilo, ihi, pscale, info , 1); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
91 n, h, n, ilo, ihi, pscale, infodo { 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"
, "sgebal_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebal_ (&job, n, h, n, ilo, ihi, pscale, info , 1); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
92 F77_CHAR_ARG_LEN (1)))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"
, "sgebal_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebal_ (&job, n, h, n, ilo, ihi, pscale, info , 1); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
;
93
94 Array<float> tau (dim_vector (n-1, 1));
95 float *ptau = tau.fortran_vec ();
96
97 Array<float> work (dim_vector (lwork, 1));
98 float *pwork = work.fortran_vec ();
99
100 F77_XFCN (sgehrd, SGEHRD, (n, ilo, ihi, h, n, ptau, pwork,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"
, "sgehrd_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgehrd_ (n, ilo, ihi, h, n, ptau, pwork, lwork, info); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
101 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"
, "sgehrd_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgehrd_ (n, ilo, ihi, h, n, ptau, pwork, lwork, info); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
;
102
103 unitary_hess_mat = hess_mat;
104 float *z = unitary_hess_mat.fortran_vec ();
105
106 F77_XFCN (sorghr, SORGHR, (n, ilo, ihi, z, n, ptau, pwork,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"
, "sorghr_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sorghr_ (n, ilo, ihi, z, n, ptau, pwork, lwork, info); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
107 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"
, "sorghr_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sorghr_ (n, ilo, ihi, z, n, ptau, pwork, lwork, info); octave_interrupt_immediately
--; octave_restore_current_context (saved_context); } } while
(0)
;
108
109 F77_XFCN (sgebak, SGEBAK, (F77_CONST_CHAR_ARG2 (&job, 1),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"
, "sgebak_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebak_ (&job, &side, n, ilo, ihi, pscale, n, z, n
, info , 1 , 1); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
110 F77_CONST_CHAR_ARG2 (&side, 1),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"
, "sgebak_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebak_ (&job, &side, n, ilo, ihi, pscale, n, z, n
, info , 1 , 1); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
111 n, ilo, ihi, pscale, n, z,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"
, "sgebak_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebak_ (&job, &side, n, ilo, ihi, pscale, n, z, n
, info , 1 , 1); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
112 n, infodo { 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"
, "sgebak_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebak_ (&job, &side, n, ilo, ihi, pscale, n, z, n
, info , 1 , 1); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
113 F77_CHAR_ARG_LEN (1)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"
, "sgebak_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebak_ (&job, &side, n, ilo, ihi, pscale, n, z, n
, info , 1 , 1); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
114 F77_CHAR_ARG_LEN (1)))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"
, "sgebak_"); else octave_rethrow_exception (); } else { octave_interrupt_immediately
++; sgebak_ (&job, &side, n, ilo, ihi, pscale, n, z, n
, info , 1 , 1); octave_interrupt_immediately--; octave_restore_current_context
(saved_context); } } while (0)
;
115
116 // If someone thinks of a more graceful way of doing
117 // this (or faster for that matter :-)), please let
118 // me know!
119
120 if (n > 2)
3
Assuming 'n' is <= 2
4
Taking false branch
121 for (octave_idx_type j = 0; j < a_nc; j++)
122 for (octave_idx_type i = j+2; i < a_nr; i++)
123 hess_mat.elem (i, j) = 0;
124
125 return info;
5
Undefined or garbage value returned to caller
126}