Mercurial > octave
changeset 22217:3ac380d46d54
chol: make option passed as string case insensitive.
* libinterp/dldfcn/chol.cc: make comparison of strings for options case
insensitive. Add tests. Add missing include for <string> which is used
elsewhere in the file.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sun, 07 Aug 2016 19:39:40 +0100 |
parents | f99c0b8cb67b |
children | 6bb0f32d22a5 |
files | libinterp/dldfcn/chol.cc |
diffstat | 1 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/chol.cc Sun Aug 07 04:21:14 2016 +0100 +++ b/libinterp/dldfcn/chol.cc Sun Aug 07 19:39:40 2016 +0100 @@ -26,11 +26,14 @@ # include "config.h" #endif +#include <string> + #include "chol.h" #include "sparse-chol.h" #include "oct-spparms.h" #include "sparse-util.h" +#include "caseless-str.h" #include "ov-re-sparse.h" #include "ov-cx-sparse.h" #include "defun-dld.h" @@ -160,13 +163,13 @@ int n = 1; while (n < nargin) { - std::string tmp = args(n++).xstring_value ("chol: optional arguments must be strings"); + caseless_str tmp = args(n++).xstring_value ("chol: optional arguments must be strings"); - if (tmp == "vector") + if (tmp.compare ("vector")) vecout = true; - else if (tmp == "lower") + else if (tmp.compare ("lower")) LLt = true; - else if (tmp == "upper") + else if (tmp.compare ("upper")) LLt = false; else error ("chol: optional argument must be one of \"vector\", \"lower\", or \"upper\""); @@ -313,6 +316,16 @@ /* %!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps)) %!assert (chol (single ([2, 1; 1, 1])), single ([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single"))) + +%!assert (chol ([2, 1; 1, 1], "upper"), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], +%! sqrt (eps)) +%!assert (chol ([2, 1; 1, 1], "lower"), [sqrt(2), 0; 1/sqrt(2), 1/sqrt(2)], +%! sqrt (eps)) + +%!assert (chol ([2, 1; 1, 1], "lower"), chol ([2, 1; 1, 1], "LoweR")) +%!assert (chol ([2, 1; 1, 1], "upper"), chol ([2, 1; 1, 1], "Upper")) +%!assert (chol ([2, 1; 1, 1], "vector"), chol ([2, 1; 1, 1], "VECTOR")) + %!testif HAVE_CHOLMOD %! ## Bug #42587 %! A = sparse ([1 0 8;0 1 8;8 8 1]);