Skip to content

Commit

Permalink
added libtomfloat-0.01
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom St Denis authored and sjaeckel committed Oct 19, 2010
0 parents commit 6c3b48a
Show file tree
Hide file tree
Showing 64 changed files with 2,659 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LibTomFloat is Public Domain.

-- Tom St Denis
38 changes: 38 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Still quite a bit todo for LibTomFloat.

1. The following functions [as of v0.01] have not been implemented (the .C files are present but not populated)

- mpf_acos
- mpf_asin
- mpf_atan
- mpf_const_1pi [*]
- mpf_const_2pi [*]
- mpf_const_2rpi [*]
- mpf_const_l10e [*]
- mpf_const_l2e [*]
- mpf_const_le2 [*]
- mpf_const_pi [*]
- mpf_const_pi2 [*]
- mpf_const_pi4 [*]
- mpf_ln
- mpf_pow [*]
- Any form of string input/output

[*] Denotes functions which are written but depend upon incomplete functions to work.

The critical path lies in two functions. The first is mpf_ln from which I can write mpf_pow and the various constants will function.
The second is mpf_atan from which I can write mpf_const_pi and finish off the missing constants.

From there it's a matter of adding mpf_asin, mpf_acos and mpf_tan and I have a decent subset of math in there.

2. Once all of the functions have been written I want to add early-out optimizations to the various series calculations. Right now
they use an arbitrary high count and get accurate results. However, quite a few functions stabalize quickly and do not need so many
iterations. In particular I plan to start on mpf_invsqrt() as it forms the basis of mpf_inv() which is used in mpf_cos() [and other trigs].

At the same time I want to add more domain checking (e.g. valid inputs).

3. Add decent string input/output

4. More things to the manual. I plan on doing this with every release cycle though.

5. MSVC makefile
11 changes: 11 additions & 0 deletions WARNING
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LibTomFloat is a *VERY* new package and is not even fully written yet. Quite a
bit of the functionality is present but will be changing in the near future to allow
for optimizations (e.g. early-outs).

Please don't use LibTomFloat just yet for any production or fielded system.

By all means if you wish to test and help find bugs in LibTomFloat give the package a try.

I do not guarantee the numerical accuracy of this package as of yet.

You've been warned.
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
May 5th, 2004 v0.01 -- wrote base of LTF

Anytime v0.00 -- no LTF existed.
54 changes: 54 additions & 0 deletions demos/ex1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <tomfloat.h>

void draw(mp_float *a)
{
char buf[8192];
mp_toradix(&(a->mantissa), buf, 10);
printf("%s * 2^%ld\n", buf, a->exp);
}

int main(void)
{
mp_float a, b, c, d, e;
mpf_init_multi(96, &a, &b, &c, &d, &e, NULL);

mpf_const_d(&a, 1); draw(&a);
mpf_const_d(&b, 2); draw(&b);
mpf_const_d(&c, 3); draw(&c);
mpf_const_d(&d, 4); draw(&d);

mpf_add(&b, &c, &e); printf("2 + 3 == "); draw(&e);
mpf_sub(&b, &c, &e); printf("2 - 3 =="); draw(&e);
mpf_mul(&b, &c, &e); printf("2 * 3 == "); draw(&e);
mpf_div(&b, &c, &e); printf("2 / 3 == "); draw(&e);
printf("\n");
mpf_invsqrt(&d, &e); printf("1/sqrt(4) == 1/2 == "); draw(&e);
mpf_invsqrt(&c, &e); printf("1/sqrt(3) == "); draw(&e);
mpf_inv(&a, &e); printf("1/1 == "); draw(&e);
mpf_inv(&b, &e); printf("1/2 == "); draw(&e);
mpf_inv(&c, &e); printf("1/3 == "); draw(&e);
mpf_inv(&d, &e); printf("1/4 == "); draw(&e);
printf("\n");
mpf_const_e(&e); printf("e == "); draw(&e);
mpf_exp(&c, &e); printf("e^3 == "); draw(&e);
mpf_sqrt(&e, &e); printf("sqrt(e^3) == "); draw(&e);
mpf_sqr(&e, &e); printf("sqrt(e^3)^2 == "); draw(&e);
printf("\n");
mpf_cos(&a, &e); printf("cos(1) == "); draw(&e);
mpf_cos(&b, &e); printf("cos(2) == "); draw(&e);
mpf_cos(&c, &e); printf("cos(3) == "); draw(&e);
mpf_cos(&d, &e); printf("cos(4) == "); draw(&e);
mpf_sin(&a, &e); printf("sin(1) == "); draw(&e);
mpf_sin(&b, &e); printf("sin(2) == "); draw(&e);
mpf_sin(&c, &e); printf("sin(3) == "); draw(&e);
mpf_sin(&d, &e); printf("sin(4) == "); draw(&e);
mpf_tan(&a, &e); printf("tan(1) == "); draw(&e);
mpf_tan(&b, &e); printf("tan(2) == "); draw(&e);
mpf_tan(&c, &e); printf("tan(3) == "); draw(&e);
mpf_tan(&d, &e); printf("tan(4) == "); draw(&e);
printf("\n");
return 0;
}



