comparison scripts/optimization/lsqnonneg.m @ 31266:e5e35410da90 stable

doc: Documented undocumented outputs for lsqnonneg and pqpnonneg lsqnonneg.m: Edited docstring to describe what the output lambda was, previously not documented. In the course of testing, an error was found for an (unlikely) edge case. Marked that with FIXME for now. pqpnonneg.m: Same as above.
author Arun Giridhar <arungiridhar@gmail.com>
date Thu, 06 Oct 2022 19:52:06 -0400
parents 796f54d4ddbf
children 44a68ac1a22f
comparison
equal deleted inserted replaced
31251:24247d13a44b 31266:e5e35410da90
67 ## 67 ##
68 ## @item @qcode{"iterations"}: The number of iterations taken. 68 ## @item @qcode{"iterations"}: The number of iterations taken.
69 ## @end itemize 69 ## @end itemize
70 ## 70 ##
71 ## @item lambda 71 ## @item lambda
72 ## @c FIXME: Something is output from the function, but what is it? 72 ## Conjugate gradient at the converged point. Zero elements are usually
73 ## Undocumented output 73 ## abutting coordinate planes. Negative elements are stable to small
74 ## perturbations.
75 ##
74 ## @end table 76 ## @end table
75 ## @seealso{pqpnonneg, lscov, optimset} 77 ## @seealso{pqpnonneg, lscov, optimset}
76 ## @end deftypefn 78 ## @end deftypefn
77 79
78 ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup. 80 ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup.
217 output = struct ("algorithm", "nnls", "iterations", iter); 219 output = struct ("algorithm", "nnls", "iterations", iter);
218 endif 220 endif
219 if (isargout (6)) 221 if (isargout (6))
220 lambda = zeros (size (x)); 222 lambda = zeros (size (x));
221 lambda(p) = w; 223 lambda(p) = w;
224 ## FIXME: The above line errors when the solution is NOT constrained
225 ## by non-negativity! That case happens when the lsqnonneg solution
226 ## is the same as the fminunc solution. Ideally the user would not
227 ## be using lsqnonneg if nonnegativity constraints are not active, but we
228 ## should handle that more gracefully.
222 endif 229 endif
223 230
224 endfunction 231 endfunction
225 232
226 233