function [lsameresult,ca,cb]=lsame(ca,cb);
lsameresult=[];
persistent first firstCall ioff ; if isempty(firstCall),firstCall=1;end;
;
%***BEGIN PROLOGUE LSAME
%***SUBSIDIARY
%***PURPOSE Test two characters to determine if they are the same
% letter, except for case.
%***LIBRARY SLATEC
%***CATEGORY R, N3
%***TYPE LOGICAL (LSAME-L)
%***KEYWORDS CHARACTER COMPARISON, LEVEL 2 BLAS, LEVEL 3 BLAS
%***AUTHOR Hanson, R., (SNLA)
% Du Croz, J., (NAG)
%***DESCRIPTION
%
% LSAME tests if CA is the same letter as CB regardless of case.
% CB is assumed to be an upper case letter. LSAME returns true if
% CA is either the same as CB or the equivalent lower case letter.
%
% N.B. This version of the code is correct for both ASCII and EBCDIC
% systems. Installers must modify the routine for other
% character-codes.
%
% For CDC systems using 6-12 bit representations, the system-
% specific code in comments must be activated.
%
% Parameters
% ==========
%
% CA - CHARACTER*1
% CB - CHARACTER*1
% On entry, CA and CB specify characters to be compared.
% Unchanged on exit.
%
%***REFERENCES (NONE)
%***ROUTINES CALLED (NONE)
%***REVISION HISTORY (YYMMDD)
% 860720 DATE WRITTEN
% 910606 Modified to meet SLATEC prologue standards. Only comment
% lines were modified. (BKS)
% 910607 Modified to handle ASCII and EBCDIC codes. (WRB)
% 930201 Tests for equality and equivalence combined. (RWC and WRB)
%***end PROLOGUE LSAME
% .. Scalar Arguments ..
% .. Local Scalars ..
if isempty(ioff), ioff=0; end;
if isempty(first), first=false; end;
% .. Intrinsic Functions ..
% .. Save statement ..
% .. Data statements ..
if firstCall, first=[true]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT LSAME
if( first )
ioff = fix(double('a') - double('A'));
end;
%
first = false;
%
% Test if the characters are equal or equivalent.
%
lsameresult =(strcmp(deblank(ca),deblank(cb))) |(double(ca)-ioff==double(cb));
%
%
% The following comments contain code for CDC systems using 6-12 bit
% representations.
%
% .. Parameters ..
% INTEGER ICIRFX
% PARAMETER ( ICIRFX=62 )
% .. Scalar Arguments ..
% CHARACTER*1 CB
% .. Array Arguments ..
% CHARACTER*1 CA(*)
% .. Local Scalars ..
% INTEGER IVAL
% .. Intrinsic Functions ..
% INTRINSIC ICHAR, CHAR
% .. Executable Statements ..
% INTRINSIC ICHAR, CHAR
%
% See if the first character in string CA equals string CB.
%
% LSAME = CA(1) .EQ. CB .AND. CA(1) .NE. CHAR(ICIRFX)
%
% IF (LSAME) RETURN
%
% The characters are not identical. Now check them for equivalence.
% Look for the 'escape' character, circumflex, followed by the
% letter.
%
% IVAL = ICHAR(CA(2))
% IF (IVAL.GE.ICHAR('A') .AND. IVAL.LE.ICHAR('Z')) THEN
% LSAME = CA(1) .EQ. CHAR(ICIRFX) .AND. CA(2) .EQ. CB
% ENDIF
%
% RETURN
%
% end of LSAME.
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',cb); evalin('caller',[inputname(2),'=FUntemp;']); end
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',ca); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK LSEI