Mercurial > octave-nkf
comparison libinterp/dldfcn/amd.cc @ 20587:f90c8372b7ba
eliminate many more simple uses of error_state
* Cell.cc, __ichol__.cc, __ilu__.cc, balance.cc, bsxfun.cc, colloc.cc,
det.cc, dlmread.cc, dynamic-ld.cc, eig.cc, fft.cc, fft2.cc, fftn.cc,
gcd.cc, getgrent.cc, getpwent.cc, givens.cc, hess.cc, input.cc,
levenshtein.cc, load-path.cc, lookup.cc, ls-mat-ascii.cc, ls-mat4.cc,
lsode.cc, lu.cc, max.cc, md5sum.cc, mex.cc, pager.cc, pinv.cc,
pr-output.cc, qz.cc, schur.cc, sparse.cc, sqrtm.cc, str2double.cc,
strfns.cc, sub2ind.cc, sysdep.cc, time.cc, toplev.cc, tril.cc,
tsearch.cc, typecast.cc, __init_gnuplot__.cc, __magick_read__.cc,
__osmesa_print__.cc, amd.cc, audiodevinfo.cc, dmperm.cc, fftw.cc,
symrcm.cc, ov-base-diag.cc, ov-base-sparse.cc, ov-base.cc,
ov-bool-sparse.cc, ov-builtin.cc, ov-complex.cc, ov-cx-diag.cc,
ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc,
ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc,
ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-lazy-idx.cc, ov-mex-fcn.cc,
ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc,
ov-scalar.cc, ov-str-mat.cc, op-bm-b.cc, op-bm-bm.cc, op-sbm-b.cc,
op-sbm-bm.cc, op-str-m.cc, op-str-s.cc, oct-parse.in.yy, pt-cbinop.cc,
pt-colon.cc, pt-decl.cc, pt-exp.cc, pt-id.cc, pt-misc.cc,
pt-select.cc, pt-unop.cc: Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 05 Oct 2015 19:29:36 -0400 |
parents | 075a5e2e1ba5 |
children |
comparison
equal
deleted
inserted
replaced
20586:b7ac1e94266e | 20587:f90c8372b7ba |
---|---|
131 } | 131 } |
132 | 132 |
133 if (!error_state && n_row != n_col) | 133 if (!error_state && n_row != n_col) |
134 error ("amd: matrix S must be square"); | 134 error ("amd: matrix S must be square"); |
135 | 135 |
136 OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL); | |
137 AMD_NAME (_defaults) (Control) ; | |
138 if (nargin > 1) | |
139 { | |
140 octave_scalar_map arg1 = args(1).scalar_map_value (); | |
141 | |
142 if (!error_state) | |
143 { | |
144 octave_value tmp; | |
145 | |
146 tmp = arg1.getfield ("dense"); | |
147 if (tmp.is_defined ()) | |
148 Control[AMD_DENSE] = tmp.double_value (); | |
149 | |
150 tmp = arg1.getfield ("aggressive"); | |
151 if (tmp.is_defined ()) | |
152 Control[AMD_AGGRESSIVE] = tmp.double_value (); | |
153 } | |
154 else | |
155 error ("amd: OPTS argument must be a scalar structure"); | |
156 } | |
157 | |
136 if (!error_state) | 158 if (!error_state) |
137 { | 159 { |
138 OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL); | 160 OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col); |
139 AMD_NAME (_defaults) (Control) ; | 161 Matrix xinfo (AMD_INFO, 1); |
140 if (nargin > 1) | 162 double *Info = xinfo.fortran_vec (); |
141 { | 163 |
142 octave_scalar_map arg1 = args(1).scalar_map_value (); | 164 // FIXME: how can we manage the memory allocation of amd |
143 | 165 // in a cleaner manner? |
144 if (!error_state) | 166 SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); |
145 { | 167 SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); |
146 octave_value tmp; | 168 SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); |
147 | 169 SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc); |
148 tmp = arg1.getfield ("dense"); | 170 SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf); |
149 if (tmp.is_defined ()) | 171 |
150 Control[AMD_DENSE] = tmp.double_value (); | 172 octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P, |
151 | 173 Control, Info); |
152 tmp = arg1.getfield ("aggressive"); | 174 |
153 if (tmp.is_defined ()) | 175 switch (result) |
154 Control[AMD_AGGRESSIVE] = tmp.double_value (); | 176 { |
155 } | 177 case AMD_OUT_OF_MEMORY: |
156 else | 178 error ("amd: out of memory"); |
157 error ("amd: OPTS argument must be a scalar structure"); | 179 break; |
158 } | 180 |
159 | 181 case AMD_INVALID: |
160 if (!error_state) | 182 error ("amd: matrix S is corrupted"); |
161 { | 183 break; |
162 OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col); | 184 |
163 Matrix xinfo (AMD_INFO, 1); | 185 default: |
164 double *Info = xinfo.fortran_vec (); | 186 { |
165 | 187 if (nargout > 1) |
166 // FIXME: how can we manage the memory allocation of amd | 188 retval(1) = xinfo; |
167 // in a cleaner manner? | 189 |
168 SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); | 190 Matrix Pout (1, n_col); |
169 SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); | 191 for (octave_idx_type i = 0; i < n_col; i++) |
170 SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); | 192 Pout.xelem (i) = P[i] + 1; |
171 SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc); | 193 |
172 SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf); | 194 retval(0) = Pout; |
173 | 195 } |
174 octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P, | |
175 Control, Info); | |
176 | |
177 switch (result) | |
178 { | |
179 case AMD_OUT_OF_MEMORY: | |
180 error ("amd: out of memory"); | |
181 break; | |
182 case AMD_INVALID: | |
183 error ("amd: matrix S is corrupted"); | |
184 break; | |
185 default: | |
186 { | |
187 if (nargout > 1) | |
188 retval(1) = xinfo; | |
189 | |
190 Matrix Pout (1, n_col); | |
191 for (octave_idx_type i = 0; i < n_col; i++) | |
192 Pout.xelem (i) = P[i] + 1; | |
193 | |
194 retval(0) = Pout; | |
195 } | |
196 } | |
197 } | 196 } |
198 } | 197 } |
199 } | 198 } |
200 #else | 199 #else |
201 | 200 |