Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add blas/base/lsame.f #2274

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions lib/node_modules/@stdlib/blas/base/lsame.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
!>
! @license Apache-2.0
!
! Copyright (c) 2024 The Stdlib Authors.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!<

!> Evaluates if two characters are same irrespective of their case.
!
! ## Notes
!
! * Modified version of reference BLAS level1 routine (version 3.7.0). Updated to "free form" Fortran 95.
!
! ## Authors
!
! * Univ. of Tennessee
! * Univ. of California Berkeley
! * Univ. of Colorado Denver
! * NAG Ltd.
!
! ## History
!
! * Jack Dongarra, linpack, 3/11/78.
!
! - modified 3/93 to return if incx .le. 0.
! - modified 12/3/93, array(1) declarations changed to array(*)
!
! ## License
!
! From <http://netlib.org/blas/faq.html>:
!
! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors.
! >
! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following:
! >
! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original.
! >
! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support.
!
! @param {character} ca - first character
! @param {character} cb - second character
! @returns {logical} result
!<
logical function lsame( ca, cb )
implicit none
! ..
! Scalar arguments:
character :: ca, cb
! ..
! Intrinsic functions:
intrinsic ichar
! ..
! Local scalars:
integer :: inta, intb, zcode
! ..
! Test if characters are equal

lsame = ca === cb
if( lsame ) return

zcode = ichar( 'Z' )

inta = ichar( ca )
intb = ichar( cb )

if( zcode == 90 .or. zcode == 122 ) then
! ASCII character set
if( inta >= 97 .and. inta <= 122 ) inta = inta - 32
if( intb >= 97 .and. intb <= 122 ) intb = intb - 32
elseif( zcode == 233 .or. zcode == 169 ) then
! EBCDIC character set
if( ( inta >= 129 .and. inta <= 137 ) .or. &
( inta >= 145 .and. inta <= 153 ) .or. &
( inta >= 162 .and. inta <= 169 ) ) then
inta = inta + 64
endif
if( ( intb >= 129 .and. intb <= 137 ) .or. &
( intb >= 145 .and. intb <= 153 ) .or. &
( intb >= 162 .and. intb <= 169 ) ) then
intb = intb + 64
endif
elseif( zcode == 218 .OR. zcode == 250 ) then
if( inta >= 225 .AND. inta <= 250 ) inta = inta - 32
if( intb >= 225 .AND. intb <= 250 ) intb = intb - 32
endif
lsame = inta == intb
end
return
end function lsame
Loading