comparison liboctave/numeric/CmplxLU.cc @ 21136:7cac4e7458f2

maint: clean up code around calls to current_liboctave_error_handler. Remove statements after call to handler that are no longer reachable. Place input validation first and immediately call handler if necessary. Change if/error_handler/else to if/error_handler and re-indent code. * Array-util.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MArray.cc, PermMatrix.cc, Sparse.cc, Sparse.h, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc, CmplxQR.cc, CmplxSCHUR.cc, CmplxSVD.cc, DASPK.cc, EIG.cc, LSODE.cc, Quad.cc, SparseCmplxCHOL.cc, SparseCmplxLU.cc, SparseCmplxQR.cc, SparseQR.cc, SparsedbleCHOL.cc, SparsedbleLU.cc, base-lu.cc, bsxfun-defs.cc, dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc, fCmplxCHOL.cc, fCmplxLU.cc, fCmplxQR.cc, fCmplxSCHUR.cc, fEIG.cc, floatAEPBAL.cc, floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc, floatSCHUR.cc, floatSVD.cc, lo-specfun.cc, oct-fftw.cc, oct-rand.cc, oct-spparms.cc, sparse-base-chol.cc, sparse-dmsolve.cc, file-ops.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-syscalls.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, lo-ieee.cc, lo-regexp.cc, oct-base64.cc, oct-shlib.cc, pathsearch.cc, singleton-cleanup.cc, sparse-util.cc, unwind-prot.cc: Remove statements after call to handler that are no longer reachable. Place input validation first and immediately call handler if necessary. Change if/error_handler/else to if/error_handler and re-indent code.
author Rik <rik@octave.org>
date Sat, 23 Jan 2016 13:52:03 -0800
parents a9574e3c6e9e
children e2fca7d79169
comparison
equal deleted inserted replaced
21135:95da3bc8a281 21136:7cac4e7458f2
96 96
97 octave_idx_type m = l.rows (); 97 octave_idx_type m = l.rows ();
98 octave_idx_type n = r.columns (); 98 octave_idx_type n = r.columns ();
99 octave_idx_type k = l.columns (); 99 octave_idx_type k = l.columns ();
100 100
101 if (u.numel () == m && v.numel () == n) 101 if (u.numel () != m || v.numel () != n)
102 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
103
104 ComplexColumnVector utmp = u;
105 ComplexColumnVector vtmp = v;
106 F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k,
107 utmp.fortran_vec (), vtmp.fortran_vec ()));
108 }
109
110 void ComplexLU::update (const ComplexMatrix& u, const ComplexMatrix& v)
111 {
112 if (packed ())
113 unpack ();
114
115 ComplexMatrix& l = l_fact;
116 ComplexMatrix& r = a_fact;
117
118 octave_idx_type m = l.rows ();
119 octave_idx_type n = r.columns ();
120 octave_idx_type k = l.columns ();
121
122 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ())
123 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
124
125 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
102 { 126 {
103 ComplexColumnVector utmp = u; 127 ComplexColumnVector utmp = u.column (i);
104 ComplexColumnVector vtmp = v; 128 ComplexColumnVector vtmp = v.column (i);
105 F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, 129 F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (),
130 m, r.fortran_vec (), k,
106 utmp.fortran_vec (), vtmp.fortran_vec ())); 131 utmp.fortran_vec (), vtmp.fortran_vec ()));
107 } 132 }
108 else
109 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
110 }
111
112 void ComplexLU::update (const ComplexMatrix& u, const ComplexMatrix& v)
113 {
114 if (packed ())
115 unpack ();
116
117 ComplexMatrix& l = l_fact;
118 ComplexMatrix& r = a_fact;
119
120 octave_idx_type m = l.rows ();
121 octave_idx_type n = r.columns ();
122 octave_idx_type k = l.columns ();
123
124 if (u.rows () == m && v.rows () == n && u.cols () == v.cols ())
125 {
126 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
127 {
128 ComplexColumnVector utmp = u.column (i);
129 ComplexColumnVector vtmp = v.column (i);
130 F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (),
131 m, r.fortran_vec (), k,
132 utmp.fortran_vec (), vtmp.fortran_vec ()));
133 }
134 }
135 else
136 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
137 } 133 }
138 134
139 void ComplexLU::update_piv (const ComplexColumnVector& u, 135 void ComplexLU::update_piv (const ComplexColumnVector& u,
140 const ComplexColumnVector& v) 136 const ComplexColumnVector& v)
141 { 137 {
147 143
148 octave_idx_type m = l.rows (); 144 octave_idx_type m = l.rows ();
149 octave_idx_type n = r.columns (); 145 octave_idx_type n = r.columns ();
150 octave_idx_type k = l.columns (); 146 octave_idx_type k = l.columns ();
151 147
152 if (u.numel () == m && v.numel () == n) 148 if (u.numel () != m || v.numel () != n)
149 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
150
151 ComplexColumnVector utmp = u;
152 ComplexColumnVector vtmp = v;
153 OCTAVE_LOCAL_BUFFER (Complex, w, m);
154 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
155 F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (),
156 m, r.fortran_vec (), k,
157 ipvt.fortran_vec (),
158 utmp.data (), vtmp.data (), w));
159 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
160 }
161
162 void ComplexLU::update_piv (const ComplexMatrix& u, const ComplexMatrix& v)
163 {
164 if (packed ())
165 unpack ();
166
167 ComplexMatrix& l = l_fact;
168 ComplexMatrix& r = a_fact;
169
170 octave_idx_type m = l.rows ();
171 octave_idx_type n = r.columns ();
172 octave_idx_type k = l.columns ();
173
174 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ())
175 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
176
177 OCTAVE_LOCAL_BUFFER (Complex, w, m);
178 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
179 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
153 { 180 {
154 ComplexColumnVector utmp = u; 181 ComplexColumnVector utmp = u.column (i);
155 ComplexColumnVector vtmp = v; 182 ComplexColumnVector vtmp = v.column (i);
156 OCTAVE_LOCAL_BUFFER (Complex, w, m);
157 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
158 F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (), 183 F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (),
159 m, r.fortran_vec (), k, 184 m, r.fortran_vec (), k,
160 ipvt.fortran_vec (), 185 ipvt.fortran_vec (),
161 utmp.data (), vtmp.data (), w)); 186 utmp.data (), vtmp.data (), w));
162 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
163 } 187 }
164 else 188 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
165 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
166 }
167
168 void ComplexLU::update_piv (const ComplexMatrix& u, const ComplexMatrix& v)
169 {
170 if (packed ())
171 unpack ();
172
173 ComplexMatrix& l = l_fact;
174 ComplexMatrix& r = a_fact;
175
176 octave_idx_type m = l.rows ();
177 octave_idx_type n = r.columns ();
178 octave_idx_type k = l.columns ();
179
180 if (u.rows () == m && v.rows () == n && u.cols () == v.cols ())
181 {
182 OCTAVE_LOCAL_BUFFER (Complex, w, m);
183 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
184 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
185 {
186 ComplexColumnVector utmp = u.column (i);
187 ComplexColumnVector vtmp = v.column (i);
188 F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (),
189 m, r.fortran_vec (), k,
190 ipvt.fortran_vec (),
191 utmp.data (), vtmp.data (), w));
192 }
193 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
194 }
195 else
196 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
197 } 189 }
198 190
199 #else 191 #else
200 192
201 void ComplexLU::update (const ComplexColumnVector&, const ComplexColumnVector&) 193 void ComplexLU::update (const ComplexColumnVector&, const ComplexColumnVector&)