JCL Help:SetPrimalityTest
JCL Help: SetPrimalityTest Function
Search in JCL Help
Search in all projects
Summary
Set the primality test to use within the JCL.
Pascal
procedure SetPrimalityTest(const Method: TPrimalityTestMethod);
Description
This procedures sets the primality test to use within the JCL. Currently two different algorithms are available: Rabin-Miller strong primality test and the more traditional and straight forward Trial Division method.
If you need to implement a new primality test please follow these rules:
First you need to add a function similar to IsPrimeRM. Per definition, each new primality test function name starts with IsPrime followed by the kind of primality test. A future function concerning the Lehmann primality test would be called, for example, IsPrimeLehmann.function IsPrimeLehmann(X: Cardinal): Boolean;
begin
[...]
end;
The next step is to add your new test to the TPrimalityTestMethod set.type
TPrimalityTestMethod = (ptTrialDivision, ptRabinMiller, ptLehmann);
Furthermore you'll need to add a new case to SetPrimality test.case Method of
ptTrialDivision: IsPrime := IsPrimeTD;
ptRabinMiller: IsPrime := IsPrimeRM;
ptLehmann: IsPrime := IsPrimeLehmann;
end;
Now you are done. Anyway, please consider to donate your function to the main JCL branch.
About
Unit
Donator
Matthias Thoma
Contribute to this help topic
This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page