chrislo-sourceclassifier 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +0 -312
- data/Rakefile +2 -2
- data/sourceclassifier.gemspec +6 -6
- metadata +4 -316
- data/sources/gcc/ackermann.gcc-2.gcc +0 -93
- data/sources/gcc/ackermann.gcc-3.gcc +0 -20
- data/sources/gcc/ary.gcc +0 -40
- data/sources/gcc/binarytrees.gcc +0 -136
- data/sources/gcc/binarytrees.gcc-2.gcc +0 -140
- data/sources/gcc/binarytrees.gcc-3.gcc +0 -134
- data/sources/gcc/chameneos.gcc +0 -117
- data/sources/gcc/chameneos.gcc-2.gcc +0 -134
- data/sources/gcc/chameneos.gcc-3.gcc +0 -120
- data/sources/gcc/chameneosredux.gcc +0 -306
- data/sources/gcc/echo.gcc +0 -144
- data/sources/gcc/except.gcc +0 -52
- data/sources/gcc/fannkuch.gcc +0 -105
- data/sources/gcc/fannkuch.gcc-2.gcc +0 -94
- data/sources/gcc/fasta.gcc +0 -158
- data/sources/gcc/fasta.gcc-2.gcc +0 -132
- data/sources/gcc/fasta.gcc-3.gcc +0 -145
- data/sources/gcc/fasta.gcc-4.gcc +0 -141
- data/sources/gcc/fibo.gcc +0 -20
- data/sources/gcc/harmonic.gcc +0 -22
- data/sources/gcc/hash.gcc +0 -31
- data/sources/gcc/hash2.gcc +0 -38
- data/sources/gcc/heapsort.gcc +0 -72
- data/sources/gcc/hello.gcc-2.gcc +0 -12
- data/sources/gcc/hello.gcc-3.gcc +0 -20
- data/sources/gcc/knucleotide.gcc +0 -173
- data/sources/gcc/knucleotide.gcc-2.gcc +0 -168
- data/sources/gcc/lists.gcc +0 -226
- data/sources/gcc/magicsquares.gcc +0 -378
- data/sources/gcc/mandelbrot.gcc +0 -84
- data/sources/gcc/mandelbrot.gcc-2.gcc +0 -63
- data/sources/gcc/mandelbrot.gcc-3.gcc +0 -91
- data/sources/gcc/mandelbrot.gcc-4.gcc +0 -78
- data/sources/gcc/matrix.gcc +0 -66
- data/sources/gcc/message.gcc-2.gcc +0 -72
- data/sources/gcc/message.gcc-3.gcc +0 -64
- data/sources/gcc/methcall.gcc +0 -89
- data/sources/gcc/moments.gcc +0 -120
- data/sources/gcc/nbody.gcc +0 -142
- data/sources/gcc/nbody.gcc-2.gcc +0 -143
- data/sources/gcc/nbody.gcc-3.gcc +0 -142
- data/sources/gcc/nestedloop.gcc +0 -25
- data/sources/gcc/nsieve.gcc +0 -35
- data/sources/gcc/nsievebits.gcc-2.gcc +0 -37
- data/sources/gcc/nsievebits.gcc-3.gcc +0 -53
- data/sources/gcc/objinst.gcc +0 -95
- data/sources/gcc/partialsums.gcc +0 -86
- data/sources/gcc/partialsums.gcc-3.gcc +0 -81
- data/sources/gcc/partialsums.gcc-4.gcc +0 -68
- data/sources/gcc/pidigits.gcc +0 -105
- data/sources/gcc/primes.gcc +0 -75
- data/sources/gcc/prodcons.gcc +0 -86
- data/sources/gcc/random.gcc +0 -29
- data/sources/gcc/raytracer.gcc +0 -125
- data/sources/gcc/raytracer.gcc-2.gcc +0 -181
- data/sources/gcc/recursive.gcc +0 -68
- data/sources/gcc/recursive.gcc-2.gcc +0 -55
- data/sources/gcc/regexdna.gcc-2.gcc +0 -126
- data/sources/gcc/regexmatch.gcc +0 -136
- data/sources/gcc/revcomp.gcc +0 -85
- data/sources/gcc/revcomp.gcc-2.gcc +0 -88
- data/sources/gcc/revcomp.gcc-4.gcc +0 -71
- data/sources/gcc/reversefile.gcc +0 -103
- data/sources/gcc/reversefile.gcc-2.gcc +0 -56
- data/sources/gcc/sieve.gcc +0 -34
- data/sources/gcc/spectralnorm.gcc +0 -54
- data/sources/gcc/spellcheck.gcc +0 -72
- data/sources/gcc/spellcheck.gcc-2.gcc +0 -61
- data/sources/gcc/strcat.gcc +0 -38
- data/sources/gcc/sumcol.gcc-2.gcc +0 -98
- data/sources/gcc/sumcol.gcc-3.gcc +0 -22
- data/sources/gcc/sumcol.gcc-4.gcc +0 -18
- data/sources/gcc/sumcol.gcc-5.gcc +0 -32
- data/sources/gcc/takfp.gcc +0 -23
- data/sources/gcc/tcp-stream.gcc +0 -122
- data/sources/gcc/tcpecho.gcc +0 -122
- data/sources/gcc/tcpecho.gcc-2.gcc +0 -136
- data/sources/gcc/tcprequest.gcc +0 -122
- data/sources/gcc/threadring.gcc +0 -73
- data/sources/gcc/wc.gcc +0 -52
- data/sources/gcc/wc.gcc-2.gcc +0 -40
- data/sources/gcc/wc.gcc-3.gcc +0 -46
- data/sources/gcc/wordfreq.gcc-2.gcc +0 -85
- data/sources/perl/ackermann.perl +0 -28
- data/sources/perl/ackermann.perl-2.perl +0 -25
- data/sources/perl/ackermann.perl-3.perl +0 -20
- data/sources/perl/ackermann.perl-4.perl +0 -18
- data/sources/perl/ary.perl +0 -25
- data/sources/perl/ary.perl-2.perl +0 -23
- data/sources/perl/binarytrees.perl +0 -66
- data/sources/perl/binarytrees.perl-2.perl +0 -71
- data/sources/perl/chameneos.perl +0 -67
- data/sources/perl/echo.perl +0 -81
- data/sources/perl/except.perl +0 -73
- data/sources/perl/fannkuch.perl +0 -44
- data/sources/perl/fannkuch.perl-2.perl +0 -38
- data/sources/perl/fasta.perl +0 -112
- data/sources/perl/fasta.perl-2.perl +0 -135
- data/sources/perl/fasta.perl-4.perl +0 -122
- data/sources/perl/fibo.perl +0 -15
- data/sources/perl/fibo.perl-2.perl +0 -0
- data/sources/perl/fibo.perl-3.perl +0 -0
- data/sources/perl/harmonic.perl +0 -7
- data/sources/perl/hash.perl +0 -23
- data/sources/perl/hash.perl-2.perl +0 -17
- data/sources/perl/hash.perl-3.perl +0 -24
- data/sources/perl/hash2.perl +0 -16
- data/sources/perl/heapsort.perl +0 -65
- data/sources/perl/heapsort.perl-2.perl +0 -0
- data/sources/perl/hello.perl +0 -5
- data/sources/perl/knucleotide.perl-2.perl +0 -30
- data/sources/perl/lists.perl +0 -48
- data/sources/perl/mandelbrot.perl-2.perl +0 -32
- data/sources/perl/matrix.perl +0 -59
- data/sources/perl/matrix.perl-2.perl +0 -0
- data/sources/perl/matrix.perl-3.perl +0 -0
- data/sources/perl/message.perl +0 -27
- data/sources/perl/methcall.perl +0 -66
- data/sources/perl/moments.perl +0 -44
- data/sources/perl/nbody.perl +0 -108
- data/sources/perl/nestedloop.perl +0 -28
- data/sources/perl/nsieve.perl-2.perl +0 -41
- data/sources/perl/nsieve.perl-4.perl +0 -43
- data/sources/perl/nsievebits.perl +0 -37
- data/sources/perl/objinst.perl +0 -73
- data/sources/perl/partialsums.perl-3.perl +0 -31
- data/sources/perl/pidigits.perl +0 -52
- data/sources/perl/pidigits.perl-2.perl +0 -47
- data/sources/perl/process.perl +0 -50
- data/sources/perl/prodcons.perl +0 -47
- data/sources/perl/random.perl-4.perl +0 -17
- data/sources/perl/recursive.perl-2.perl +0 -57
- data/sources/perl/regexdna.perl +0 -48
- data/sources/perl/regexdna.perl-2.perl +0 -43
- data/sources/perl/regexdna.perl-3.perl +0 -50
- data/sources/perl/regexdna.perl-4.perl +0 -49
- data/sources/perl/regexdna.perl-5.perl +0 -42
- data/sources/perl/regexdna.perl-6.perl +0 -43
- data/sources/perl/regexmatch.perl +0 -35
- data/sources/perl/revcomp.perl-2.perl +0 -34
- data/sources/perl/reversefile.perl +0 -8
- data/sources/perl/reversefile.perl-2.perl +0 -0
- data/sources/perl/reversefile.perl-3.perl +0 -0
- data/sources/perl/sieve.perl +0 -23
- data/sources/perl/spectralnorm.perl-2.perl +0 -54
- data/sources/perl/spellcheck.perl +0 -24
- data/sources/perl/strcat.perl +0 -13
- data/sources/perl/strcat.perl-2.perl +0 -0
- data/sources/perl/sumcol.perl +0 -8
- data/sources/perl/takfp.perl +0 -23
- data/sources/perl/takfp.perl-3.perl +0 -20
- data/sources/perl/tcpecho.perl +0 -61
- data/sources/perl/tcprequest.perl +0 -61
- data/sources/perl/tcpstream.perl +0 -61
- data/sources/perl/threadring.perl +0 -55
- data/sources/perl/threadring.perl-2.perl +0 -43
- data/sources/perl/wc.perl +0 -20
- data/sources/perl/wc.perl-2.perl +0 -14
- data/sources/perl/wordfreq.perl +0 -22
- data/sources/perl/wordfreq.perl-3.perl +0 -0
- data/sources/perl/wordfreq.perl3.perl +0 -0
- data/sources/python/ackermann.python +0 -21
- data/sources/python/ary.python +0 -19
- data/sources/python/binarytrees.python +0 -39
- data/sources/python/binarytrees.python-3.python +0 -44
- data/sources/python/chameneos.python-6.python +0 -73
- data/sources/python/chameneosredux.python +0 -126
- data/sources/python/chameneosredux.python-2.python +0 -122
- data/sources/python/dispatch.python +0 -176
- data/sources/python/dispatch.python-2.python +0 -136
- data/sources/python/echo.python +0 -64
- data/sources/python/except.python +0 -62
- data/sources/python/fannkuch.python +0 -50
- data/sources/python/fannkuch.python-2.python +0 -54
- data/sources/python/fasta.python-2.python +0 -79
- data/sources/python/fibo.python +0 -17
- data/sources/python/fibo.python-2.python +0 -0
- data/sources/python/fibo.python-3.python +0 -0
- data/sources/python/harmonic.python-2.python +0 -9
- data/sources/python/hash.python +0 -21
- data/sources/python/hash.python-2.python +0 -0
- data/sources/python/hash2.python +0 -30
- data/sources/python/heapsort.python-3.python +0 -66
- data/sources/python/hello.python +0 -5
- data/sources/python/implicitode.python +0 -231
- data/sources/python/knucleotide.python +0 -55
- data/sources/python/lists.python +0 -44
- data/sources/python/magicsquares.python +0 -145
- data/sources/python/mandelbrot.python +0 -44
- data/sources/python/mandelbrot.python-2.python +0 -35
- data/sources/python/mandelbrot.python-3.python +0 -46
- data/sources/python/matrix.python +0 -34
- data/sources/python/matrix.python-2.python +0 -23
- data/sources/python/message.python +0 -24
- data/sources/python/message.python-2.python +0 -20
- data/sources/python/message.python-3.python +0 -19
- data/sources/python/meteor.python +0 -210
- data/sources/python/meteor.python-2.python +0 -192
- data/sources/python/methcall.python +0 -51
- data/sources/python/moments.python +0 -65
- data/sources/python/nbody.python +0 -123
- data/sources/python/nbody.python-2.python +0 -120
- data/sources/python/nestedloop.python +0 -24
- data/sources/python/nsieve.python +0 -27
- data/sources/python/nsieve.python-2.python +0 -23
- data/sources/python/nsieve.python-4.python +0 -25
- data/sources/python/nsievebits.python +0 -27
- data/sources/python/nsievebits.python-2.python +0 -43
- data/sources/python/objinst.python +0 -53
- data/sources/python/partialsums.python +0 -37
- data/sources/python/partialsums.python-2.python +0 -35
- data/sources/python/partialsums.python-3.python +0 -48
- data/sources/python/pidigits.python +0 -38
- data/sources/python/pidigits.python-3.python +0 -63
- data/sources/python/pidigits.python-4.python +0 -24
- data/sources/python/process.python +0 -51
- data/sources/python/process.python-2.python +0 -133
- data/sources/python/prodcons.python +0 -51
- data/sources/python/prodcons.python-2.python +0 -0
- data/sources/python/random.python +0 -27
- data/sources/python/raytracer.python +0 -203
- data/sources/python/recursive.python +0 -35
- data/sources/python/regexdna.python +0 -39
- data/sources/python/regexdna.python-2.python +0 -34
- data/sources/python/regexmatch.python +0 -36
- data/sources/python/revcomp.python-3.python +0 -31
- data/sources/python/reversefile.python +0 -13
- data/sources/python/reversefile.python-2.python +0 -0
- data/sources/python/reversefile.python-3.python +0 -0
- data/sources/python/sieve.python +0 -50
- data/sources/python/spectralnorm.python-2.python +0 -36
- data/sources/python/spellcheck.python +0 -17
- data/sources/python/strcat.python +0 -35
- data/sources/python/strcat.python-2.python +0 -0
- data/sources/python/sumcol.python-2.python +0 -0
- data/sources/python/sumcol.python-3.python +0 -0
- data/sources/python/takfp.python +0 -19
- data/sources/python/tcpecho.python +0 -67
- data/sources/python/tcprequest.python +0 -67
- data/sources/python/tcpstream.python +0 -67
- data/sources/python/threadring.python +0 -47
- data/sources/python/threadring.python-2.python +0 -40
- data/sources/python/threadring.python-3.python +0 -34
- data/sources/python/wc.python-2.python +0 -19
- data/sources/python/wordfreq.python +0 -43
- data/sources/python/wordfreq.python-2.python +0 -0
- data/sources/python/wordfreq.python-3.python +0 -28
- data/sources/python/wordfreq.python-4.python +0 -38
- data/sources/python/wordfreq.python-5.python +0 -39
- data/sources/ruby/ackermann.ruby +0 -17
- data/sources/ruby/ackermann.ruby-5.ruby +0 -153
- data/sources/ruby/ary.ruby +0 -22
- data/sources/ruby/binarytrees.ruby-2.ruby +0 -55
- data/sources/ruby/chameneos.ruby-2.ruby +0 -71
- data/sources/ruby/dispatch.ruby +0 -114
- data/sources/ruby/echo.ruby +0 -41
- data/sources/ruby/except.ruby +0 -61
- data/sources/ruby/except.ruby-2.ruby +0 -61
- data/sources/ruby/fannkuch.ruby +0 -42
- data/sources/ruby/fasta.ruby +0 -81
- data/sources/ruby/fibo.ruby +0 -15
- data/sources/ruby/harmonic.ruby-2.ruby +0 -15
- data/sources/ruby/hash.ruby +0 -19
- data/sources/ruby/hash2.ruby +0 -23
- data/sources/ruby/heapsort.ruby +0 -55
- data/sources/ruby/hello.ruby +0 -6
- data/sources/ruby/knucleotide.ruby-2.ruby +0 -44
- data/sources/ruby/lists.ruby +0 -46
- data/sources/ruby/mandelbrot.ruby-3.ruby +0 -63
- data/sources/ruby/matrix.ruby +0 -40
- data/sources/ruby/matrix.ruby-2.ruby +0 -30
- data/sources/ruby/message.ruby +0 -29
- data/sources/ruby/message.ruby-2.ruby +0 -24
- data/sources/ruby/meteor.ruby +0 -386
- data/sources/ruby/meteor.ruby-2.ruby +0 -561
- data/sources/ruby/methcall.ruby +0 -58
- data/sources/ruby/methcall.ruby-2.ruby +0 -54
- data/sources/ruby/moments.ruby +0 -64
- data/sources/ruby/nbody.ruby-2.ruby +0 -145
- data/sources/ruby/nestedloop.ruby +0 -22
- data/sources/ruby/nsieve.ruby +0 -36
- data/sources/ruby/nsieve.ruby-2.ruby +0 -25
- data/sources/ruby/nsievebits.ruby-2.ruby +0 -42
- data/sources/ruby/objinst.ruby +0 -58
- data/sources/ruby/partialsums.ruby +0 -39
- data/sources/ruby/pidigits.ruby +0 -92
- data/sources/ruby/pidigits.ruby-2.ruby +0 -109
- data/sources/ruby/prodcons.ruby +0 -41
- data/sources/ruby/random.ruby +0 -17
- data/sources/ruby/recursive.ruby-2.ruby +0 -53
- data/sources/ruby/regexdna.ruby +0 -32
- data/sources/ruby/regexdna.ruby-2.ruby +0 -38
- data/sources/ruby/regexmatch.ruby +0 -33
- data/sources/ruby/revcomp.ruby +0 -28
- data/sources/ruby/reversefile.ruby +0 -7
- data/sources/ruby/sieve.ruby +0 -30
- data/sources/ruby/spectralnorm.ruby +0 -48
- data/sources/ruby/spellcheck.ruby +0 -18
- data/sources/ruby/spellcheck.ruby-2.ruby +0 -0
- data/sources/ruby/strcat.ruby +0 -12
- data/sources/ruby/strcat.ruby-2.ruby +0 -12
- data/sources/ruby/sumcol.ruby +0 -12
- data/sources/ruby/sumcol.ruby-2.ruby +0 -5
- data/sources/ruby/takfp.ruby +0 -15
- data/sources/ruby/tcpecho.ruby +0 -45
- data/sources/ruby/tcprequest.ruby +0 -45
- data/sources/ruby/tcpstream.ruby +0 -45
- data/sources/ruby/threadring.ruby +0 -61
- data/sources/ruby/threadring.ruby-2.ruby +0 -33
- data/sources/ruby/wc.ruby +0 -15
- data/sources/ruby/wordfreq.ruby +0 -17
- data/sources/ruby/wordfreq.ruby2.ruby +0 -0
@@ -1,56 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: reversefile.gcc-2.gcc,v 1.1 2004-11-10 06:51:38 bfulgham Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
*/
|
5
|
-
|
6
|
-
/* this version attempts to read the file line by line instead of
|
7
|
-
all at once. */
|
8
|
-
|
9
|
-
#include <stdio.h>
|
10
|
-
#include <stdlib.h>
|
11
|
-
#include <string.h>
|
12
|
-
#include <unistd.h>
|
13
|
-
|
14
|
-
#define BLKSIZE 16 * 1024
|
15
|
-
|
16
|
-
int main(int argc, char *argv[]) {
|
17
|
-
int nread, size, len;
|
18
|
-
char *cp, *offset, *buf = malloc(BLKSIZE + 1);
|
19
|
-
|
20
|
-
offset = buf;
|
21
|
-
size = len = BLKSIZE;
|
22
|
-
while (1) {
|
23
|
-
nread = read(0, offset, len);
|
24
|
-
if (0 == nread) break;
|
25
|
-
if (-1 == nread) {
|
26
|
-
perror("read");
|
27
|
-
exit(1);
|
28
|
-
}
|
29
|
-
offset += nread;
|
30
|
-
len -= nread;
|
31
|
-
if (0 == len) {
|
32
|
-
len = size;
|
33
|
-
size *= 2;
|
34
|
-
if (0 == (cp = realloc(buf, size + 1))) {
|
35
|
-
fprintf(stderr, "realloc failed\n");
|
36
|
-
exit(1);
|
37
|
-
}
|
38
|
-
buf = cp;
|
39
|
-
offset = buf + len;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
*offset = 0;
|
43
|
-
for (cp = offset; cp > buf; --cp) {
|
44
|
-
if ('\n' == *cp) {
|
45
|
-
*offset = 0;
|
46
|
-
if (cp < offset)
|
47
|
-
printf(offset = cp+1);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
if (cp < offset) {
|
51
|
-
*offset = 0;
|
52
|
-
printf(cp);
|
53
|
-
}
|
54
|
-
free(buf);
|
55
|
-
return(0);
|
56
|
-
}
|
data/sources/gcc/sieve.gcc
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: sieve.gcc,v 1.1.1.1 2004-05-19 18:12:27 bfulgham Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
*/
|
5
|
-
|
6
|
-
#include <stdio.h>
|
7
|
-
#include <stdlib.h>
|
8
|
-
|
9
|
-
int
|
10
|
-
main(int argc, char *argv[]) {
|
11
|
-
int NUM = ((argc == 2) ? atoi(argv[1]) : 1);
|
12
|
-
static char flags[8192 + 1];
|
13
|
-
long i, k;
|
14
|
-
int count = 0;
|
15
|
-
|
16
|
-
while (NUM--) {
|
17
|
-
count = 0;
|
18
|
-
for (i=2; i <= 8192; i++) {
|
19
|
-
flags[i] = 1;
|
20
|
-
}
|
21
|
-
for (i=2; i <= 8192; i++) {
|
22
|
-
if (flags[i]) {
|
23
|
-
// remove all multiples of prime: i
|
24
|
-
for (k=i+i; k <= 8192; k+=i) {
|
25
|
-
flags[k] = 0;
|
26
|
-
}
|
27
|
-
count++;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
printf("Count: %d\n", count);
|
32
|
-
return(0);
|
33
|
-
}
|
34
|
-
|
@@ -1,54 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
*
|
3
|
-
* The Great Computer Language Shootout
|
4
|
-
* http://shootout.alioth.debian.org/
|
5
|
-
*
|
6
|
-
* Contributed by Sebastien Loisel
|
7
|
-
*/
|
8
|
-
|
9
|
-
#include <stdio.h>
|
10
|
-
#include <stdlib.h>
|
11
|
-
#include <math.h>
|
12
|
-
|
13
|
-
double eval_A(int i, int j) { return 1.0/((i+j)*(i+j+1)/2+i+1); }
|
14
|
-
|
15
|
-
void eval_A_times_u(int N, const double u[], double Au[])
|
16
|
-
{
|
17
|
-
int i,j;
|
18
|
-
for(i=0;i<N;i++)
|
19
|
-
{
|
20
|
-
Au[i]=0;
|
21
|
-
for(j=0;j<N;j++) Au[i]+=eval_A(i,j)*u[j];
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
void eval_At_times_u(int N, const double u[], double Au[])
|
26
|
-
{
|
27
|
-
int i,j;
|
28
|
-
for(i=0;i<N;i++)
|
29
|
-
{
|
30
|
-
Au[i]=0;
|
31
|
-
for(j=0;j<N;j++) Au[i]+=eval_A(j,i)*u[j];
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
void eval_AtA_times_u(int N, const double u[], double AtAu[])
|
36
|
-
{ double v[N]; eval_A_times_u(N,u,v); eval_At_times_u(N,v,AtAu); }
|
37
|
-
|
38
|
-
int main(int argc, char *argv[])
|
39
|
-
{
|
40
|
-
int i;
|
41
|
-
int N = ((argc == 2) ? atoi(argv[1]) : 2000);
|
42
|
-
double u[N],v[N],vBv,vv;
|
43
|
-
for(i=0;i<N;i++) u[i]=1;
|
44
|
-
for(i=0;i<10;i++)
|
45
|
-
{
|
46
|
-
eval_AtA_times_u(N,u,v);
|
47
|
-
eval_AtA_times_u(N,v,u);
|
48
|
-
}
|
49
|
-
vBv=vv=0;
|
50
|
-
for(i=0;i<N;i++) { vBv+=u[i]*v[i]; vv+=v[i]*v[i]; }
|
51
|
-
printf("%0.9f\n",sqrt(vBv/vv));
|
52
|
-
return 0;
|
53
|
-
}
|
54
|
-
|
data/sources/gcc/spellcheck.gcc
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: spellcheck.gcc,v 1.1.1.1 2004-05-19 18:13:26 bfulgham Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
* with help from Brad Knotwell
|
5
|
-
*/
|
6
|
-
|
7
|
-
#include <ctype.h>
|
8
|
-
#include <stdio.h>
|
9
|
-
#include <stdlib.h>
|
10
|
-
#include <unistd.h>
|
11
|
-
#include "simple_hash.h"
|
12
|
-
|
13
|
-
#define MAXLINELEN 128
|
14
|
-
|
15
|
-
struct ht_ht *dict = NULL;
|
16
|
-
|
17
|
-
int handleInput(FILE *input,void (*hashManipFn)(char *))
|
18
|
-
{
|
19
|
-
int wordbufsize = 80,i = 0;
|
20
|
-
char *cp, *wordbuf = (char *)malloc(wordbufsize + 1);
|
21
|
-
char line[MAXLINELEN];
|
22
|
-
|
23
|
-
if((wordbuf = malloc(wordbufsize+1)) == NULL)
|
24
|
-
return(fprintf(stderr,"malloc\n"),0);
|
25
|
-
|
26
|
-
while (fgets(line, MAXLINELEN, input))
|
27
|
-
for (cp=line; *cp > 0; cp++) {
|
28
|
-
if (isspace(*cp)) {
|
29
|
-
if (i) {
|
30
|
-
wordbuf[i] = '\0';
|
31
|
-
hashManipFn(wordbuf);
|
32
|
-
i = 0;
|
33
|
-
}
|
34
|
-
} else {
|
35
|
-
wordbuf[i++] = *cp;
|
36
|
-
if (i == wordbufsize) {
|
37
|
-
wordbufsize *= 2;
|
38
|
-
if((wordbuf = realloc(wordbuf, wordbufsize + 1)) == NULL)
|
39
|
-
return(fprintf(stderr, "realloc\n"), 0);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
free(wordbuf);
|
45
|
-
return(1);
|
46
|
-
}
|
47
|
-
|
48
|
-
void spellCheck(char *key) {
|
49
|
-
if (ht_find_new(dict,key)->val != 1) printf("%s\n",key);
|
50
|
-
}
|
51
|
-
|
52
|
-
void hashLoad(char *key) { ht_find_new(dict,key)->val = 1; }
|
53
|
-
|
54
|
-
int main(int argc, char *argv[]) {
|
55
|
-
FILE *fh;
|
56
|
-
int rc;
|
57
|
-
|
58
|
-
/*
|
59
|
-
ht_create doesn't handle malloc and calloc failures
|
60
|
-
so this is superfluous
|
61
|
-
*/
|
62
|
-
if((dict = ht_create(40000)) == NULL)
|
63
|
-
return(fprintf(stderr,"hash creation failed\n"),EXIT_FAILURE);
|
64
|
-
|
65
|
-
if ((fh = fopen("Usr.Dict.Words", "r")) == NULL)
|
66
|
-
return(fprintf(stderr,"couldn't open dictionary\n"),EXIT_FAILURE);
|
67
|
-
|
68
|
-
rc = ((handleInput(fh,hashLoad) && handleInput(stdin,spellCheck)) ? EXIT_SUCCESS : EXIT_FAILURE);
|
69
|
-
|
70
|
-
ht_destroy(dict);
|
71
|
-
return(rc);
|
72
|
-
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: spellcheck.gcc-2.gcc,v 1.1 2004-11-10 06:47:52 bfulgham Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
*/
|
5
|
-
|
6
|
-
#include <ctype.h>
|
7
|
-
#include <stdio.h>
|
8
|
-
#include <stdlib.h>
|
9
|
-
#include <unistd.h>
|
10
|
-
#include "../../Include/simple_hash.h"
|
11
|
-
|
12
|
-
int main(int argc, char *argv[]) {
|
13
|
-
int i, wordbufsize = 80;
|
14
|
-
char c, *wordbuf = (char *)malloc(wordbufsize + 1);
|
15
|
-
struct ht_ht *dict = ht_create(40000);
|
16
|
-
FILE *fh;
|
17
|
-
|
18
|
-
if ((fh = fopen("Usr.Dict.Words", "r")) == NULL) {
|
19
|
-
perror("fopen");
|
20
|
-
exit(1);
|
21
|
-
}
|
22
|
-
i = 0;
|
23
|
-
while ((c = getc(fh)) > 0) {
|
24
|
-
if (isspace(c)) {
|
25
|
-
if (i > 0) {
|
26
|
-
wordbuf[i] = '\0';
|
27
|
-
ht_find_new(dict, wordbuf)->val = 1;
|
28
|
-
i = 0;
|
29
|
-
}
|
30
|
-
} else {
|
31
|
-
wordbuf[i++] = c;
|
32
|
-
if (i == wordbufsize) {
|
33
|
-
wordbufsize *= 2;
|
34
|
-
wordbuf = realloc(wordbuf, wordbufsize + 1);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
fclose(fh);
|
39
|
-
|
40
|
-
i = 0;
|
41
|
-
while ((c = getchar()) > 0) {
|
42
|
-
if (isspace(c)) {
|
43
|
-
if (i > 0) {
|
44
|
-
wordbuf[i] = '\0';
|
45
|
-
if (ht_find(dict, wordbuf) == NULL) {
|
46
|
-
printf("%s\n", wordbuf);
|
47
|
-
}
|
48
|
-
i = 0;
|
49
|
-
}
|
50
|
-
} else {
|
51
|
-
wordbuf[i++] = c;
|
52
|
-
if (i == wordbufsize) {
|
53
|
-
wordbufsize *= 2;
|
54
|
-
wordbuf = realloc(wordbuf, wordbufsize + 1);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
free(wordbuf);
|
59
|
-
ht_destroy(dict);
|
60
|
-
return(0);
|
61
|
-
}
|
data/sources/gcc/strcat.gcc
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: strcat.gcc,v 1.1.1.1 2004-05-19 18:13:34 bfulgham Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
*/
|
5
|
-
|
6
|
-
#include <stdio.h>
|
7
|
-
#include <stdlib.h>
|
8
|
-
#include <string.h>
|
9
|
-
#include <unistd.h>
|
10
|
-
|
11
|
-
#define STUFF "hello\n"
|
12
|
-
|
13
|
-
int
|
14
|
-
main(int argc, char *argv[]) {
|
15
|
-
int n = ((argc == 2) ? atoi(argv[1]) : 1);
|
16
|
-
int i, buflen = 32;
|
17
|
-
char *strbuf = calloc(sizeof(char), buflen);
|
18
|
-
char *strend = strbuf;
|
19
|
-
int stufflen = strlen(STUFF);
|
20
|
-
|
21
|
-
if (!strbuf) { perror("calloc strbuf"); exit(1); }
|
22
|
-
for (i=0; i<n; i++) {
|
23
|
-
if (((strbuf+buflen)-strend) < (stufflen+1)) {
|
24
|
-
buflen = 2*buflen;
|
25
|
-
strbuf = realloc(strbuf, buflen);
|
26
|
-
if (!strbuf) { perror("realloc strbuf"); exit(1); }
|
27
|
-
strend = strbuf + strlen(strbuf);
|
28
|
-
}
|
29
|
-
/* much faster to strcat to strend than to strbuf */
|
30
|
-
strcat(strend, STUFF);
|
31
|
-
strend += stufflen;
|
32
|
-
}
|
33
|
-
fprintf(stdout, "%d\n", strlen(strbuf));
|
34
|
-
free(strbuf);
|
35
|
-
|
36
|
-
sleep(1);
|
37
|
-
return(0);
|
38
|
-
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
/* The Computer Language Shootout
|
2
|
-
* http://shootout.alioth.debian.org/
|
3
|
-
*
|
4
|
-
* contributed by CTips (ctips@bestweb.net)
|
5
|
-
* modified by
|
6
|
-
*/
|
7
|
-
#include <stdio.h>
|
8
|
-
#include <stdlib.h>
|
9
|
-
#include <ctype.h>
|
10
|
-
#include <limits.h>
|
11
|
-
|
12
|
-
#define MAXLINELEN 128
|
13
|
-
|
14
|
-
/* the progam sums each digit position separately; the formula below gives
|
15
|
-
* a coservative estimate of the number of digits required
|
16
|
-
*/
|
17
|
-
#define MAXDIGITS ((int)(1+((sizeof(int)*CHAR_BIT)/3)))
|
18
|
-
|
19
|
-
/* stdin is may be unbuffered by default in the operating system.
|
20
|
-
* Provide a buffer as shown below to make sure that it is buffered
|
21
|
-
*/
|
22
|
-
#ifndef IOBUFSIZE
|
23
|
-
#define IOBUFSIZE (16*1024)
|
24
|
-
#endif
|
25
|
-
|
26
|
-
/* according to the benchmark requiremnents, we need to use "line-oriented"
|
27
|
-
* I/O functions. I'm going to assume that requires line-buffering as well,
|
28
|
-
* but we can override the behavior here
|
29
|
-
*/
|
30
|
-
#define IOBUFMODE _IOLBF
|
31
|
-
|
32
|
-
/* gets or fgets */
|
33
|
-
#ifndef USE_GETS
|
34
|
-
#define USE_GETS 1
|
35
|
-
#endif
|
36
|
-
|
37
|
-
#if USE_GETS
|
38
|
-
#define IOGET(_line) gets(_line)
|
39
|
-
#else
|
40
|
-
#define IOGET(_line) fgets(_line, sizeof(_line), stdin)
|
41
|
-
#endif
|
42
|
-
|
43
|
-
int
|
44
|
-
main(void)
|
45
|
-
{
|
46
|
-
char line[MAXLINELEN];
|
47
|
-
int digitsum[MAXDIGITS];
|
48
|
-
char iobuf[IOBUFSIZE];
|
49
|
-
int sum;
|
50
|
-
int i;
|
51
|
-
|
52
|
-
setvbuf(stdin, iobuf, IOBUFMODE, sizeof(iobuf));
|
53
|
-
|
54
|
-
for( i = 0; i < MAXDIGITS; i++ ) {
|
55
|
-
digitsum[i] = 0;
|
56
|
-
}
|
57
|
-
|
58
|
-
while( IOGET(line) ) {
|
59
|
-
char * p = line;
|
60
|
-
char digits[15];
|
61
|
-
int ndigits;
|
62
|
-
int isneg;
|
63
|
-
|
64
|
-
while( isspace(*p) ) {
|
65
|
-
p++;
|
66
|
-
}
|
67
|
-
|
68
|
-
isneg = 0;
|
69
|
-
if( *p == '-' ) {
|
70
|
-
p++;
|
71
|
-
isneg = 1;
|
72
|
-
}
|
73
|
-
|
74
|
-
ndigits = 0;
|
75
|
-
while( isdigit(*p) ) {
|
76
|
-
digits[ndigits] = *p;
|
77
|
-
ndigits++;
|
78
|
-
p++;
|
79
|
-
}
|
80
|
-
if( isneg ) {
|
81
|
-
for( i = 0; i < ndigits; i++ ) {
|
82
|
-
digitsum[i] -= digits[ndigits-1-i] - '0';
|
83
|
-
}
|
84
|
-
}
|
85
|
-
else {
|
86
|
-
for( i = 0; i < ndigits; i++ ) {
|
87
|
-
digitsum[i] += digits[ndigits-1-i] - '0';
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
sum = 0;
|
93
|
-
for( i = MAXDIGITS-1; i >= 0; i-- ) {
|
94
|
-
sum = sum*10 + digitsum[i];
|
95
|
-
}
|
96
|
-
printf("%d\n", sum);
|
97
|
-
return(0);
|
98
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/* The Computer Language Benchmarks Game
|
2
|
-
http://shootout.alioth.debian.org/
|
3
|
-
modified by … James Antill - 2007-06-14
|
4
|
-
*/
|
5
|
-
|
6
|
-
#define _GNU_SOURCE 1
|
7
|
-
#include <stdio.h>
|
8
|
-
#include <stdlib.h>
|
9
|
-
|
10
|
-
#define MAXLINELEN 128
|
11
|
-
|
12
|
-
int
|
13
|
-
main() {
|
14
|
-
int sum = 0;
|
15
|
-
char line[MAXLINELEN];
|
16
|
-
|
17
|
-
while (fgets_unlocked(line, MAXLINELEN, stdin)) {
|
18
|
-
sum += atoi(line);
|
19
|
-
}
|
20
|
-
printf("%d\n", sum);
|
21
|
-
return(0);
|
22
|
-
}
|