arageli
play

Arageli: Library for Doing Exact Computation Segrey S. Lyalin - PowerPoint PPT Presentation

Arageli: Library for Doing Exact Computation Segrey S. Lyalin Nikolai Yu. Zolotykh University of Nizhni Novgorod, Russia ICMS, 2006 Contents 1 Project 3 2 Classes 4 3 Algorithms 6 4 Examples 8 5 Aragelis (distinctive)


  1. Arageli: Library for Doing Exact Computation Segrey S. Lyalin Nikolai Yu. Zolotykh University of Nizhni Novgorod, Russia ICMS, 2006

  2. Contents 1 Project 3 2 Classes 4 3 Algorithms 6 4 Examples 8 5 Arageli’s (distinctive) characteristics 29 6 Comparison with other libraries 30 7 Arageli in action 31

  3. 1 Project Arageli is a C++ library for exact computations in ARithmetic, Algebra, GEometry, Linear and Integer linear programming Sphere of possible applications: exact linear algebra, number theory, linear and integer linear programming, criptography, symbolic computations 100+ files of source code, 50000+ lines

  4. 1 Project Arageli is a C++ library for exact computations in ARithmetic, Algebra, GEometry, Linear and Integer linear programming Sphere of possible applications: exact linear algebra, number theory, linear and integer linear programming, criptography, symbolic computations 100+ files of source code, 50000+ lines Arageli group  Eugene Agafonov   Max Alekseyev (Uni of San Diego at pres.)     Aleksey Bader    Sergey S. Lyalin University of Nizhni Novgorod Aleksey Polovinkin     Andrey Somsikov     Nikolai Yu. Zolotykh 

  5. 2 Classes

  6. 2 Classes • big int Arbitrary precision integers

  7. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials)

  8. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials) • vector < T > Vectors with entries that belong to T

  9. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials) • vector < T > Vectors with entries that belong to T • matrix < T > Matrices with entries that belong to T

  10. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials) • vector < T > Vectors with entries that belong to T • matrix < T > Matrices with entries that belong to T • sparse polynom < T > Sparse polynomials with coefficients that belong to T

  11. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials) • vector < T > Vectors with entries that belong to T • matrix < T > Matrices with entries that belong to T • sparse polynom < T > Sparse polynomials with coefficients that belong to T • residue < T > Elements in T modulo certain m ∈ T

  12. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials) • vector < T > Vectors with entries that belong to T • matrix < T > Matrices with entries that belong to T • sparse polynom < T > Sparse polynomials with coefficients that belong to T • residue < T > Elements in T modulo certain m ∈ T • algebraic < T > Algebraic numbers, i.e. roots of polynomials with coefficients in T = { rational numbers }

  13. 2 Classes • big int Arbitrary precision integers • rational < T > Rational numbers/functions, i.e. fractions u v , where u, v ∈ T (integers/polynomials) • vector < T > Vectors with entries that belong to T • matrix < T > Matrices with entries that belong to T • sparse polynom < T > Sparse polynomials with coefficients that belong to T • residue < T > Elements in T modulo certain m ∈ T • algebraic < T > Algebraic numbers, i.e. roots of polynomials with coefficients in T = { rational numbers }

  14. • a few experimental classes (dense polynomials, polynomials of many variables, algebraic numbers, multiprecision float point numbers, . . . )

  15. • a few experimental classes (dense polynomials, polynomials of many variables, algebraic numbers, multiprecision float point numbers, . . . ) All classes above (except big int ) have more than 1 parameter. Supplementary parameters control reducing fractions algorithms, references count methods, etc.

  16. 3 Algorithms • GCD (extended) Euclidian and binary algorithms • Gaussian elimination and Gauss-Bareiss’ elimination algorithms for matrices over field and integer domains • Classical/Storjohann’s algorithms for constructing Smith’s normal diagonal form over ring of integers and ring of polynomials • Classical/Domich/Storjohann’s algorithms for finding Hermith’s normal form • Solovay–Strassen, Miller–Rabin and Agrawal–Kayal–Saxena tests for primality • Integer number factorization by Pollard’s ρ -method and Pollard’s p − 1 method • Simplex method and Gomory’s algorithms for linear and integer linear programming problems • Sturm’s algorithm for locating polynomial roots • Double description method for polyhedra • Triangulation of polyhedra • . . .

  17. • All algorithms are templated functions int a , b ; big int c , d ; polynomial < rational <> > f , g ; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gcd ( a , b ); gcd ( c , d ); gcd ( a , c ); gcd ( f , g );

  18. • All algorithms are templated functions int a , b ; big int c , d ; polynomial < rational <> > f , g ; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gcd ( a , b ); gcd ( c , d ); gcd ( a , c ); gcd ( f , g ); • One of parameters is controller : it is a class that controls the algorithm while it is working, puts out intermediate results of the computation, measures time etc.

  19. 4 Examples

  20. 4 Examples Example: big integers #include < arageli / arageli . hpp > using namespace std ; using namespace Arageli ; int main ( int argc , char * argv [ ]) { big int a = “101100111000111100001111100000”; big int b = “-1234567890987654321”; cout << “a = ” << a << endl << “b = ” << b << endl ; cout << “2*(a + b) - a%b = ” << 2*( a + b ) − a % b << endl ; return 0; } a = 101100111000111100001111100000 b = -1234567890987654321 2*(a + b) - a%b = 202200221996782640900764076427

  21. Example: rational numbers #include < arageli / arageli . hpp > using namespace std ; using namespace Arageli ; int main ( int argc , char * argv [ ]) { rational <> a = “22/7”; rational <> b (355, 113); cout << “a = ” << a << endl ; cout << “b = ” << b << endl ; cout << “Numerator of a = ” << a . numerator () << endl ; cout << “Denominator of a = ” << a . denominator () << endl ; double af = a ; // You can assign rational numbers to float or to double double bf = b ; cout << “af = ” << setprecision (5) << af << endl ; cout << “bf = ” << setprecision (10) << bf << endl ; return 0; }

  22. a = 22/7 b = 355/113 Numerator of a = 22 Denominator of a = 7 af = 3.1429 bf = 3.14159292

  23. Example: polynomials #include “arageli/arageli.hpp” using namespace std ; using namespace Arageli ; int main ( int argc , char * argv [ ]) { sparse polynom < rational <> > f = “x ^ 6+x ^ 4-x ^ 2-1”, g = “x ^ 3-2*x ^ 2-x+2”; cout << “f = ” << f << endl ; cout << “g = ” << g << endl << endl ; cout << “f + g = ” << f + g << endl ; cout << “f - g = ” << f − g << endl ; cout << “f * g = ” << f * g << endl ; cout << “f / g = ” << f / g << endl ; cout << “f % g = ” << f % g << endl ; cout << “GCD(f, g) = ” << gcd ( f , g ) << endl ; cout << “LCM(f, g) = ” << lcm ( f , g ) << endl ; return 0; }

  24. f = x^6+x^4-x^2-1 g = x^3-2*x^2-x+2 f + g = x^6+x^4+x^3-3*x^2-x+1 f - g = x^6+x^4-x^3+x^2+x-3 f * g = x^9-2*x^8-2*x^5+4*x^4+x-2 f / g = x^3+2*x^2+6*x+12 f % g = 25*x^2-25 GCD(f, g) = x^2-1 LCM(f, g) = x^7-2*x^6+x^5-2*x^4-x^3+2*x^2-x+2

  25. Example: vectors and matrices #include < arageli / arageli . hpp > using namespace std ; using namespace Arageli ; typedef rational <> Q ; int main ( int argc , char * argv [ ]) { matrix < Q > A = “((-1/2, 3/4), (-2/3, 5), (1/7, -5/2))”; matrix < Q > B = “((3/4, 1/6, -7/8), (5/2, 2/5, -9/10))”; vector < Q > c = “(1/4, -4/15, 5)”; vector < Q > d = “(-2/3, -1, 4)”; Q alpha = Q (1, 120), beta = − 2; vector < Q > res = (( A * B )* c + d *( A * B ) − alpha * d )/ beta ; // ( A * B )* c → c is interpreted as a column // d *( A * B ) → d is interpreted as a row cout << “Result:” << endl ; output aligned ( cout , res ); return 0;

  26. } Result: ||968591/50400|| ||174007/15120|| ||-27583/2520 ||

Recommend


More recommend