comparison liboctave/numeric/dbleLU.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
95 95
96 octave_idx_type m = l.rows (); 96 octave_idx_type m = l.rows ();
97 octave_idx_type n = r.columns (); 97 octave_idx_type n = r.columns ();
98 octave_idx_type k = l.columns (); 98 octave_idx_type k = l.columns ();
99 99
100 if (u.numel () == m && v.numel () == n) 100 if (u.numel () != m || v.numel () != n)
101 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
102
103 ColumnVector utmp = u;
104 ColumnVector vtmp = v;
105 F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k,
106 utmp.fortran_vec (), vtmp.fortran_vec ()));
107 }
108
109 void LU::update (const Matrix& u, const Matrix& v)
110 {
111 if (packed ())
112 unpack ();
113
114 Matrix& l = l_fact;
115 Matrix& r = a_fact;
116
117 octave_idx_type m = l.rows ();
118 octave_idx_type n = r.columns ();
119 octave_idx_type k = l.columns ();
120
121 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ())
122 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
123
124 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
101 { 125 {
102 ColumnVector utmp = u; 126 ColumnVector utmp = u.column (i);
103 ColumnVector vtmp = v; 127 ColumnVector vtmp = v.column (i);
104 F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, 128 F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (),
129 m, r.fortran_vec (), k,
105 utmp.fortran_vec (), vtmp.fortran_vec ())); 130 utmp.fortran_vec (), vtmp.fortran_vec ()));
106 } 131 }
107 else 132 }
108 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); 133
109 } 134 void LU::update_piv (const ColumnVector& u, const ColumnVector& v)
110 135 {
111 void LU::update (const Matrix& u, const Matrix& v) 136 if (packed ())
112 { 137 unpack ();
113 if (packed ()) 138
114 unpack (); 139 Matrix& l = l_fact;
115 140 Matrix& r = a_fact;
116 Matrix& l = l_fact; 141
117 Matrix& r = a_fact; 142 octave_idx_type m = l.rows ();
118 143 octave_idx_type n = r.columns ();
119 octave_idx_type m = l.rows (); 144 octave_idx_type k = l.columns ();
120 octave_idx_type n = r.columns (); 145
121 octave_idx_type k = l.columns (); 146 if (u.numel () != m || v.numel () != n)
122 147 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
123 if (u.rows () == m && v.rows () == n && u.cols () == v.cols ()) 148
149 ColumnVector utmp = u;
150 ColumnVector vtmp = v;
151 OCTAVE_LOCAL_BUFFER (double, w, m);
152 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
153 F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (),
154 m, r.fortran_vec (), k,
155 ipvt.fortran_vec (),
156 utmp.data (), vtmp.data (), w));
157 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
158 }
159
160 void LU::update_piv (const Matrix& u, const Matrix& v)
161 {
162 if (packed ())
163 unpack ();
164
165 Matrix& l = l_fact;
166 Matrix& r = a_fact;
167
168 octave_idx_type m = l.rows ();
169 octave_idx_type n = r.columns ();
170 octave_idx_type k = l.columns ();
171
172 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ())
173 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
174
175 OCTAVE_LOCAL_BUFFER (double, w, m);
176 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
177 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
124 { 178 {
125 for (volatile octave_idx_type i = 0; i < u.cols (); i++) 179 ColumnVector utmp = u.column (i);
126 { 180 ColumnVector vtmp = v.column (i);
127 ColumnVector utmp = u.column (i);
128 ColumnVector vtmp = v.column (i);
129 F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (),
130 m, r.fortran_vec (), k,
131 utmp.fortran_vec (), vtmp.fortran_vec ()));
132 }
133 }
134 else
135 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
136 }
137
138 void LU::update_piv (const ColumnVector& u, const ColumnVector& v)
139 {
140 if (packed ())
141 unpack ();
142
143 Matrix& l = l_fact;
144 Matrix& r = a_fact;
145
146 octave_idx_type m = l.rows ();
147 octave_idx_type n = r.columns ();
148 octave_idx_type k = l.columns ();
149
150 if (u.numel () == m && v.numel () == n)
151 {
152 ColumnVector utmp = u;
153 ColumnVector vtmp = v;
154 OCTAVE_LOCAL_BUFFER (double, w, m);
155 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
156 F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (), 181 F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (),
157 m, r.fortran_vec (), k, 182 m, r.fortran_vec (), k,
158 ipvt.fortran_vec (), 183 ipvt.fortran_vec (),
159 utmp.data (), vtmp.data (), w)); 184 utmp.data (), vtmp.data (), w));
160 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
161 } 185 }
162 else 186 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
163 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
164 }
165
166 void LU::update_piv (const Matrix& u, const Matrix& v)
167 {
168 if (packed ())
169 unpack ();
170
171 Matrix& l = l_fact;
172 Matrix& r = a_fact;
173
174 octave_idx_type m = l.rows ();
175 octave_idx_type n = r.columns ();
176 octave_idx_type k = l.columns ();
177
178 if (u.rows () == m && v.rows () == n && u.cols () == v.cols ())
179 {
180 OCTAVE_LOCAL_BUFFER (double, w, m);
181 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment
182 for (volatile octave_idx_type i = 0; i < u.cols (); i++)
183 {
184 ColumnVector utmp = u.column (i);
185 ColumnVector vtmp = v.column (i);
186 F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (),
187 m, r.fortran_vec (), k,
188 ipvt.fortran_vec (),
189 utmp.data (), vtmp.data (), w));
190 }
191 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement
192 }
193 else
194 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch");
195 } 187 }
196 188
197 #else 189 #else
198 190
199 void LU::update (const ColumnVector&, const ColumnVector&) 191 void LU::update (const ColumnVector&, const ColumnVector&)