comparison liboctave/numeric/svd.cc @ 22228:4afe3705ea75

svd: do not shadow member variables with local variables. * liboctave/numeric/svd.cc, liboctave/numeric/svd.h: there was no issue with current code because member variables never change after construction. Still, it's not good practice and the compilers will warn about it.
author Carnë Draug <carandraug@octave.org>
date Tue, 09 Aug 2016 00:21:36 +0100
parents 469c817eb256
children 60986498af9e
comparison
equal deleted inserted replaced
22227:ab139f0733b9 22228:4afe3705ea75
129 129
130 template <typename T> 130 template <typename T>
131 T 131 T
132 svd<T>::left_singular_matrix (void) const 132 svd<T>::left_singular_matrix (void) const
133 { 133 {
134 if (type == svd::Type::sigma_only) 134 if (m_type == svd::Type::sigma_only)
135 (*current_liboctave_error_handler) 135 (*current_liboctave_error_handler)
136 ("svd: U not computed because type == svd::sigma_only"); 136 ("svd: U not computed because type == svd::sigma_only");
137 137
138 return left_sm; 138 return left_sm;
139 } 139 }
140 140
141 template <typename T> 141 template <typename T>
142 T 142 T
143 svd<T>::right_singular_matrix (void) const 143 svd<T>::right_singular_matrix (void) const
144 { 144 {
145 if (type == svd::Type::sigma_only) 145 if (m_type == svd::Type::sigma_only)
146 (*current_liboctave_error_handler) 146 (*current_liboctave_error_handler)
147 ("svd: V not computed because type == svd::sigma_only"); 147 ("svd: V not computed because type == svd::sigma_only");
148 148
149 return right_sm; 149 return right_sm;
150 } 150 }
367 367
368 368
369 template<typename T> 369 template<typename T>
370 svd<T>::svd (const T& a, svd::Type type, 370 svd<T>::svd (const T& a, svd::Type type,
371 svd::Driver driver) 371 svd::Driver driver)
372 : type (type), driver (driver), left_sm (), sigma (), right_sm () 372 : m_type (type), m_driver (driver), left_sm (), sigma (), right_sm ()
373 { 373 {
374 octave_idx_type info; 374 octave_idx_type info;
375 375
376 octave_idx_type m = a.rows (); 376 octave_idx_type m = a.rows ();
377 octave_idx_type n = a.cols (); 377 octave_idx_type n = a.cols ();
378 378
379 if (m == 0 || n == 0) 379 if (m == 0 || n == 0)
380 { 380 {
381 switch (type) 381 switch (m_type)
382 { 382 {
383 case svd::Type::std: 383 case svd::Type::std:
384 left_sm = T (m, m, 0); 384 left_sm = T (m, m, 0);
385 for (octave_idx_type i = 0; i < m; i++) 385 for (octave_idx_type i = 0; i < m; i++)
386 left_sm.xelem (i, i) = 1; 386 left_sm.xelem (i, i) = 1;
415 octave_idx_type ncol_u = m; 415 octave_idx_type ncol_u = m;
416 octave_idx_type nrow_vt = n; 416 octave_idx_type nrow_vt = n;
417 octave_idx_type nrow_s = m; 417 octave_idx_type nrow_s = m;
418 octave_idx_type ncol_s = n; 418 octave_idx_type ncol_s = n;
419 419
420 switch (type) 420 switch (m_type)
421 { 421 {
422 case svd::Type::economy: 422 case svd::Type::economy:
423 jobu = jobv = 'S'; 423 jobu = jobv = 'S';
424 ncol_u = nrow_vt = nrow_s = ncol_s = min_mn; 424 ncol_u = nrow_vt = nrow_s = ncol_s = min_mn;
425 break; 425 break;
462 T work (1, 1); 462 T work (1, 1);
463 463
464 octave_idx_type m1 = std::max (m, 1); 464 octave_idx_type m1 = std::max (m, 1);
465 octave_idx_type nrow_vt1 = std::max (nrow_vt, 1); 465 octave_idx_type nrow_vt1 = std::max (nrow_vt, 1);
466 466
467 if (driver == svd::Driver::GESVD) 467 if (m_driver == svd::Driver::GESVD)
468 gesvd (jobu, jobv, m, n, tmp_data, m1, s_vec, u, vt, nrow_vt1, 468 gesvd (jobu, jobv, m, n, tmp_data, m1, s_vec, u, vt, nrow_vt1,
469 work, lwork, info); 469 work, lwork, info);
470 else if (driver == svd::Driver::GESDD) 470 else if (m_driver == svd::Driver::GESDD)
471 { 471 {
472 assert (jobu == jobv); 472 assert (jobu == jobv);
473 char jobz = jobu; 473 char jobz = jobu;
474 474
475 OCTAVE_LOCAL_BUFFER (octave_idx_type, iwork, 8 * std::min (m, n)); 475 OCTAVE_LOCAL_BUFFER (octave_idx_type, iwork, 8 * std::min (m, n));