File: igcd.C

package info (click to toggle)
givaro 3.2.10-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,388 kB
  • ctags: 2,088
  • sloc: cpp: 11,000; sh: 9,193; makefile: 309; ansic: 93; sed: 4
file content (36 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
#include <stdlib.h>
#include <givaro/givintprime.h>
#include <givaro/givtimer.h>
#include <givaro/givinit.h>         // Givaro initialization



int main(int argc, char** argv)
{
//  Givaro::Init(&argc, &argv);


  IntegerDom IP;
  IntegerDom::Element GG, g,a,b;
  int offset = 0;
  if (argc > ++offset) a = Integer(argv[offset]); else cin >> a;
  if (argc > ++offset) b = Integer(argv[offset]); else cin >> b;
  
        Timer tim; tim.clear(); tim.start();
        IP.gcd(GG,a,b);
	for ( ; argc > ++offset; ) {
		a = Integer(argv[offset]);
		IP.gcd(g, GG, a);
		GG = g;
	}	
        tim.stop();
        cout << GG << endl;
        cerr << tim << endl;

//  Givaro::End();

  return 0;
}