6 changes: 6 additions & 0 deletions float.ilg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).
Scanning input file float.idx....done (48 entries accepted, 0 rejected).
Sorting entries....done (285 comparisons).
Generating output file float.ind....done (55 lines written, 0 warnings).
Output written in float.ind.
Transcript written in float.ilg.
55 changes: 55 additions & 0 deletions float.ind
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
\begin{theindex}

\item exponent, \hyperpage{2}

\indexspace

\item mantissa, \hyperpage{2}
\item mp\_cmp, \hyperpage{16}
\item mp\_error\_to\_string, \hyperpage{6}
\item MP\_MEM, \hyperpage{5}
\item MP\_NO, \hyperpage{5}
\item MP\_OKAY, \hyperpage{5}
\item MP\_VAL, \hyperpage{5}
\item MP\_YES, \hyperpage{5}
\item mpf\_abs, \hyperpage{13}
\item mpf\_acos, \hyperpage{18}
\item mpf\_add, \hyperpage{15}
\item mpf\_add\_d, \hyperpage{15}
\item mpf\_asin, \hyperpage{18}
\item mpf\_atan, \hyperpage{18}
\item mpf\_clear, \hyperpage{7}
\item mpf\_clear\_multi, \hyperpage{8}
\item mpf\_cmp\_d, \hyperpage{16}
\item mpf\_const\_0, \hyperpage{11}
\item mpf\_const\_d, \hyperpage{11}
\item mpf\_const\_ln\_d, \hyperpage{11}
\item mpf\_const\_sqrt\_d, \hyperpage{11}
\item mpf\_copy, \hyperpage{9}
\item mpf\_cos, \hyperpage{18}
\item mpf\_div, \hyperpage{15}
\item mpf\_div\_2, \hyperpage{16}
\item mpf\_div\_d, \hyperpage{15}
\item mpf\_exch, \hyperpage{10}
\item mpf\_exp, \hyperpage{17}
\item mpf\_init, \hyperpage{7}
\item mpf\_init\_copy, \hyperpage{8}
\item mpf\_init\_multi, \hyperpage{8}
\item mpf\_inv, \hyperpage{18}
\item mpf\_invsqrt, \hyperpage{18}
\item mpf\_ln, \hyperpage{17}
\item mpf\_mul, \hyperpage{15}
\item mpf\_mul\_2, \hyperpage{16}
\item mpf\_mul\_d, \hyperpage{15}
\item mpf\_neg, \hyperpage{13}
\item mpf\_normalize, \hyperpage{11}
\item mpf\_normalize\_to, \hyperpage{11}
\item mpf\_pow, \hyperpage{17}
\item mpf\_sin, \hyperpage{18}
\item mpf\_sqr, \hyperpage{16}
\item mpf\_sqrt, \hyperpage{18}
\item mpf\_sub, \hyperpage{15}
\item mpf\_sub\_d, \hyperpage{15}
\item mpf\_tan, \hyperpage{18}

\end{theindex}
Binary file added float.pdf
Binary file not shown.
Loading

0 comments on commit 6c3b48a

Please sign in to comment.