Code covered by the BSD License  

Highlights from
trilin

trilin

by

 

Facilitates the reuse of matrix factorizations in large dense linear algebra problems.

strendi (str1, str2)
function answer = strendi (str1, str2)
    if ~iscell(str1) && ~iscell(str2)
        if length(str1) > length(str2)
            answer = false;
            return;
        end
        answer = strcmpi(str1, str2(end-length(str1)+1:end));
    elseif iscell(str1) && iscell(str2)
        error('strend:cellInput', 'Cell arrays not supported.');
    elseif xor(iscell(str1), iscell(str2))
        if iscell(str1)
            strc = str1;
            str  = str2;
        else
            strc = str2;
            str  = str1;
        end
        answer = false(size(strc));
        for i=1:length(strc)
            %answer, strendi(str, strc{i})  % DEBUG
            answer(i) = answer(i) || strendi(str, strc{i});
        end
    end
end

%!test
%! myassert(strendi('Private', 'haha/private'));
%! myassert(~strendi('Private', 'haha/private2'));
%! myassert(~strendi('packed:rcond:complexNotSupported', ...
%!     'packed:chol:complexNotSupported'));
%! myassert(strendi('Private', 'haha/private'));
%! myassert(strendi('a', {'a', 'b'}), [true, false]);
%! myassert(strendi({'a', 'b'}, 'b'), [false, true]);

Contact us