Page 2 of 2

Re: Issue with converting tiny classifier routine into a macro

Posted: Sun Aug 17, 2025 11:02 am
by infratec
Suboptimal:

Code: Select all

Structure AsciiArray
	a.a[0]
EndStructure


Define IsLetter.i
Define *IsLetter.AsciiArray = ?IsLetter
Define *IsLetterCharacter.Character

Macro IsLetterMacro(String)
  IsLetter = 0
  *IsLetterCharacter = @String
  If *IsLetterCharacter\c < 128
    IsLetter = *IsLetter\a[*IsLetterCharacter\c]
  EndIf
EndMacro


DataSection
	IsLetter:
	Data.a 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	Data.a 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	Data.a 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	Data.a 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
	Data.a 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
	Data.a 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1
	Data.a 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
	Data.a 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
EndDataSection

IsLetterMacro("a")
Debug IsLetter
IsLetterMacro("_")
Debug IsLetter
IsLetterMacro("ß")
Debug IsLetter
IsLetterMacro("1")
Debug IsLetter

Re: Issue with converting tiny classifier routine into a macro

Posted: Mon Aug 18, 2025 5:39 am
by Olli
Olli wrote: Tue Jul 29, 2025 7:14 am This is "SIMDable" :

Code: Select all

Dim NonLetter(65535)
For i = 0 to 65535
 NonLetter(i) = (((i & ~32) - 52) / 13 - 1) >> 1
Next
Hello skiper, I am sorry for having done short. Maybe an other short version ?

Code: Select all

macro isNotLetter(self)
(((self&~32)-52)/13-1)>>1
endmacro
It is method to be fast. And normally, the optimizer should use it, as SIMD if you use it in a contiguous array.

@infratec
IsLetterMacro("ß")
That is a problem this letter : 's' und 'z', as 'o' und 'e' für << (french) des œufs >> (œ) ("eggs"). I used it long time ago to learn my deutsch ! chr$(223)

Re: Issue with converting tiny classifier routine into a macro

Posted: Mon Aug 18, 2025 6:08 am
by idle
Olli wrote: Tue Jul 29, 2025 7:14 am

Code: Select all

macro isNotLetter(self)
(((self&~32)-52)/13-1)>>1
endmacro
It is method to be fast. And normally, the optimizer should use it, as SIMD if you use it in a contiguous array.
That's really nice for azAZ