サンプルプログラム

ソースコード

  1. #include <iostream>
  2. #include "lilib.h"
  3. using namespace std;
  4. int main(){
  5. lilib::setPrecision(100);
  6. cout << "Long precision is " << lilib::getPrecision() << "." << endl;
  7. cout << endl;
  8. LongInterval x;
  9. x = 1;
  10. cout << "x = " << x << endl;
  11. x /= 3;
  12. cout << "x = " << x << endl;
  13. x *= 3;
  14. cout << "x = " << x << endl;
  15. cout << endl;
  16. int m = 3, n = 2, i, j;
  17. LongIntervalMatrix a(m, n), b, c;
  18. for(i = 0; i < m; i++){
  19. for(j = 0; j < n; j++){
  20. a[i][j] = n * i + j;
  21. }
  22. }
  23. b = trans(a);
  24. c = a * b;
  25. cout << "a = " << endl << a << endl;
  26. cout << "b = " << endl << b << endl;
  27. cout << "c = " << endl << c << endl;
  28. return 0;
  29. }

実行結果

Long precision is 105.

x = < 1.000000, 0.000000>
x = < 3.333333e-1, 2.537942e-116>
x = < 1.000000, 7.613826e-116>

a =
< 0.000000, 0.000000>   < 1.000000, 0.000000>
< 2.000000, 0.000000>   < 3.000000, 0.000000>
< 4.000000, 0.000000>   < 5.000000, 0.000000>

b =
< 0.000000, 0.000000>   < 2.000000, 0.000000>   < 4.000000, 0.000000>
< 1.000000, 0.000000>   < 3.000000, 0.000000>   < 5.000000, 0.000000>

c =
< 1.000000, 0.000000>   < 3.000000, 0.000000>   < 5.000000, 0.000000>
< 3.000000, 0.000000>   < 1.300000e1, 0.000000> < 2.300000e1, 0.000000>
< 5.000000, 0.000000>   < 2.300000e1, 0.000000> < 4.100000e1, 0.000000>