NO

Recent Posts

Pages: [1] 2 3 ... 10
1
User contributions / Re: Big integer arithmetic library
« Last post by jack on Today at 04:53:55 PM »
hello cosh
if you implement a multiply BigInt by 32-bit integer then your factorial would be about 3 times faster
2
User contributions / Re: Big integer arithmetic library
« Last post by jack on Today at 02:44:35 PM »
hello cosh  :)
I ran your test, if compiled with -O2 the time was about .0043, if compiled with -O3 .0058, it's not uncommon that -O3 is a bit slower than -O2
but I don't like the license at all, LGPL for a library is ok but not GPL, although I much prefer the MIT type of license
3
User contributions / Re: Big integer arithmetic library
« Last post by TimoVJL on Today at 09:09:44 AM »
pbint.def
Code: [Select]
LIBRARY pbint.dll
EXPORTS
pbkInitBint
pbkReallocBint
pbkFreeBint
pbkCreateBint
pbkDeleteBint
pbkMoveBint
pbkCopyBint
pbkIbToBint
pbkBintToIb
pbkCompareBint
pbkAddBint
pbkSubtractBint
pbkLeftShiftBint
pbkRightShiftBint
pbkMultiplyBint
pbkDivideBint
pbkInitBnum
pbkReallocBnum
pbkFreeBnum
pbkCreateBnum
pbkDeleteBnum
pbkMoveBnum
pbkIbToBnum
pbkDecimalSzToBnum
pbkPrintBnum
pbkBintToDecimalBnum
pbkDecimalBnumToBint
pbmBintPower
pbmUbFactorial
pbmBintSquareRoot
pbmBintGreatestCommonDivisor
pbxLoadBint
pbxSaveBint
4
User contributions / Re: Big integer arithmetic library
« Last post by WiiLF23 on Today at 03:33:01 AM »
Nice work! Very appreciated.

Cheers!
5
User contributions / Re: Big integer arithmetic library
« Last post by frankie on May 20, 2024, 10:58:59 PM »
 :)
6
User contributions / Big integer arithmetic library
« Last post by cosh on May 20, 2024, 07:14:08 PM »
 :) Hi, there
I wrote a library for big integer arithmetic here: https://github.com/coshcage/pbint
It's called pbint means portable big integer library.
The difference between pbint and gnu gmp is that you don't need to control memory manually in pbint, pbint combined heap memory management functions to arithmetic functions together. pbint is smaller and faster. If you are interested in high precision calculation and large integer arithmetic, pbint is suitable for you.

I also tested and compiled pbint with Pelles C compiler. Before compiling pbint with Pelles C you need to alter pbint according to the following instructions:
Delete line 568 register qualifier in pbk.c.
Delete line 621 register qualifier in pbk.c. But don't delete variable declaration clause.

Testing shows to calculate factorial 2000 on an Intel Core i9 9 Gen microprocessor only needs 0.01 seconds.
Here's the code that I used for testing:
Code: [Select]
#include <stdio.h>
#include <Windows.h>
#include "pbk.h"
#include "pbm.h"

int main()
{
P_BINT pc;
P_BNUM p;
LARGE_INTEGER la, lb, lc;


pc = pbkCreateBint(0);
p = pbkCreateBnum(10);

QueryPerformanceFrequency(&lc);
QueryPerformanceCounter(&la);

pbmUbFactorial(pc, 2000); // 2000!

QueryPerformanceCounter(&lb);
printf("%lf\n", (double)(lb.QuadPart - la.QuadPart) / (double)lc.QuadPart);

pbkBintToDecimalBnum(p, pc);

pbkPrintBnum(p);

return 0;
}

Kind regards,
Cosh.
7
Tips & tricks / KAST macro by MrBcx
« Last post by Vortex on May 18, 2024, 09:28:17 PM »
A nice macro by MrBcx used in the BCX language.

Traditional type casting :

Code: [Select]
#include <windows.h>
#include <stdio.h>

int main(void)
{
HMODULE hMod;
PIMAGE_NT_HEADERS pNThdr;
PIMAGE_EXPORT_DIRECTORY pDesc;
DWORD NumbOfNames,i;
DWORD* AddrOfNames;

hMod=LoadLibrary("kernel32.dll");

pNThdr=(PIMAGE_NT_HEADERS)((LPBYTE)hMod + ((PIMAGE_DOS_HEADER)hMod)->e_lfanew);

pDesc=(PIMAGE_EXPORT_DIRECTORY)((LPBYTE)hMod + pNThdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);

NumbOfNames =  pDesc -> NumberOfNames;

AddrOfNames = (DWORD *)((LPBYTE)hMod + pDesc -> AddressOfNames);

for(i=0;i<NumbOfNames;i++)
{
printf("%s\n",(*AddrOfNames+(LPBYTE)hMod));

AddrOfNames=AddrOfNames+1;
}

FreeLibrary(hMod);
return 0;
}

The KAST macro for type casting :

Code: [Select]
#include <windows.h>
#include <stdio.h>

/* KAST macro by MrBcx */

#define KAST(to_type,old_obj) ((to_type)(old_obj))

int main(void)
{
HMODULE hMod;
PIMAGE_NT_HEADERS pNThdr;
PIMAGE_EXPORT_DIRECTORY pDesc;
DWORD NumbOfNames,i;
DWORD* AddrOfNames;

hMod=LoadLibrary("kernel32.dll");

pNThdr=KAST(PIMAGE_NT_HEADERS,KAST(LPBYTE,hMod) + KAST(PIMAGE_DOS_HEADER,hMod)->e_lfanew);

pDesc=KAST(PIMAGE_EXPORT_DIRECTORY,KAST(LPBYTE,hMod) + pNThdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);

NumbOfNames =  pDesc -> NumberOfNames;

AddrOfNames = KAST(DWORD *,KAST(LPBYTE,hMod) + pDesc -> AddressOfNames);

for(i=0;i<NumbOfNames;i++)
{
printf("%s\n",*AddrOfNames+KAST(LPBYTE,hMod));

AddrOfNames=AddrOfNames+1;
}

FreeLibrary(hMod);
return 0;
}
8
Expert questions / Re: TikToken
« Last post by HellOfMice on May 18, 2024, 01:21:19 PM »
I have used the web interface and created a database with more than 174 000 english words and their tokens.
Thank you everybody for your help

9
Expert questions / Re: TikToken
« Last post by John Z on May 18, 2024, 10:45:25 AM »
For OpenAI a token is a group of three or four characters. The solution I have made is to divide the length of each word by three and add 1 word length is greather than three.


OpenAI tokenizer https://platform.openai.com/tokenizer

One of the methods to get better performance (at least using English language) is to look for both common prefixes and common suffixes and break the word there initially.  This creates more efficient tokens as I understand that.

To that end the following link might be useful for the most common of each - 

https://www.scholastic.com/content/dam/teachers/lesson-plans/migrated-files-in-body/prefixes_suffixes.pdf

John Z
10
Work in progress / Re: zlib 1.2.8 source converted for __stdcall
« Last post by John Z on May 17, 2024, 09:53:49 PM »
zlib 1.2.8 source converted for __stdcall.

Thanks Timo!

John Z
Pages: [1] 2 3 ... 10