Qupat - a quadruple precision floating point package for Scilab
QuPat is a quadruple precision floating point package for Scilab. This Scilab add on was developed in Japan, and the English support is minimal to nonexistent, but through experimentation it is possible to decipher how to use this package in Scilab.INDEX
Qupat can be downloaded here -The Qupat homepage.
The High Speed version of Qupat can be directly downloaded from this link - High Speed QuPat (aka MuPat).
Most of the instructions for QuPat also seem to work fine with MuPat, the only difference being that MuPat is 'high speed' and MuPat also has double the precision of QuPat.
There is a screwy cgi script on the download page and it produces a link to a cgi script which is then fed a link to the zip file, but when it is clicked instead of downloading the zip file, it fills your screen with meaningless mumbo jumbo (it attempts to display the contents of the zip file on your monitor). To fix this problem I simply clipped the address of the zip file from the end of the cgi request in the url and then entered the address directly in the address bar.
The latest 'high speed' version of Qupat is now known as 'MuPat', which is the first download on the page, and the older version known as 'Qupat' is the next download further down on the page. There used to a be a buggy problem with MuPat but this seems to have been fixed and there now seems to be little reason to prefer QuPat over MuPat given the even higher precision of the MuPat package and its speed.
When you first download QuPat, you must navigate to the 'macros' folder and find the file 'buildmacros.sce'. You use the file menu option to 'open' this file in the Scilab editor, and then from the drop down 'Execute' file menu select 'load into Scilab'. This will start the Scilab executable file, and build the required QuPat or MuPat macros. You only need to do this once. Check the Console to ensure that no error messages were reported while the code was running.
Whenever you wish to run QuPat you must the open the file 'loadmacros.sce' in the editor and then using the drop down Execution menu, once again choose 'Load into Scilab'. The Console should report that the macros were successfully loaded into Scilab, and QuPat is now ready to be used by the Scilab Math programs. The macros must be reloaded into Scilab every time you restart the program.
We will declare a QuPat variable with the value of the speed of light, 'c'.
c = dd(299792458, 0);
A QuPat quadruple precision floating point number consists of two normal double precision floating point numbers. For the first field we enter the value of 'c' and in the second field we enter the value '0'.
Next we will deliberately overflow the double precision floating point capabilities by creating a new variable 'c cubed'.
c3 = c * c * c
Note that the instruction c3 = c^3 does not work on QuPat.
If we omit the ending semicolon ';' from the end of the line of code, the Console will automatically echo the results of the calculation. A Qupat variable consists of three fields (in this case c3(1), c3(2), and c3(3) ). The value of c3(1) is constant and consists of an enigmatic string that I always ignore. c3(2) is the double precision floating point number, and c3(3) is the 'overflow' when a number goes beyond what can be represented in double precision. If we wish to convert a quadruple precision QuPat number back into a double precision number we must extract only the second field (ie A = c3(2) ).
From this point on, QuPat quadruple precision numbers are used in all mathematical equations, just like an ordinary double precision Scilab variable. However if a QuPat variable is included in any equation, the result will always be another QuPat variable. For example if we have the equation Y = (A * B) + C, and if A and C are normal double precision variables, but B is a QuPat quadruple precision variable, then the result, Y, will be a QuPat quadruple precision variable.
There also appear to be some QuPat specific variations upon standard Scilab functions. The only one I am familiar with at this time is 'ddsqrt'. If we wish to find the square root of a normal double precision Scilab variable we use the function sqrt (ie Y = sqrt(X) ). If we wish to find the sqrt of a QuPat variable we use Y = ddsqrt(X). The name of the Scilab function has been preceded by 'dd' to indicate that this is now a specialized quadruple precision function call. There may be other functions that also have modified versions in QuPat (where I would assume that the function name is the same as the function name in Scilab, the only difference being that the function name is preceded by 'dd').
Qupat is a quadruple precision math package. There is another add on available for Scilab which allows an arbitrary precision (up to 200 digits). This package is known as Xnum, and is described on the following page - Xnum package for Scilab.
The Living Resurrection: A Manifesto