From 2f2ba42a1453f4a3a08f9c1ecfc53c1b1c83d550 Mon Sep 17 00:00:00 2001 From: "philblunsom@gmail.com" Date: Tue, 22 Jun 2010 20:34:00 +0000 Subject: Initial ci of gi dir git-svn-id: https://ws10smt.googlecode.com/svn/trunk@5 ec762483-ff6d-05da-a07a-a48fb63a330f --- gi/pyp-topics/scripts/contexts2documents.py | 29 + gi/pyp-topics/scripts/extract_contexts.py | 144 +++ gi/pyp-topics/scripts/extract_contexts_test.py | 72 ++ gi/pyp-topics/scripts/extract_leaves.py | 49 + gi/pyp-topics/scripts/map-documents.py | 20 + gi/pyp-topics/scripts/map-terms.py | 20 + gi/pyp-topics/scripts/score-mkcls.py | 61 ++ gi/pyp-topics/scripts/score-topics.py | 64 ++ gi/pyp-topics/scripts/spans2labels.py | 46 + gi/pyp-topics/scripts/topics.py | 20 + gi/pyp-topics/src/Makefile | 30 + gi/pyp-topics/src/corpus.cc | 103 ++ gi/pyp-topics/src/corpus.hh | 101 ++ gi/pyp-topics/src/gammadist.c | 247 +++++ gi/pyp-topics/src/gammadist.h | 72 ++ gi/pyp-topics/src/gzstream.cc | 165 ++++ gi/pyp-topics/src/gzstream.hh | 121 +++ gi/pyp-topics/src/log_add.h | 30 + gi/pyp-topics/src/makefile.darwin | 15 + gi/pyp-topics/src/makefile.depend | 1250 ++++++++++++++++++++++++ gi/pyp-topics/src/mt19937ar.c | 194 ++++ gi/pyp-topics/src/mt19937ar.h | 44 + gi/pyp-topics/src/pyp-topics.cc | 224 +++++ gi/pyp-topics/src/pyp-topics.hh | 52 + gi/pyp-topics/src/pyp.hh | 477 +++++++++ gi/pyp-topics/src/slice-sampler.h | 192 ++++ gi/pyp-topics/src/train.cc | 136 +++ gi/pyp-topics/src/utility.h | 962 ++++++++++++++++++ 28 files changed, 4940 insertions(+) create mode 100755 gi/pyp-topics/scripts/contexts2documents.py create mode 100755 gi/pyp-topics/scripts/extract_contexts.py create mode 100755 gi/pyp-topics/scripts/extract_contexts_test.py create mode 100755 gi/pyp-topics/scripts/extract_leaves.py create mode 100755 gi/pyp-topics/scripts/map-documents.py create mode 100755 gi/pyp-topics/scripts/map-terms.py create mode 100755 gi/pyp-topics/scripts/score-mkcls.py create mode 100755 gi/pyp-topics/scripts/score-topics.py create mode 100755 gi/pyp-topics/scripts/spans2labels.py create mode 100755 gi/pyp-topics/scripts/topics.py create mode 100644 gi/pyp-topics/src/Makefile create mode 100644 gi/pyp-topics/src/corpus.cc create mode 100644 gi/pyp-topics/src/corpus.hh create mode 100644 gi/pyp-topics/src/gammadist.c create mode 100644 gi/pyp-topics/src/gammadist.h create mode 100644 gi/pyp-topics/src/gzstream.cc create mode 100644 gi/pyp-topics/src/gzstream.hh create mode 100644 gi/pyp-topics/src/log_add.h create mode 100644 gi/pyp-topics/src/makefile.darwin create mode 100644 gi/pyp-topics/src/makefile.depend create mode 100644 gi/pyp-topics/src/mt19937ar.c create mode 100644 gi/pyp-topics/src/mt19937ar.h create mode 100644 gi/pyp-topics/src/pyp-topics.cc create mode 100644 gi/pyp-topics/src/pyp-topics.hh create mode 100644 gi/pyp-topics/src/pyp.hh create mode 100644 gi/pyp-topics/src/slice-sampler.h create mode 100644 gi/pyp-topics/src/train.cc create mode 100644 gi/pyp-topics/src/utility.h diff --git a/gi/pyp-topics/scripts/contexts2documents.py b/gi/pyp-topics/scripts/contexts2documents.py new file mode 100755 index 00000000..c625d17d --- /dev/null +++ b/gi/pyp-topics/scripts/contexts2documents.py @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import sys +from operator import itemgetter + +if len(sys.argv) > 2: + print "Usage: contexts2documents.py [contexts_index_out]" + exit(1) + +context_index = {} +for line in sys.stdin: + phrase, line_tail = line.split('\t') + + raw_contexts = line_tail.split('|||') + contexts = [c.strip() for x,c in enumerate(raw_contexts) if x%2 == 0] + counts = [int(c.split('=')[1].strip()) for x,c in enumerate(raw_contexts) if x%2 != 0] + + print len(contexts), + for context,count in zip(contexts,counts): + c = context_index.setdefault(context, len(context_index)) + print "%d:%d" % (c,count), + print +if len(sys.argv) == 2: + contexts_out = open(sys.argv[1],'w') + contexts = context_index.items() + contexts.sort(key = itemgetter(1)) + for context in contexts: + print >>contexts_out, context[0] + contexts_out.close() diff --git a/gi/pyp-topics/scripts/extract_contexts.py b/gi/pyp-topics/scripts/extract_contexts.py new file mode 100755 index 00000000..b2723f2a --- /dev/null +++ b/gi/pyp-topics/scripts/extract_contexts.py @@ -0,0 +1,144 @@ +#!/usr/bin/python + +import sys,collections + +def extract_backoff(context_list, order): + assert len(context_list) == (2*order) + backoffs = [] + for i in range(1,order+1): + if i == order: + backoffs.append(([context_list[i-1]+"|"], ["|"+context_list[i]])) + else: + right_limit = 2*order-i + core = context_list[i:right_limit] + left = [context_list[i-1]+"|"*(order-i+1)] + right = ["|"*(order-i+1)+context_list[right_limit]] + backoffs.append((core, left, right)) +# print context_list, backoffs + return backoffs + +def tuple_to_str(t): + s="" + for i,x in enumerate(t): + if i > 0: s += "|" + s += str(x) + return s + +if len(sys.argv) < 3: + print "Usage: extract-contexts.py output_filename order cutoff lowercase" + exit(1) + +output_filename = sys.argv[1] +order = int(sys.argv[2]) +cutoff = 0 +if len(sys.argv) > 3: + cutoff = int(sys.argv[3]) +lowercase = False +if len(sys.argv) > 4: + lowercase = bool(sys.argv[4]) + +contexts_dict={} +contexts_list=[] +contexts_freq=collections.defaultdict(int) +contexts_backoff={} + +token_dict={} +token_list=[] +documents_dict=collections.defaultdict(dict) + +contexts_at_order = [i for i in range(order+1)] + +prefix = ["|"%i for i in range(order)] +suffix = ["|"%i for i in range(order)] + +for line in sys.stdin: + tokens = list(prefix) + tokens.extend(line.split()) + tokens.extend(suffix) + if lowercase: + tokens = map(lambda x: x.lower(), tokens) + + for i in range(order, len(tokens)-order): + context_list = [] + term="" + for j in range(i-order, i+order+1): + token,tag = tokens[j].rsplit('|',2) + if j != i: + context_list.append(token) + else: + if token not in token_dict: + token_dict[token] = len(token_dict) + token_list.append(token) + term = token_dict[token] + + context = tuple_to_str(tuple(context_list)) + + if context not in contexts_dict: + context_index = len(contexts_dict) + contexts_dict[context] = context_index + contexts_list.append(context) + contexts_at_order[0] += 1 + + # handle backoff + backoff_contexts = extract_backoff(context_list, order) + bo_indexes=[(context_index,)] +# bo_indexes=[(context,)] + for i,bo in enumerate(backoff_contexts): + factor_indexes=[] + for factor in bo: + bo_tuple = tuple_to_str(tuple(factor)) + if bo_tuple not in contexts_dict: + contexts_dict[bo_tuple] = len(contexts_dict) + contexts_list.append(bo_tuple) + contexts_at_order[i+1] += 1 +# factor_indexes.append(bo_tuple) + factor_indexes.append(contexts_dict[bo_tuple]) + bo_indexes.append(tuple(factor_indexes)) + + for i in range(len(bo_indexes)-1): + contexts_backoff[bo_indexes[i][0]] = bo_indexes[i+1] + + context_index = contexts_dict[context] + contexts_freq[context_index] += 1 + + if context_index not in documents_dict[term]: + documents_dict[term][context_index] = 1 + else: + documents_dict[term][context_index] += 1 + +term_file = open(output_filename+".terms",'w') +for t in token_list: print >>term_file, t +term_file.close() + +contexts_file = open(output_filename+".contexts",'w') +for c in contexts_list: + print >>contexts_file, c +contexts_file.close() + +data_file = open(output_filename+".data",'w') +for t in range(len(token_list)): + line="" + num_active=0 + for c in documents_dict[t]: + count = documents_dict[t][c] + if contexts_freq[c] >= cutoff: + line += (' ' + str(c) + ':' + str(count)) + num_active += 1 + if num_active > 0: + print >>data_file, "%d%s" % (num_active,line) +data_file.close() + +contexts_backoff_file = open(output_filename+".contexts_backoff",'w') +print >>contexts_backoff_file, len(contexts_list), order, +#for x in contexts_at_order: +# print >>contexts_backoff_file, x, +#print >>contexts_backoff_file +for x in range(order-1): + print >>contexts_backoff_file, 3, +print >>contexts_backoff_file, 2 + +for x in contexts_backoff: + print >>contexts_backoff_file, x, + for y in contexts_backoff[x]: print >>contexts_backoff_file, y, + print >>contexts_backoff_file +contexts_backoff_file.close() diff --git a/gi/pyp-topics/scripts/extract_contexts_test.py b/gi/pyp-topics/scripts/extract_contexts_test.py new file mode 100755 index 00000000..693b6e0b --- /dev/null +++ b/gi/pyp-topics/scripts/extract_contexts_test.py @@ -0,0 +1,72 @@ +#!/usr/bin/python + +import sys,collections + +def tuple_to_str(t): + s="" + for i,x in enumerate(t): + if i > 0: s += "|" + s += str(x) + return s + +if len(sys.argv) < 5: + print "Usage: extract-contexts_test.py output_filename vocab contexts order lowercase" + exit(1) + +output_filename = sys.argv[1] +output = open(output_filename+".test_data",'w') + +unk_term="-UNK-" +vocab_dict={} +for i,x in enumerate(file(sys.argv[2], 'r').readlines()): + vocab_dict[x.strip()]=i + +contexts_dict={} +contexts_list=[] +for i,x in enumerate(file(sys.argv[3], 'r').readlines()): + contexts_dict[x.strip()]=i + contexts_list.append(x.strip()) + +order = int(sys.argv[4]) + +lowercase = False +if len(sys.argv) > 5: + lowercase = bool(sys.argv[5]) +if lowercase: unk_term = unk_term.lower() + +prefix = ["|"%i for i in range(order)] +suffix = ["|"%i for i in range(order)] + +assert unk_term in vocab_dict +for line in sys.stdin: + tokens = list(prefix) + tokens.extend(line.split()) + tokens.extend(suffix) + if lowercase: + tokens = map(lambda x: x.lower(), tokens) + + for i in range(order, len(tokens)-order): + context_list=[] + term="" + for j in range(i-order, i+order+1): + token,tag = tokens[j].rsplit('|',2) + if j != i: + context_list.append(token) + else: + if token not in vocab_dict: + term = vocab_dict[unk_term] + else: + term = vocab_dict[token] + context = tuple_to_str(context_list) + if context not in contexts_dict: + contexts_dict[context] = len(contexts_dict) + contexts_list.append(context) + context_index = contexts_dict[context] + print >>output, "%d:%d" % (term,context_index), + print >>output +output.close() + +contexts_file = open(output_filename+".test_contexts",'w') +for c in contexts_list: + print >>contexts_file, c +contexts_file.close() diff --git a/gi/pyp-topics/scripts/extract_leaves.py b/gi/pyp-topics/scripts/extract_leaves.py new file mode 100755 index 00000000..14783b36 --- /dev/null +++ b/gi/pyp-topics/scripts/extract_leaves.py @@ -0,0 +1,49 @@ +#!/usr/bin/python + +import nltk +import nltk.probability +import sys +import getopt + +lexicalise=False +rm_traces=False +cutoff=100 +length_cutoff=10000 +try: + opts, args = getopt.getopt(sys.argv[1:], "hs:c:l", ["help", "lexicalise", "cutoff","sentence-length","remove-traces"]) +except getopt.GetoptError: + print "Usage: extract_leaves.py [-lsc]" + sys.exit(2) +for opt, arg in opts: + if opt in ("-h", "--help"): + print "Usage: extract_leaves.py [-lsc]" + sys.exit() + elif opt in ("-l", "--lexicalise"): + lexicalise = True + elif opt in ("-c", "--cutoff"): + cutoff = int(arg) + elif opt in ("-s", "--sentence-length"): + length_cutoff = int(arg) + elif opt in ("--remove-traces"): + rm_traces = True + +token_freq = nltk.probability.FreqDist() +lines = [] +for line in sys.stdin: + t = nltk.Tree.parse(line) + pos = t.pos() + if len(pos) <= length_cutoff: + lines.append(pos) + for token, tag in pos: + token_freq.inc(token) + +for line in lines: + for token,tag in line: + if not (rm_traces and tag == "-NONE-"): + if lexicalise: + if token_freq[token] < cutoff: + token = '-UNK-' + print '%s|%s' % (token,tag), + else: + print '%s' % tag, + print diff --git a/gi/pyp-topics/scripts/map-documents.py b/gi/pyp-topics/scripts/map-documents.py new file mode 100755 index 00000000..703de312 --- /dev/null +++ b/gi/pyp-topics/scripts/map-documents.py @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import sys + +if len(sys.argv) != 2: + print "Usage: map-documents.py vocab-file" + exit(1) + +vocab = file(sys.argv[1], 'r').readlines() +term_dict = map(lambda x: x.strip(), vocab) + +for line in sys.stdin: + tokens = line.split() + for token in tokens: + elements = token.split(':') + if len(elements) == 1: + print "%s" % (term_dict[int(elements[0])]), + else: + print "%s:%s" % (term_dict[int(elements[0])], elements[1]), + print diff --git a/gi/pyp-topics/scripts/map-terms.py b/gi/pyp-topics/scripts/map-terms.py new file mode 100755 index 00000000..eb0298d7 --- /dev/null +++ b/gi/pyp-topics/scripts/map-terms.py @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import sys + +if len(sys.argv) != 2: + print "Usage: map-terms.py vocab-file" + exit(1) + +vocab = file(sys.argv[1], 'r').readlines() +term_dict = map(lambda x: x.strip().replace(' ','_'), vocab) + +for line in sys.stdin: + tokens = line.split() + for token in tokens: + elements = token.split(':') + if len(elements) == 1: + print "%s" % (term_dict[int(elements[0])]), + else: + print "%s:%s" % (term_dict[int(elements[0])], elements[1]), + print diff --git a/gi/pyp-topics/scripts/score-mkcls.py b/gi/pyp-topics/scripts/score-mkcls.py new file mode 100755 index 00000000..6bd33fc5 --- /dev/null +++ b/gi/pyp-topics/scripts/score-mkcls.py @@ -0,0 +1,61 @@ +#!/usr/bin/python + +import sys +from collections import defaultdict + +def dict_max(d): + max_val=-1 + max_key=None + for k in d: + if d[k] > max_val: + max_val = d[k] + max_key = k + assert max_key + return max_key + +if len(sys.argv) != 3: + print "Usage: score-mkcls.py gold classes" + exit(1) + +gold_file=open(sys.argv[1],'r') + +term_to_topics = {} +for line in open(sys.argv[2],'r'): + term,cls = line.split() + term_to_topics[term] = cls + +gold_to_topics = defaultdict(dict) +topics_to_gold = defaultdict(dict) + +for gold_line in gold_file: + gold_tokens = gold_line.split() + for gold_token in gold_tokens: + gold_term,gold_tag = gold_token.rsplit('|',1) + pred_token = term_to_topics[gold_term] + gold_to_topics[gold_tag][pred_token] \ + = gold_to_topics[gold_tag].get(pred_token, 0) + 1 + topics_to_gold[pred_token][gold_tag] \ + = topics_to_gold[pred_token].get(gold_tag, 0) + 1 + +pred=0 +correct=0 +gold_file=open(sys.argv[1],'r') +for gold_line in gold_file: + gold_tokens = gold_line.split() + + for gold_token in gold_tokens: + gold_term,gold_tag = gold_token.rsplit('|',1) + pred_token = term_to_topics[gold_term] + print "%s|%s|%s" % (gold_token, pred_token, dict_max(topics_to_gold[pred_token])), + pred += 1 + if gold_tag == dict_max(topics_to_gold[pred_token]): + correct += 1 + print +print >>sys.stderr, "Many-to-One Accuracy = %f" % (float(correct) / pred) +#for x in gold_to_topics: +# print x,dict_max(gold_to_topics[x]) +#print "###################################################" +#for x in range(len(topics_to_gold)): +# print x,dict_max(topics_to_gold[str(x)]) +# print x,topics_to_gold[str(x)] +#print term_to_topics diff --git a/gi/pyp-topics/scripts/score-topics.py b/gi/pyp-topics/scripts/score-topics.py new file mode 100755 index 00000000..1d8a1fcd --- /dev/null +++ b/gi/pyp-topics/scripts/score-topics.py @@ -0,0 +1,64 @@ +#!/usr/bin/python + +import sys +from collections import defaultdict + +def dict_max(d): + max_val=-1 + max_key=None + for k in d: + if d[k] > max_val: + max_val = d[k] + max_key = k + assert max_key + return max_key + +if len(sys.argv) != 3: + print "Usage: score-topics.py gold pred" + exit(1) + +gold_file=open(sys.argv[1],'r') +pred_file=open(sys.argv[2],'r') + +gold_to_topics = defaultdict(dict) +topics_to_gold = defaultdict(dict) +term_to_topics = defaultdict(dict) + +for gold_line,pred_line in zip(gold_file,pred_file): + gold_tokens = gold_line.split() + pred_tokens = pred_line.split() + assert len(gold_tokens) == len(pred_tokens) + + for gold_token,pred_token in zip(gold_tokens,pred_tokens): + gold_term,gold_tag = gold_token.rsplit('|',1) + gold_to_topics[gold_tag][pred_token] \ + = gold_to_topics[gold_tag].get(pred_token, 0) + 1 + term_to_topics[gold_term][pred_token] \ + = term_to_topics[gold_term].get(pred_token, 0) + 1 + topics_to_gold[pred_token][gold_tag] \ + = topics_to_gold[pred_token].get(gold_tag, 0) + 1 + +pred=0 +correct=0 +gold_file=open(sys.argv[1],'r') +pred_file=open(sys.argv[2],'r') +for gold_line,pred_line in zip(gold_file,pred_file): + gold_tokens = gold_line.split() + pred_tokens = pred_line.split() + + for gold_token,pred_token in zip(gold_tokens,pred_tokens): + gold_term,gold_tag = gold_token.rsplit('|',1) +# print "%s|%s" % (gold_token, dict_max(gold_to_topics[gold_tag])), + print "%s|%s|%s" % (gold_token, pred_token, dict_max(topics_to_gold[pred_token])), + pred += 1 + if gold_tag == dict_max(topics_to_gold[pred_token]): + correct += 1 + print +print >>sys.stderr, "Many-to-One Accuracy = %f" % (float(correct) / pred) +#for x in gold_to_topics: +# print x,dict_max(gold_to_topics[x]) +#print "###################################################" +#for x in range(len(topics_to_gold)): +# print x,dict_max(topics_to_gold[str(x)]) +# print x,topics_to_gold[str(x)] +#print term_to_topics diff --git a/gi/pyp-topics/scripts/spans2labels.py b/gi/pyp-topics/scripts/spans2labels.py new file mode 100755 index 00000000..b523e191 --- /dev/null +++ b/gi/pyp-topics/scripts/spans2labels.py @@ -0,0 +1,46 @@ +#!/usr/bin/python + +import sys +from operator import itemgetter + +if len(sys.argv) != 4: + print "Usage: spans2labels.py phrase_index context_index phrase_context_index" + exit(1) + +phrase_index = dict(map(lambda x: (x[1].strip(),x[0]), enumerate(file(sys.argv[1], 'r').readlines()))) +context_index = dict(map(lambda x: (x[1].strip(),x[0]), enumerate(file(sys.argv[2], 'r').readlines()))) + +phrase_context_index = {} +for i,line in enumerate(file(sys.argv[3], 'r').readlines()): + for c,l in map(lambda x: x.split(':'), line.split()[1:]): + phrase_context_index[(int(i),int(c))] = l + +for line in sys.stdin: + line_segments = line.split('|||') + source = [''] + line_segments[0].split() + [''] + target = [''] + line_segments[1].split() + [''] + phrases = [ [int(i) for i in x.split('-')] for x in line_segments[2].split()] + +# for x in source[1:-1]: +# print x, +# print "|||", +# for x in target[1:-1]: +# print x, + print "|||", + + for s1,s2,t1,t2 in phrases: + s1 += 1 + s2 += 1 + t1 += 1 + t2 += 1 + + phrase = reduce(lambda x, y: x+y+" ", target[t1:t2], "").strip() + context = "%s %s" % (target[t1-1], target[t2]) + + pi = phrase_index[phrase] + ci = context_index[context] + label = phrase_context_index[(pi,ci)] + print "%s-%s:%s" % (t1-1,t2-1,label), +# print phrase, pi, context, ci +# print phrase_context_index[(pi,ci)] + print diff --git a/gi/pyp-topics/scripts/topics.py b/gi/pyp-topics/scripts/topics.py new file mode 100755 index 00000000..0db1af71 --- /dev/null +++ b/gi/pyp-topics/scripts/topics.py @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import sys + +if len(sys.argv) != 2: + print "Usage: topics.py words-per-topic" + exit(1) + +for t,line in enumerate(sys.stdin): + tokens = line.split() + terms = [] + for token in tokens: + elements = token.rsplit(':',1) + terms.append((int(elements[1]),elements[0])) + terms.sort() + terms.reverse() + + print "Topic %d:" % t + map(lambda (x,y) : sys.stdout.write(" %s:%s\n" % (y,x)), terms[:int(sys.argv[1])]) + print diff --git a/gi/pyp-topics/src/Makefile b/gi/pyp-topics/src/Makefile new file mode 100644 index 00000000..1d1391ae --- /dev/null +++ b/gi/pyp-topics/src/Makefile @@ -0,0 +1,30 @@ +-include makefile.darwin + +local_objs = ../obj/corpus.o ../obj/gzstream.o ../obj/mt19937ar.o ../obj/pyp-topics.o ../obj/gammadist.o + +all: ../bin/pyp-topics-train + +-include makefile.depend + +#-----------------------# +# Local stuff +#-----------------------# + +../bin/pyp-topics-train: ../obj/train.o $(local_objs) + $(CXX) -o $@ $^ $(LDFLAGS) + +../obj/%.o: %.cc + ${CXX} $(CXXFLAGS) -c $< -o $@ + +../obj/%.o: %.c + ${CC} $(CFLAGS) -c $< -o $@ + +.PHONY: depend +depend: + $(CXX) -MM $(CXXFLAGS) *.cc | sed 's/^\(.*\.o:\)/obj\/\1/' > makefile.depend + +clean: + rm -f ../obj/*.o + +#clobber: clean +# rm makefile.depend ../bin/${ARCH}/* diff --git a/gi/pyp-topics/src/corpus.cc b/gi/pyp-topics/src/corpus.cc new file mode 100644 index 00000000..93910ea3 --- /dev/null +++ b/gi/pyp-topics/src/corpus.cc @@ -0,0 +1,103 @@ +#include +#include +#include + +#include "corpus.hh" +#include "gzstream.hh" + +using namespace std; + +////////////////////////////////////////////////// +// Corpus +////////////////////////////////////////////////// + +Corpus::Corpus() {} + +unsigned Corpus::read(const std::string &filename) { + m_num_terms = 0; + m_num_types = 0; + std::set seen_types; + + igzstream in(filename.c_str()); + + string buf; + int token; + unsigned count=0; + while (getline(in, buf)) { + Document* doc(new Document()); + istringstream ss(buf); + + ss >> token; // the number of unique terms + + char delimeter; + int count; + while(ss >> token >> delimeter >> count) { + for (int i=0; ipush_back(token); + m_num_terms += count; + seen_types.insert(token); + } + + m_documents.push_back(doc); + count++; + } + + m_num_types = seen_types.size(); + + return count; +} + +////////////////////////////////////////////////// +// TestCorpus +////////////////////////////////////////////////// + +TestCorpus::TestCorpus() {} + +void TestCorpus::read(const std::string &filename) { + igzstream in(filename.c_str()); + + string buf; + Term term; + DocumentId doc; + char delimeter; + while (getline(in, buf)) { + DocumentTerms* line(new DocumentTerms()); + istringstream ss(buf); + + while(ss >> doc >> delimeter >> term) + line->push_back(DocumentTerm(doc, term)); + + m_lines.push_back(line); + } +} + +////////////////////////////////////////////////// +// TermBackoff +////////////////////////////////////////////////// + +void TermBackoff::read(const std::string &filename) { + igzstream in(filename.c_str()); + + string buf; + int num_terms; + getline(in, buf); + istringstream ss(buf); + ss >> num_terms >> m_backoff_order; + + m_dict.resize(num_terms, -1); + for (int i=0; i> count; + m_terms_at_order.push_back(count); + } + + Term term, backoff; + while (getline(in, buf)) { + istringstream ss(buf); + ss >> term >> backoff; + + assert(term < num_terms); + assert(term >= 0); + + m_dict[term] = backoff; + } +} diff --git a/gi/pyp-topics/src/corpus.hh b/gi/pyp-topics/src/corpus.hh new file mode 100644 index 00000000..3dd17cf9 --- /dev/null +++ b/gi/pyp-topics/src/corpus.hh @@ -0,0 +1,101 @@ +#ifndef _CORPUS_HH +#define _CORPUS_HH + +#include +#include +#include + +#include + +//////////////////////////////////////////////////////////////// +// Corpus +//////////////////////////////////////////////////////////////// +typedef int Term; + +typedef std::vector Document; +typedef std::vector Terms; + +class Corpus { +public: + typedef boost::ptr_vector::const_iterator const_iterator; + +public: + Corpus(); + ~Corpus() {} + + unsigned read(const std::string &filename); + + const_iterator begin() const { return m_documents.begin(); } + const_iterator end() const { return m_documents.end(); } + + int num_documents() const { return m_documents.size(); } + int num_terms() const { return m_num_terms; } + int num_types() const { return m_num_types; } + +protected: + int m_num_terms, m_num_types; + boost::ptr_vector m_documents; +}; + +typedef int DocumentId; +struct DocumentTerm { + DocumentTerm(DocumentId d, Term t) : term(t), doc(d) {} + Term term; + DocumentId doc; +}; +typedef std::vector DocumentTerms; + +class TestCorpus { +public: + typedef boost::ptr_vector::const_iterator const_iterator; + +public: + TestCorpus(); + ~TestCorpus() {} + + void read(const std::string &filename); + + const_iterator begin() const { return m_lines.begin(); } + const_iterator end() const { return m_lines.end(); } + + int num_instances() const { return m_lines.size(); } + +protected: + boost::ptr_vector m_lines; +}; + +class TermBackoff { +public: + typedef std::vector dictionary_type; + typedef dictionary_type::const_iterator const_iterator; + +public: + TermBackoff() : m_backoff_order(-1) {} + ~TermBackoff() {} + + void read(const std::string &filename); + + const_iterator begin() const { return m_dict.begin(); } + const_iterator end() const { return m_dict.end(); } + + const Term& operator[](const Term& t) const { + assert(t < static_cast(m_dict.size())); + return m_dict[t]; + } + + int order() const { return m_backoff_order; } +// int levels() const { return m_terms_at_order.size(); } + bool is_null(const Term& term) const { return term < 0; } + int terms_at_level(int level) const { + assert (level < (int)m_terms_at_order.size()); + return m_terms_at_order[level]; + } + + int size() const { return m_dict.size(); } + +protected: + dictionary_type m_dict; + int m_backoff_order; + std::vector m_terms_at_order; +}; +#endif // _CORPUS_HH diff --git a/gi/pyp-topics/src/gammadist.c b/gi/pyp-topics/src/gammadist.c new file mode 100644 index 00000000..4e260db8 --- /dev/null +++ b/gi/pyp-topics/src/gammadist.c @@ -0,0 +1,247 @@ +/* gammadist.c -- computes probability of samples under / produces samples from a Gamma distribution + * + * Mark Johnson, 22nd March 2008 + * + * WARNING: you need to set the flag -std=c99 to compile + * + * gammavariate() was translated from random.py in Python library + * + * The Gamma distribution is: + * + * Gamma(x | alpha, beta) = pow(x/beta, alpha-1) * exp(-x/beta) / (gamma(alpha)*beta) + * + * shape parameter alpha > 0 (also called c), scale parameter beta > 0 (also called s); + * mean is alpha*beta, variance is alpha*beta**2 + * + * Note that many parameterizations of the Gamma function are in terms of an _inverse_ + * scale parameter beta, which is the inverse of the beta given here. + * + * To define a main() that tests the routines, uncomment the following #define: + */ +/* #define GAMMATEST */ + +#include +#include + +#include "gammadist.h" +#include "mt19937ar.h" + +/* gammadist() returns the probability density of x under a Gamma(alpha,beta) + * distribution + */ + +long double gammadist(long double x, long double alpha, long double beta) { + assert(alpha > 0); + assert(beta > 0); + return pow(x/beta, alpha-1) * exp(-x/beta) / (tgamma(alpha)*beta); +} + +/* lgammadist() returns the log probability density of x under a Gamma(alpha,beta) + * distribution + */ + +long double lgammadist(long double x, long double alpha, long double beta) { + assert(alpha > 0); + assert(beta > 0); + return (alpha-1)*log(x) - alpha*log(beta) - x/beta - lgamma(alpha); +} + +/* This definition of gammavariate is from Python code in + * the Python random module. + */ + +long double gammavariate(long double alpha, long double beta) { + + assert(alpha > 0); + assert(beta > 0); + + if (alpha > 1.0) { + + /* Uses R.C.H. Cheng, "The generation of Gamma variables with + non-integral shape parameters", Applied Statistics, (1977), 26, + No. 1, p71-74 */ + + long double ainv = sqrt(2.0 * alpha - 1.0); + long double bbb = alpha - log(4.0); + long double ccc = alpha + ainv; + + while (1) { + long double u1 = mt_genrand_real3(); + if (u1 > 1e-7 || u1 < 0.9999999) { + long double u2 = 1.0 - mt_genrand_real3(); + long double v = log(u1/(1.0-u1))/ainv; + long double x = alpha*exp(v); + long double z = u1*u1*u2; + long double r = bbb+ccc*v-x; + if (r + (1.0+log(4.5)) - 4.5*z >= 0.0 || r >= log(z)) + return x * beta; + } + } + } + else if (alpha == 1.0) { + long double u = mt_genrand_real3(); + while (u <= 1e-7) + u = mt_genrand_real3(); + return -log(u) * beta; + } + else { + /* alpha is between 0 and 1 (exclusive) + Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle */ + + while (1) { + long double u = mt_genrand_real3(); + long double b = (exp(1) + alpha)/exp(1); + long double p = b*u; + long double x = (p <= 1.0) ? pow(p, 1.0/alpha) : -log((b-p)/alpha); + long double u1 = mt_genrand_real3(); + if (! (((p <= 1.0) && (u1 > exp(-x))) || + ((p > 1.0) && (u1 > pow(x, alpha - 1.0))))) + return x * beta; + } + } +} + +/* betadist() returns the probability density of x under a Beta(alpha,beta) + * distribution. + */ + +long double betadist(long double x, long double alpha, long double beta) { + assert(x >= 0); + assert(x <= 1); + assert(alpha > 0); + assert(beta > 0); + return pow(x,alpha-1)*pow(1-x,beta-1)*tgamma(alpha+beta)/(tgamma(alpha)*tgamma(beta)); +} + +/* lbetadist() returns the log probability density of x under a Beta(alpha,beta) + * distribution. + */ + +long double lbetadist(long double x, long double alpha, long double beta) { + assert(x > 0); + assert(x < 1); + assert(alpha > 0); + assert(beta > 0); + return (alpha-1)*log(x)+(beta-1)*log(1-x)+lgamma(alpha+beta)-lgamma(alpha)-lgamma(beta); +} + +/* betavariate() generates a sample from a Beta distribution with + * parameters alpha and beta. + * + * 0 < alpha < 1, 0 < beta < 1, mean is alpha/(alpha+beta) + */ + +long double betavariate(long double alpha, long double beta) { + long double x = gammavariate(alpha, 1); + long double y = gammavariate(beta, 1); + return x/(x+y); +} + +#ifdef GAMMATEST +#include + +int main(int argc, char **argv) { + int iteration, niterations = 1000; + + for (iteration = 0; iteration < niterations; ++iteration) { + long double alpha = 100*mt_genrand_real3(); + long double gv = gammavariate(alpha, 1); + long double pgv = gammadist(gv, alpha, 1); + long double pgvl = exp(lgammadist(gv, alpha, 1)); + fprintf(stderr, "iteration = %d, gammavariate(%lg,1) = %lg, gammadist(%lg,%lg,1) = %lg, exp(lgammadist(%lg,%lg,1) = %lg\n", + iteration, alpha, gv, gv, alpha, pgv, gv, alpha, pgvl); + } + return 0; +} + +#endif /* GAMMATEST */ + + +/* Other routines I tried, but which weren't as good as the ones above */ + +#if 0 + +/*! gammavariate() returns samples from a Gamma distribution + *! where alpha is the shape parameter and beta is the scale + *! parameter, using the algorithm described on p. 94 of + *! Gentle (1998) Random Number Generation and Monte Carlo Methods, + *! Springer. + */ + +long double gammavariate(long double alpha) { + + assert(alpha > 0); + + if (alpha > 1.0) { + while (1) { + long double u1 = mt_genrand_real3(); + long double u2 = mt_genrand_real3(); + long double v = (alpha - 1/(6*alpha))*u1/(alpha-1)*u2; + if (2*(u2-1)/(alpha-1) + v + 1/v <= 2 + || 2*log(u2)/(alpha-1) - log(v) + v <= 1) + return (alpha-1)*v; + } + } else if (alpha < 1.0) { + while (1) { + long double t = 0.07 + 0.75*sqrt(1-alpha); + long double b = alpha + exp(-t)*alpha/t; + long double u1 = mt_genrand_real3(); + long double u2 = mt_genrand_real3(); + long double v = b*u1; + if (v <= 1) { + long double x = t*pow(v, 1/alpha); + if (u2 <= (2 - x)/(2 + x)) + return x; + if (u2 <= exp(-x)) + return x; + } + else { + long double x = log(t*(b-v)/alpha); + long double y = x/t; + if (u2*(alpha + y*(1-alpha)) <= 1) + return x; + if (u2 <= pow(y,alpha-1)) + return x; + } + } + } + else + return -log(mt_genrand_real3()); +} + + +/*! gammavariate() returns a deviate distributed as a gamma + *! distribution of order alpha, beta, i.e., a waiting time to the alpha'th + *! event in a Poisson process of unit mean. + *! + *! Code from Numerical Recipes + */ + +long double nr_gammavariate(long double ia) { + int j; + long double am,e,s,v1,v2,x,y; + assert(ia > 0); + if (ia < 10) { + x=1.0; + for (j=1;j<=ia;j++) + x *= mt_genrand_real3(); + x = -log(x); + } else { + do { + do { + do { + v1=mt_genrand_real3(); + v2=2.0*mt_genrand_real3()-1.0; + } while (v1*v1+v2*v2 > 1.0); + y=v2/v1; + am=ia-1; + s=sqrt(2.0*am+1.0); + x=s*y+am; + } while (x <= 0.0); + e=(1.0+y*y)*exp(am*log(x/am)-s*y); + } while (mt_genrand_real3() > e); + } + return x; +} + +#endif diff --git a/gi/pyp-topics/src/gammadist.h b/gi/pyp-topics/src/gammadist.h new file mode 100644 index 00000000..b6ad6c40 --- /dev/null +++ b/gi/pyp-topics/src/gammadist.h @@ -0,0 +1,72 @@ +/* gammadist.h -- computes probability of samples under / produces samples from a Gamma distribution + * + * Mark Johnson, 22nd March 2008 + * + * gammavariate() was translated from random.py in Python library + * + * The Gamma distribution is: + * + * Gamma(x | alpha, beta) = pow(x/beta, alpha-1) * exp(-x/beta) / (gamma(alpha)*beta) + * + * shape parameter alpha > 0 (also called c), scale parameter beta > 0 (also called s); + * mean is alpha*beta, variance is alpha*beta**2 + * + * Note that many parameterizations of the Gamma function are in terms of an _inverse_ + * scale parameter beta, which is the inverse of the beta given here. + */ + +#ifndef GAMMADIST_H +#define GAMMADIST_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* gammadist() returns the probability density of x under a Gamma(alpha,beta) + * distribution + */ + + long double gammadist(long double x, long double alpha, long double beta); + + /* lgammadist() returns the log probability density of x under a Gamma(alpha,beta) + * distribution + */ + + long double lgammadist(long double x, long double alpha, long double beta); + + /* gammavariate() generates samples from a Gamma distribution + * conditioned on the parameters alpha and beta. + * + * alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2 + * + * Warning: a few older sources define the gamma distribution in terms + * of alpha > -1.0 + */ + + long double gammavariate(long double alpha, long double beta); + + /* betadist() returns the probability density of x under a Beta(alpha,beta) + * distribution. + */ + + long double betadist(long double x, long double alpha, long double beta); + + /* lbetadist() returns the log probability density of x under a Beta(alpha,beta) + * distribution. + */ + + long double lbetadist(long double x, long double alpha, long double beta); + + /* betavariate() generates a sample from a Beta distribution with + * parameters alpha and beta. + * + * 0 < alpha < 1, 0 < beta < 1, mean is alpha/(alpha+beta) + */ + + long double betavariate(long double alpha, long double beta); + +#ifdef __cplusplus +}; +#endif + +#endif /* GAMMADIST_H */ diff --git a/gi/pyp-topics/src/gzstream.cc b/gi/pyp-topics/src/gzstream.cc new file mode 100644 index 00000000..7c4d3a12 --- /dev/null +++ b/gi/pyp-topics/src/gzstream.cc @@ -0,0 +1,165 @@ +// ============================================================================ +// gzstream, C++ iostream classes wrapping the zlib compression library. +// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// ============================================================================ +// +// File : gzstream.C +// Revision : $Revision: 1.1 $ +// Revision_date : $Date: 2006/03/30 04:05:52 $ +// Author(s) : Deepak Bandyopadhyay, Lutz Kettner +// +// Standard streambuf implementation following Nicolai Josuttis, "The +// Standard C++ Library". +// ============================================================================ + +#include "gzstream.hh" +#include +#include // for memcpy + +#ifdef GZSTREAM_NAMESPACE +namespace GZSTREAM_NAMESPACE { +#endif + +// ---------------------------------------------------------------------------- +// Internal classes to implement gzstream. See header file for user classes. +// ---------------------------------------------------------------------------- + +// -------------------------------------- +// class gzstreambuf: +// -------------------------------------- + +gzstreambuf* gzstreambuf::open( const char* name, int open_mode) { + if ( is_open()) + return (gzstreambuf*)0; + mode = open_mode; + // no append nor read/write mode + if ((mode & std::ios::ate) || (mode & std::ios::app) + || ((mode & std::ios::in) && (mode & std::ios::out))) + return (gzstreambuf*)0; + char fmode[10]; + char* fmodeptr = fmode; + if ( mode & std::ios::in) + *fmodeptr++ = 'r'; + else if ( mode & std::ios::out) + *fmodeptr++ = 'w'; + *fmodeptr++ = 'b'; + *fmodeptr = '\0'; + file = gzopen( name, fmode); + if (file == 0) + return (gzstreambuf*)0; + opened = 1; + return this; +} + +gzstreambuf * gzstreambuf::close() { + if ( is_open()) { + sync(); + opened = 0; + if ( gzclose( file) == Z_OK) + return this; + } + return (gzstreambuf*)0; +} + +int gzstreambuf::underflow() { // used for input buffer only + if ( gptr() && ( gptr() < egptr())) + return * reinterpret_cast( gptr()); + + if ( ! (mode & std::ios::in) || ! opened) + return EOF; + // Josuttis' implementation of inbuf + int n_putback = gptr() - eback(); + if ( n_putback > 4) + n_putback = 4; + memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback); + + int num = gzread( file, buffer+4, bufferSize-4); + if (num <= 0) // ERROR or EOF + return EOF; + + // reset buffer pointers + setg( buffer + (4 - n_putback), // beginning of putback area + buffer + 4, // read position + buffer + 4 + num); // end of buffer + + // return next character + return * reinterpret_cast( gptr()); +} + +int gzstreambuf::flush_buffer() { + // Separate the writing of the buffer from overflow() and + // sync() operation. + int w = pptr() - pbase(); + if ( gzwrite( file, pbase(), w) != w) + return EOF; + pbump( -w); + return w; +} + +int gzstreambuf::overflow( int c) { // used for output buffer only + if ( ! ( mode & std::ios::out) || ! opened) + return EOF; + if (c != EOF) { + *pptr() = c; + pbump(1); + } + if ( flush_buffer() == EOF) + return EOF; + return c; +} + +int gzstreambuf::sync() { + // Changed to use flush_buffer() instead of overflow( EOF) + // which caused improper behavior with std::endl and flush(), + // bug reported by Vincent Ricard. + if ( pptr() && pptr() > pbase()) { + if ( flush_buffer() == EOF) + return -1; + } + return 0; +} + +// -------------------------------------- +// class gzstreambase: +// -------------------------------------- + +gzstreambase::gzstreambase( const char* name, int mode) { + init( &buf); + open( name, mode); +} + +gzstreambase::~gzstreambase() { + buf.close(); +} + +void gzstreambase::open( const char* name, int open_mode) { + if ( ! buf.open( name, open_mode)) + clear( rdstate() | std::ios::badbit); +} + +void gzstreambase::close() { + if ( buf.is_open()) + if ( ! buf.close()) + clear( rdstate() | std::ios::badbit); +} + +#ifdef GZSTREAM_NAMESPACE +} // namespace GZSTREAM_NAMESPACE +#endif + +// ============================================================================ +// EOF // diff --git a/gi/pyp-topics/src/gzstream.hh b/gi/pyp-topics/src/gzstream.hh new file mode 100644 index 00000000..ad9785fd --- /dev/null +++ b/gi/pyp-topics/src/gzstream.hh @@ -0,0 +1,121 @@ +// ============================================================================ +// gzstream, C++ iostream classes wrapping the zlib compression library. +// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// ============================================================================ +// +// File : gzstream.h +// Revision : $Revision: 1.1 $ +// Revision_date : $Date: 2006/03/30 04:05:52 $ +// Author(s) : Deepak Bandyopadhyay, Lutz Kettner +// +// Standard streambuf implementation following Nicolai Josuttis, "The +// Standard C++ Library". +// ============================================================================ + +#ifndef GZSTREAM_H +#define GZSTREAM_H 1 + +// standard C++ with new header file names and std:: namespace +#include +#include +#include + +#ifdef GZSTREAM_NAMESPACE +namespace GZSTREAM_NAMESPACE { +#endif + +// ---------------------------------------------------------------------------- +// Internal classes to implement gzstream. See below for user classes. +// ---------------------------------------------------------------------------- + +class gzstreambuf : public std::streambuf { +private: + static const int bufferSize = 47+256; // size of data buff + // totals 512 bytes under g++ for igzstream at the end. + + gzFile file; // file handle for compressed file + char buffer[bufferSize]; // data buffer + char opened; // open/close state of stream + int mode; // I/O mode + + int flush_buffer(); +public: + gzstreambuf() : opened(0) { + setp( buffer, buffer + (bufferSize-1)); + setg( buffer + 4, // beginning of putback area + buffer + 4, // read position + buffer + 4); // end position + // ASSERT: both input & output capabilities will not be used together + } + int is_open() { return opened; } + gzstreambuf* open( const char* name, int open_mode); + gzstreambuf* close(); + ~gzstreambuf() { close(); } + + virtual int overflow( int c = EOF); + virtual int underflow(); + virtual int sync(); +}; + +class gzstreambase : virtual public std::ios { +protected: + gzstreambuf buf; +public: + gzstreambase() { init(&buf); } + gzstreambase( const char* name, int open_mode); + ~gzstreambase(); + void open( const char* name, int open_mode); + void close(); + gzstreambuf* rdbuf() { return &buf; } +}; + +// ---------------------------------------------------------------------------- +// User classes. Use igzstream and ogzstream analogously to ifstream and +// ofstream respectively. They read and write files based on the gz* +// function interface of the zlib. Files are compatible with gzip compression. +// ---------------------------------------------------------------------------- + +class igzstream : public gzstreambase, public std::istream { +public: + igzstream() : std::istream( &buf) {} + igzstream( const char* name, int open_mode = std::ios::in) + : gzstreambase( name, open_mode), std::istream( &buf) {} + gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } + void open( const char* name, int open_mode = std::ios::in) { + gzstreambase::open( name, open_mode); + } +}; + +class ogzstream : public gzstreambase, public std::ostream { +public: + ogzstream() : std::ostream( &buf) {} + ogzstream( const char* name, int mode = std::ios::out) + : gzstreambase( name, mode), std::ostream( &buf) {} + gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); } + void open( const char* name, int open_mode = std::ios::out) { + gzstreambase::open( name, open_mode); + } +}; + +#ifdef GZSTREAM_NAMESPACE +} // namespace GZSTREAM_NAMESPACE +#endif + +#endif // GZSTREAM_H +// ============================================================================ +// EOF // + diff --git a/gi/pyp-topics/src/log_add.h b/gi/pyp-topics/src/log_add.h new file mode 100644 index 00000000..e0620c5a --- /dev/null +++ b/gi/pyp-topics/src/log_add.h @@ -0,0 +1,30 @@ +#ifndef log_add_hh +#define log_add_hh + +#include +#include +#include +#include + +template +struct Log +{ + static T zero() { return -std::numeric_limits::infinity(); } + + static T add(T l1, T l2) + { + if (l1 == zero()) return l2; + if (l1 > l2) + return l1 + std::log(1 + exp(l2 - l1)); + else + return l2 + std::log(1 + exp(l1 - l2)); + } + + static T subtract(T l1, T l2) + { + //std::assert(l1 >= l2); + return l1 + log(1 - exp(l2 - l1)); + } +}; + +#endif diff --git a/gi/pyp-topics/src/makefile.darwin b/gi/pyp-topics/src/makefile.darwin new file mode 100644 index 00000000..af608fd8 --- /dev/null +++ b/gi/pyp-topics/src/makefile.darwin @@ -0,0 +1,15 @@ +CC = /usr/bin/gcc +CXX = /usr/bin/g++ +LD = /usr/bin/g++ +FC=/usr/bin/g77 + +ARCH=i686-m64 +CXXFLAGS = -m64 -Wall -I/Users/pblunsom/packages/include +CFLAGS = -m64 -Wall -I/Users/pblunsom/packages/include +FFLAGS = -m64 -Wall +LDFLAGS = -L/Users/pblunsom/packages/lib -lboost_program_options -lm -lz + +FFLAGS += -g -O3 -funroll-loops #-pg +CFLAGS += -g -O3 -funroll-loops #-pg +CXXFLAGS += -g -O3 -funroll-loops #-pg +LDFLAGS += -g -O3 -funroll-loops #-pg diff --git a/gi/pyp-topics/src/makefile.depend b/gi/pyp-topics/src/makefile.depend new file mode 100644 index 00000000..89bafcf6 --- /dev/null +++ b/gi/pyp-topics/src/makefile.depend @@ -0,0 +1,1250 @@ +obj/corpus.o: corpus.cc corpus.hh \ + /Users/pblunsom/packages/include/boost/ptr_container/ptr_vector.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/ptr_sequence_adapter.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/reversible_ptr_container.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/throw_exception.hpp \ + /Users/pblunsom/packages/include/boost/assert.hpp \ + /Users/pblunsom/packages/include/boost/config.hpp \ + /Users/pblunsom/packages/include/boost/config/user.hpp \ + /Users/pblunsom/packages/include/boost/config/select_compiler_config.hpp \ + /Users/pblunsom/packages/include/boost/config/compiler/gcc.hpp \ + /Users/pblunsom/packages/include/boost/config/select_stdlib_config.hpp \ + /Users/pblunsom/packages/include/boost/config/no_tr1/utility.hpp \ + /Users/pblunsom/packages/include/boost/config/stdlib/libstdcpp3.hpp \ + /Users/pblunsom/packages/include/boost/config/select_platform_config.hpp \ + /Users/pblunsom/packages/include/boost/config/platform/macos.hpp \ + /Users/pblunsom/packages/include/boost/config/posix_features.hpp \ + /Users/pblunsom/packages/include/boost/config/suffix.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/scoped_deleter.hpp \ + /Users/pblunsom/packages/include/boost/scoped_array.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/scoped_array.hpp \ + /Users/pblunsom/packages/include/boost/checked_delete.hpp \ + /Users/pblunsom/packages/include/boost/detail/workaround.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/operator_bool.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/static_move_ptr.hpp \ + /Users/pblunsom/packages/include/boost/compressed_pair.hpp \ + /Users/pblunsom/packages/include/boost/detail/compressed_pair.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_cv.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/broken_compiler_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/lambda_support.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/ttp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/msvc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/gcc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/workaround.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/ctps.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/cv_traits_impl.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/type_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/template_arity_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/int.hpp \ + /Users/pblunsom/packages/include/boost/mpl/int_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/adl_barrier.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/adl.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/intel.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/nttp_decl.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/nttp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/integral_wrapper.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c_tag.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/static_constant.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/static_cast.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/config/config.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/template_arity_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/params.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/preprocessor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comma_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/comma_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/iif.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bool.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/empty.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/comma.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repeat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/repeat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/error.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/auto_rec.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/eat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/inc.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/inc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/overload_resolution.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/type_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_empty.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_convertible.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/intrinsics.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/config.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/yes_no_type.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_array.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/bool_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/integral_constant.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bool.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bool_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c_fwd.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/bool_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/ice.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_or.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_and.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_not.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_eq.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_arithmetic.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_integral.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_float.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_void.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_abstract.hpp \ + /Users/pblunsom/packages/include/boost/static_assert.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_class.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_union.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_same.hpp \ + /Users/pblunsom/packages/include/boost/call_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/call_traits.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_member_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_member_function_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/default_deleter.hpp \ + /Users/pblunsom/packages/include/boost/mpl/if.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/value_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/integral.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/eti.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/lambda_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/void_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/lambda_arity_param.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/dtp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/enum.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/def_params_tail.hpp \ + /Users/pblunsom/packages/include/boost/mpl/limits/arity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/and.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitand.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/identity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/identity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/empty.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/add.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/dec.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/while.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/detail/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/expr_iif.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/adt.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/is_binary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/check.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/compl.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/detail/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/detail/while.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/sub.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_bounds.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/is_convertible.hpp \ + /Users/pblunsom/packages/include/boost/mpl/and.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/use_preprocessed.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/nested_type_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/include_preprocessed.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/compiler.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/stringize.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/and.hpp \ + /Users/pblunsom/packages/include/boost/mpl/identity.hpp \ + /Users/pblunsom/packages/include/boost/utility/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/move.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/exception.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/clone_allocator.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/nullable.hpp \ + /Users/pblunsom/packages/include/boost/mpl/eval_if.hpp \ + /Users/pblunsom/packages/include/boost/range/functions.hpp \ + /Users/pblunsom/packages/include/boost/range/begin.hpp \ + /Users/pblunsom/packages/include/boost/range/config.hpp \ + /Users/pblunsom/packages/include/boost/range/iterator.hpp \ + /Users/pblunsom/packages/include/boost/range/mutable_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/iterator.hpp \ + /Users/pblunsom/packages/include/boost/range/const_iterator.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_const.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_volatile.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_const.hpp \ + /Users/pblunsom/packages/include/boost/range/end.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/implementation_help.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/common.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/sfinae.hpp \ + /Users/pblunsom/packages/include/boost/range/size.hpp \ + /Users/pblunsom/packages/include/boost/range/difference_type.hpp \ + /Users/pblunsom/packages/include/boost/range/distance.hpp \ + /Users/pblunsom/packages/include/boost/range/empty.hpp \ + /Users/pblunsom/packages/include/boost/range/rbegin.hpp \ + /Users/pblunsom/packages/include/boost/range/reverse_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator/reverse_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator.hpp \ + /Users/pblunsom/packages/include/boost/utility.hpp \ + /Users/pblunsom/packages/include/boost/utility/addressof.hpp \ + /Users/pblunsom/packages/include/boost/utility/base_from_member.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/rem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/repeat_from_to.hpp \ + /Users/pblunsom/packages/include/boost/utility/binary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/deduce_d.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/transform.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/mod.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/detail/div_base.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/less_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/not.hpp \ + /Users/pblunsom/packages/include/boost/next_prior.hpp \ + /Users/pblunsom/packages/include/boost/noncopyable.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_adaptor.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_categories.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/config_def.hpp \ + /Users/pblunsom/packages/include/boost/mpl/placeholders.hpp \ + /Users/pblunsom/packages/include/boost/mpl/arg.hpp \ + /Users/pblunsom/packages/include/boost/mpl/arg_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_assert.hpp \ + /Users/pblunsom/packages/include/boost/mpl/assert.hpp \ + /Users/pblunsom/packages/include/boost/mpl/not.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/yes_no.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/arrays.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/pp_counter.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arity_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arg_typedef.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/arg.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/config_undef.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_facade.hpp \ + /Users/pblunsom/packages/include/boost/iterator/interoperable.hpp \ + /Users/pblunsom/packages/include/boost/mpl/or.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/or.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/facade_iterator_category.hpp \ + /Users/pblunsom/packages/include/boost/detail/indirect_traits.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_function.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/false_result.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/is_function_ptr_helper.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_pointer.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/implicit_cast.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_const.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_pod.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_scalar.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_enum.hpp \ + /Users/pblunsom/packages/include/boost/mpl/always.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply_wrap.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/has_apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/has_xxx.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/type_wrapper.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/has_xxx.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/msvc_typename.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/has_apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/msvc_never_true.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp \ + /Users/pblunsom/packages/include/boost/mpl/lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bind_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/bind_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/next.hpp \ + /Users/pblunsom/packages/include/boost/mpl/next_prior.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/common_name_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/protect.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/full_lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/quote.hpp \ + /Users/pblunsom/packages/include/boost/mpl/void.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/has_type.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/bcc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/quote.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/template_arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/full_lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply.hpp \ + /Users/pblunsom/packages/include/boost/range/rend.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/indirect_fun.hpp \ + /Users/pblunsom/packages/include/boost/utility/result_of.hpp \ + /Users/pblunsom/packages/include/boost/type.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/library.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/div.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/mul.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/data.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/insert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/push_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/not_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/pop_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/deduce_z.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/pop_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/push_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/remove.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/replace.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/greater.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/less.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/greater_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/config/limits.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/expr_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/assert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/line.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/iterate.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/slot.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/detail/def.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/apply.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/is_unary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/expand.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/intercept.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/local.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/self.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/append.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/at.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/rest_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each_i.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/for.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/detail/for.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/filter.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/first_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each_product.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/to_tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/to_list.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/transform.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitnor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitxor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/nor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/or.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/xor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/paren.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/paren_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/deduce_r.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params_with_a_default.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params_with_defaults.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection/max.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection/min.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/filter.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/first_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/detail/split.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each_i.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each_product.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/insert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/rest_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/pop_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/pop_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/push_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/push_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/remove.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/replace.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/subseq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/to_array.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/to_tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/to_seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/iter/forward1.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/bounds/lower1.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/detail/shared.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/bounds/upper1.hpp \ + /Users/pblunsom/packages/include/boost/utility/detail/result_of_iterate.hpp \ + /Users/pblunsom/packages/include/boost/pointee.hpp \ + /Users/pblunsom/packages/include/boost/detail/is_incrementable.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/void_ptr_iterator.hpp \ + gzstream.hh +obj/gzstream.o: gzstream.cc gzstream.hh +obj/pyp-topics.o: pyp-topics.cc pyp-topics.hh pyp.hh log_add.h gammadist.h \ + slice-sampler.h mt19937ar.h corpus.hh \ + /Users/pblunsom/packages/include/boost/ptr_container/ptr_vector.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/ptr_sequence_adapter.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/reversible_ptr_container.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/throw_exception.hpp \ + /Users/pblunsom/packages/include/boost/assert.hpp \ + /Users/pblunsom/packages/include/boost/config.hpp \ + /Users/pblunsom/packages/include/boost/config/user.hpp \ + /Users/pblunsom/packages/include/boost/config/select_compiler_config.hpp \ + /Users/pblunsom/packages/include/boost/config/compiler/gcc.hpp \ + /Users/pblunsom/packages/include/boost/config/select_stdlib_config.hpp \ + /Users/pblunsom/packages/include/boost/config/no_tr1/utility.hpp \ + /Users/pblunsom/packages/include/boost/config/stdlib/libstdcpp3.hpp \ + /Users/pblunsom/packages/include/boost/config/select_platform_config.hpp \ + /Users/pblunsom/packages/include/boost/config/platform/macos.hpp \ + /Users/pblunsom/packages/include/boost/config/posix_features.hpp \ + /Users/pblunsom/packages/include/boost/config/suffix.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/scoped_deleter.hpp \ + /Users/pblunsom/packages/include/boost/scoped_array.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/scoped_array.hpp \ + /Users/pblunsom/packages/include/boost/checked_delete.hpp \ + /Users/pblunsom/packages/include/boost/detail/workaround.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/operator_bool.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/static_move_ptr.hpp \ + /Users/pblunsom/packages/include/boost/compressed_pair.hpp \ + /Users/pblunsom/packages/include/boost/detail/compressed_pair.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_cv.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/broken_compiler_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/lambda_support.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/ttp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/msvc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/gcc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/workaround.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/ctps.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/cv_traits_impl.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/type_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/template_arity_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/int.hpp \ + /Users/pblunsom/packages/include/boost/mpl/int_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/adl_barrier.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/adl.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/intel.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/nttp_decl.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/nttp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/integral_wrapper.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c_tag.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/static_constant.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/static_cast.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/config/config.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/template_arity_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/params.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/preprocessor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comma_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/comma_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/iif.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bool.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/empty.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/comma.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repeat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/repeat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/error.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/auto_rec.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/eat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/inc.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/inc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/overload_resolution.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/type_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_empty.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_convertible.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/intrinsics.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/config.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/yes_no_type.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_array.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/bool_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/integral_constant.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bool.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bool_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c_fwd.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/bool_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/ice.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_or.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_and.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_not.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_eq.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_arithmetic.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_integral.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_float.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_void.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_abstract.hpp \ + /Users/pblunsom/packages/include/boost/static_assert.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_class.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_union.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_same.hpp \ + /Users/pblunsom/packages/include/boost/call_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/call_traits.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_member_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_member_function_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/default_deleter.hpp \ + /Users/pblunsom/packages/include/boost/mpl/if.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/value_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/integral.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/eti.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/lambda_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/void_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/lambda_arity_param.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/dtp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/enum.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/def_params_tail.hpp \ + /Users/pblunsom/packages/include/boost/mpl/limits/arity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/and.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitand.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/identity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/identity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/empty.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/add.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/dec.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/while.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/detail/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/expr_iif.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/adt.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/is_binary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/check.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/compl.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/detail/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/detail/while.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/sub.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_bounds.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/is_convertible.hpp \ + /Users/pblunsom/packages/include/boost/mpl/and.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/use_preprocessed.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/nested_type_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/include_preprocessed.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/compiler.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/stringize.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/and.hpp \ + /Users/pblunsom/packages/include/boost/mpl/identity.hpp \ + /Users/pblunsom/packages/include/boost/utility/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/move.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/exception.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/clone_allocator.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/nullable.hpp \ + /Users/pblunsom/packages/include/boost/mpl/eval_if.hpp \ + /Users/pblunsom/packages/include/boost/range/functions.hpp \ + /Users/pblunsom/packages/include/boost/range/begin.hpp \ + /Users/pblunsom/packages/include/boost/range/config.hpp \ + /Users/pblunsom/packages/include/boost/range/iterator.hpp \ + /Users/pblunsom/packages/include/boost/range/mutable_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/iterator.hpp \ + /Users/pblunsom/packages/include/boost/range/const_iterator.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_const.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_volatile.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_const.hpp \ + /Users/pblunsom/packages/include/boost/range/end.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/implementation_help.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/common.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/sfinae.hpp \ + /Users/pblunsom/packages/include/boost/range/size.hpp \ + /Users/pblunsom/packages/include/boost/range/difference_type.hpp \ + /Users/pblunsom/packages/include/boost/range/distance.hpp \ + /Users/pblunsom/packages/include/boost/range/empty.hpp \ + /Users/pblunsom/packages/include/boost/range/rbegin.hpp \ + /Users/pblunsom/packages/include/boost/range/reverse_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator/reverse_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator.hpp \ + /Users/pblunsom/packages/include/boost/utility.hpp \ + /Users/pblunsom/packages/include/boost/utility/addressof.hpp \ + /Users/pblunsom/packages/include/boost/utility/base_from_member.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/rem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/repeat_from_to.hpp \ + /Users/pblunsom/packages/include/boost/utility/binary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/deduce_d.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/transform.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/mod.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/detail/div_base.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/less_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/not.hpp \ + /Users/pblunsom/packages/include/boost/next_prior.hpp \ + /Users/pblunsom/packages/include/boost/noncopyable.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_adaptor.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_categories.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/config_def.hpp \ + /Users/pblunsom/packages/include/boost/mpl/placeholders.hpp \ + /Users/pblunsom/packages/include/boost/mpl/arg.hpp \ + /Users/pblunsom/packages/include/boost/mpl/arg_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_assert.hpp \ + /Users/pblunsom/packages/include/boost/mpl/assert.hpp \ + /Users/pblunsom/packages/include/boost/mpl/not.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/yes_no.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/arrays.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/pp_counter.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arity_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arg_typedef.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/arg.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/config_undef.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_facade.hpp \ + /Users/pblunsom/packages/include/boost/iterator/interoperable.hpp \ + /Users/pblunsom/packages/include/boost/mpl/or.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/or.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/facade_iterator_category.hpp \ + /Users/pblunsom/packages/include/boost/detail/indirect_traits.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_function.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/false_result.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/is_function_ptr_helper.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_pointer.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/implicit_cast.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_const.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_pod.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_scalar.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_enum.hpp \ + /Users/pblunsom/packages/include/boost/mpl/always.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply_wrap.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/has_apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/has_xxx.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/type_wrapper.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/has_xxx.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/msvc_typename.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/has_apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/msvc_never_true.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp \ + /Users/pblunsom/packages/include/boost/mpl/lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bind_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/bind_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/next.hpp \ + /Users/pblunsom/packages/include/boost/mpl/next_prior.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/common_name_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/protect.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/full_lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/quote.hpp \ + /Users/pblunsom/packages/include/boost/mpl/void.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/has_type.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/bcc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/quote.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/template_arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/full_lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply.hpp \ + /Users/pblunsom/packages/include/boost/range/rend.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/indirect_fun.hpp \ + /Users/pblunsom/packages/include/boost/utility/result_of.hpp \ + /Users/pblunsom/packages/include/boost/type.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/library.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/div.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/mul.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/data.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/insert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/push_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/not_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/pop_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/deduce_z.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/pop_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/push_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/remove.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/replace.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/greater.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/less.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/greater_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/config/limits.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/expr_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/assert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/line.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/iterate.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/slot.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/detail/def.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/apply.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/is_unary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/expand.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/intercept.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/local.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/self.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/append.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/at.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/rest_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each_i.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/for.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/detail/for.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/filter.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/first_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each_product.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/to_tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/to_list.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/transform.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitnor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitxor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/nor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/or.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/xor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/paren.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/paren_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/deduce_r.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params_with_a_default.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params_with_defaults.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection/max.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection/min.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/filter.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/first_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/detail/split.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each_i.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each_product.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/insert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/rest_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/pop_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/pop_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/push_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/push_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/remove.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/replace.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/subseq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/to_array.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/to_tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/to_seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/iter/forward1.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/bounds/lower1.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/detail/shared.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/bounds/upper1.hpp \ + /Users/pblunsom/packages/include/boost/utility/detail/result_of_iterate.hpp \ + /Users/pblunsom/packages/include/boost/pointee.hpp \ + /Users/pblunsom/packages/include/boost/detail/is_incrementable.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/void_ptr_iterator.hpp +obj/train.o: train.cc \ + /Users/pblunsom/packages/include/boost/program_options/parsers.hpp \ + /Users/pblunsom/packages/include/boost/program_options/config.hpp \ + /Users/pblunsom/packages/include/boost/config.hpp \ + /Users/pblunsom/packages/include/boost/config/user.hpp \ + /Users/pblunsom/packages/include/boost/config/select_compiler_config.hpp \ + /Users/pblunsom/packages/include/boost/config/compiler/gcc.hpp \ + /Users/pblunsom/packages/include/boost/config/select_stdlib_config.hpp \ + /Users/pblunsom/packages/include/boost/config/no_tr1/utility.hpp \ + /Users/pblunsom/packages/include/boost/config/stdlib/libstdcpp3.hpp \ + /Users/pblunsom/packages/include/boost/config/select_platform_config.hpp \ + /Users/pblunsom/packages/include/boost/config/platform/macos.hpp \ + /Users/pblunsom/packages/include/boost/config/posix_features.hpp \ + /Users/pblunsom/packages/include/boost/config/suffix.hpp \ + /Users/pblunsom/packages/include/boost/version.hpp \ + /Users/pblunsom/packages/include/boost/config/auto_link.hpp \ + /Users/pblunsom/packages/include/boost/program_options/option.hpp \ + /Users/pblunsom/packages/include/boost/program_options/detail/cmdline.hpp \ + /Users/pblunsom/packages/include/boost/program_options/errors.hpp \ + /Users/pblunsom/packages/include/boost/program_options/cmdline.hpp \ + /Users/pblunsom/packages/include/boost/program_options/options_description.hpp \ + /Users/pblunsom/packages/include/boost/program_options/value_semantic.hpp \ + /Users/pblunsom/packages/include/boost/any.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/broken_compiler_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/lambda_support.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/ttp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/msvc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/gcc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/workaround.hpp \ + /Users/pblunsom/packages/include/boost/detail/workaround.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/ctps.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/type_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/template_arity_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/int.hpp \ + /Users/pblunsom/packages/include/boost/mpl/int_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/adl_barrier.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/adl.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/intel.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/nttp_decl.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/nttp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/integral_wrapper.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c_tag.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/static_constant.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/static_cast.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/config/config.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/template_arity_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/params.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/preprocessor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comma_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/comma_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/iif.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bool.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/empty.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/comma.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repeat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/repeat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/error.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/auto_rec.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/eat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/inc.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/inc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/overload_resolution.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/type_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/config.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/bool_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/integral_constant.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bool.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bool_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c.hpp \ + /Users/pblunsom/packages/include/boost/mpl/integral_c_fwd.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/bool_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/throw_exception.hpp \ + /Users/pblunsom/packages/include/boost/exception/detail/attribute_noreturn.hpp \ + /Users/pblunsom/packages/include/boost/exception/exception.hpp \ + /Users/pblunsom/packages/include/boost/current_function.hpp \ + /Users/pblunsom/packages/include/boost/static_assert.hpp \ + /Users/pblunsom/packages/include/boost/function/function1.hpp \ + /Users/pblunsom/packages/include/boost/function/detail/maybe_include.hpp \ + /Users/pblunsom/packages/include/boost/function/function_template.hpp \ + /Users/pblunsom/packages/include/boost/function/detail/prologue.hpp \ + /Users/pblunsom/packages/include/boost/config/no_tr1/functional.hpp \ + /Users/pblunsom/packages/include/boost/function/function_base.hpp \ + /Users/pblunsom/packages/include/boost/assert.hpp \ + /Users/pblunsom/packages/include/boost/integer.hpp \ + /Users/pblunsom/packages/include/boost/integer_fwd.hpp \ + /Users/pblunsom/packages/include/boost/limits.hpp \ + /Users/pblunsom/packages/include/boost/integer_traits.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/has_trivial_copy.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/intrinsics.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_volatile.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/cv_traits_impl.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_pod.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_void.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_scalar.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_arithmetic.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_integral.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_float.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_or.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_enum.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_reference.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_convertible.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/yes_no_type.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_array.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/ice.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_and.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_not.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/ice_eq.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_abstract.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_class.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_union.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_cv.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_function.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/false_result.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/is_function_ptr_helper.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_member_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_member_function_pointer.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/has_trivial_destructor.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_const.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/composite_traits.hpp \ + /Users/pblunsom/packages/include/boost/ref.hpp \ + /Users/pblunsom/packages/include/boost/utility/addressof.hpp \ + /Users/pblunsom/packages/include/boost/mpl/if.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/value_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/integral.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/eti.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/lambda_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/void_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/lambda_arity_param.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/dtp.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/enum.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessor/def_params_tail.hpp \ + /Users/pblunsom/packages/include/boost/mpl/limits/arity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/and.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitand.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/identity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/identity.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/empty.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/add.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/dec.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/while.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/detail/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/expr_iif.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/adt.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/is_binary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/check.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/compl.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/detail/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/detail/while.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/sub.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/alignment_of.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/size_t_trait_def.hpp \ + /Users/pblunsom/packages/include/boost/mpl/size_t.hpp \ + /Users/pblunsom/packages/include/boost/mpl/size_t_fwd.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/detail/size_t_trait_undef.hpp \ + /Users/pblunsom/packages/include/boost/utility/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/function_equal.hpp \ + /Users/pblunsom/packages/include/boost/function/function_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mem_fn.hpp \ + /Users/pblunsom/packages/include/boost/bind/mem_fn.hpp \ + /Users/pblunsom/packages/include/boost/get_pointer.hpp \ + /Users/pblunsom/packages/include/boost/config/no_tr1/memory.hpp \ + /Users/pblunsom/packages/include/boost/bind/mem_fn_template.hpp \ + /Users/pblunsom/packages/include/boost/bind/mem_fn_cc.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/rem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/enum_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params.hpp \ + /Users/pblunsom/packages/include/boost/detail/no_exceptions_support.hpp \ + /Users/pblunsom/packages/include/boost/lexical_cast.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/make_unsigned.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_signed.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_unsigned.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_same.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_const.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_volatile.hpp \ + /Users/pblunsom/packages/include/boost/call_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/call_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/lcast_precision.hpp \ + /Users/pblunsom/packages/include/boost/program_options/detail/value_semantic.hpp \ + /Users/pblunsom/packages/include/boost/function.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iterate.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/iterate.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/data.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/slot.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/detail/def.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/iter/forward1.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/bounds/lower1.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot/detail/shared.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/detail/bounds/upper1.hpp \ + /Users/pblunsom/packages/include/boost/function/detail/function_iterate.hpp \ + /Users/pblunsom/packages/include/boost/shared_ptr.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/shared_ptr.hpp \ + /Users/pblunsom/packages/include/boost/checked_delete.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/shared_count.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/bad_weak_ptr.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/sp_counted_base.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/sp_has_sync.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp \ + /Users/pblunsom/packages/include/boost/detail/sp_typeinfo.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/sp_counted_impl.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/sp_convertible.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/spinlock_pool.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/spinlock.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/spinlock_sync.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/yield_k.hpp \ + /Users/pblunsom/packages/include/boost/memory_order.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/detail/operator_bool.hpp \ + /Users/pblunsom/packages/include/boost/program_options/positional_options.hpp \ + /Users/pblunsom/packages/include/boost/program_options/detail/parsers.hpp \ + /Users/pblunsom/packages/include/boost/program_options/detail/convert.hpp \ + /Users/pblunsom/packages/include/boost/program_options/variables_map.hpp \ + /Users/pblunsom/packages/include/boost/scoped_ptr.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/scoped_ptr.hpp \ + pyp-topics.hh pyp.hh log_add.h gammadist.h slice-sampler.h mt19937ar.h \ + corpus.hh \ + /Users/pblunsom/packages/include/boost/ptr_container/ptr_vector.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/ptr_sequence_adapter.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/reversible_ptr_container.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/throw_exception.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/scoped_deleter.hpp \ + /Users/pblunsom/packages/include/boost/scoped_array.hpp \ + /Users/pblunsom/packages/include/boost/smart_ptr/scoped_array.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/static_move_ptr.hpp \ + /Users/pblunsom/packages/include/boost/compressed_pair.hpp \ + /Users/pblunsom/packages/include/boost/detail/compressed_pair.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/is_empty.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/default_deleter.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_bounds.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/is_convertible.hpp \ + /Users/pblunsom/packages/include/boost/mpl/and.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/use_preprocessed.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/nested_type_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/include_preprocessed.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/compiler.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/stringize.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/and.hpp \ + /Users/pblunsom/packages/include/boost/mpl/identity.hpp \ + /Users/pblunsom/packages/include/boost/utility/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/move.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/exception.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/clone_allocator.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/nullable.hpp \ + /Users/pblunsom/packages/include/boost/mpl/eval_if.hpp \ + /Users/pblunsom/packages/include/boost/range/functions.hpp \ + /Users/pblunsom/packages/include/boost/range/begin.hpp \ + /Users/pblunsom/packages/include/boost/range/config.hpp \ + /Users/pblunsom/packages/include/boost/range/iterator.hpp \ + /Users/pblunsom/packages/include/boost/range/mutable_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_traits.hpp \ + /Users/pblunsom/packages/include/boost/detail/iterator.hpp \ + /Users/pblunsom/packages/include/boost/range/const_iterator.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_const.hpp \ + /Users/pblunsom/packages/include/boost/range/end.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/implementation_help.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/common.hpp \ + /Users/pblunsom/packages/include/boost/range/detail/sfinae.hpp \ + /Users/pblunsom/packages/include/boost/range/size.hpp \ + /Users/pblunsom/packages/include/boost/range/difference_type.hpp \ + /Users/pblunsom/packages/include/boost/range/distance.hpp \ + /Users/pblunsom/packages/include/boost/range/empty.hpp \ + /Users/pblunsom/packages/include/boost/range/rbegin.hpp \ + /Users/pblunsom/packages/include/boost/range/reverse_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator/reverse_iterator.hpp \ + /Users/pblunsom/packages/include/boost/iterator.hpp \ + /Users/pblunsom/packages/include/boost/utility.hpp \ + /Users/pblunsom/packages/include/boost/utility/base_from_member.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/repeat_from_to.hpp \ + /Users/pblunsom/packages/include/boost/utility/binary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/deduce_d.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/fold_left.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/elem.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/transform.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/mod.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/detail/div_base.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/less_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/not.hpp \ + /Users/pblunsom/packages/include/boost/next_prior.hpp \ + /Users/pblunsom/packages/include/boost/noncopyable.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_adaptor.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_categories.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/config_def.hpp \ + /Users/pblunsom/packages/include/boost/mpl/placeholders.hpp \ + /Users/pblunsom/packages/include/boost/mpl/arg.hpp \ + /Users/pblunsom/packages/include/boost/mpl/arg_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/na_assert.hpp \ + /Users/pblunsom/packages/include/boost/mpl/assert.hpp \ + /Users/pblunsom/packages/include/boost/mpl/not.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/yes_no.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/arrays.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/pp_counter.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arity_spec.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/arg_typedef.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/arg.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/config_undef.hpp \ + /Users/pblunsom/packages/include/boost/iterator/iterator_facade.hpp \ + /Users/pblunsom/packages/include/boost/iterator/interoperable.hpp \ + /Users/pblunsom/packages/include/boost/mpl/or.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/or.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/facade_iterator_category.hpp \ + /Users/pblunsom/packages/include/boost/detail/indirect_traits.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/remove_pointer.hpp \ + /Users/pblunsom/packages/include/boost/iterator/detail/enable_if.hpp \ + /Users/pblunsom/packages/include/boost/implicit_cast.hpp \ + /Users/pblunsom/packages/include/boost/type_traits/add_pointer.hpp \ + /Users/pblunsom/packages/include/boost/mpl/always.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/apply_wrap.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/has_apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/has_xxx.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/type_wrapper.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/has_xxx.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/msvc_typename.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/has_apply.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/msvc_never_true.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp \ + /Users/pblunsom/packages/include/boost/mpl/lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/bind_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/bind_fwd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/next.hpp \ + /Users/pblunsom/packages/include/boost/mpl/next_prior.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/common_name_wknd.hpp \ + /Users/pblunsom/packages/include/boost/mpl/protect.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/bind.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/full_lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/quote.hpp \ + /Users/pblunsom/packages/include/boost/mpl/void.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/has_type.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/config/bcc.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/quote.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/template_arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/full_lambda.hpp \ + /Users/pblunsom/packages/include/boost/mpl/aux_/preprocessed/gcc/apply.hpp \ + /Users/pblunsom/packages/include/boost/range/rend.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/indirect_fun.hpp \ + /Users/pblunsom/packages/include/boost/utility/result_of.hpp \ + /Users/pblunsom/packages/include/boost/type.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/library.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/div.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/arithmetic/mul.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/insert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/push_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/not_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/pop_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/deduce_z.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/pop_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/push_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/remove.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/replace.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/array/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/greater.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/less.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/comparison/greater_equal.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/config/limits.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/control/expr_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/assert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/debug/line.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/apply.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/detail/is_unary.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/expand.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/facilities/intercept.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/local.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/iteration/self.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/append.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/at.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/rest_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/cat.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each_i.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/for.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/detail/for.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/filter.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/first_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/for_each_product.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/to_tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/to_list.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/size.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/list/transform.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitnor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/bitxor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/nor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/or.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/logical/xor.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/paren.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/punctuation/paren_if.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/deduce_r.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params_with_a_default.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_params_with_defaults.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_shifted_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing_binary_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/repetition/enum_trailing_params.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection/max.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/selection/min.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/enum.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/filter.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/first_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/detail/split.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/fold_right.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/reverse.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each_i.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/for_each_product.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/insert.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/rest_n.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/pop_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/pop_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/push_back.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/push_front.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/remove.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/replace.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/subseq.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/to_array.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/seq/to_tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/slot.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple.hpp \ + /Users/pblunsom/packages/include/boost/preprocessor/tuple/to_seq.hpp \ + /Users/pblunsom/packages/include/boost/utility/detail/result_of_iterate.hpp \ + /Users/pblunsom/packages/include/boost/pointee.hpp \ + /Users/pblunsom/packages/include/boost/detail/is_incrementable.hpp \ + /Users/pblunsom/packages/include/boost/ptr_container/detail/void_ptr_iterator.hpp \ + gzstream.hh diff --git a/gi/pyp-topics/src/mt19937ar.c b/gi/pyp-topics/src/mt19937ar.c new file mode 100644 index 00000000..6551ea39 --- /dev/null +++ b/gi/pyp-topics/src/mt19937ar.c @@ -0,0 +1,194 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using mt_init_genrand(seed) + or mt_init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) +*/ + +#include "mt19937ar.h" /* XXX MJ 17th March 2006 */ + +/* Period parameters */ +#define N 624 +#define M 397 +#define MATRIX_A 0x9908b0dfUL /* constant vector a */ +#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffffUL /* least significant r bits */ + +static unsigned long mt[N]; /* the array for the state vector */ +static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ + +/* initializes mt[N] with a seed */ +void mt_init_genrand(unsigned long s) +{ + mt[0]= s & 0xffffffffUL; + for (mti=1; mti> 30)) + mti); + /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ + /* In the previous versions, MSBs of the seed affect */ + /* only MSBs of the array mt[]. */ + /* 2002/01/09 modified by Makoto Matsumoto */ + mt[mti] &= 0xffffffffUL; + /* for >32 bit machines */ + } +} + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +/* slight change for C++, 2004/2/26 */ +void mt_init_by_array(unsigned long init_key[], int key_length) +{ + int i, j, k; + mt_init_genrand(19650218UL); + i=1; j=0; + k = (N>key_length ? N : key_length); + for (; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) + + init_key[j] + j; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; j++; + if (i>=N) { mt[0] = mt[N-1]; i=1; } + if (j>=key_length) j=0; + } + for (k=N-1; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) + - i; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; + if (i>=N) { mt[0] = mt[N-1]; i=1; } + } + + mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ +} + +/* generates a random number on [0,0xffffffff]-interval */ +unsigned long mt_genrand_int32(void) +{ + unsigned long y; + static unsigned long mag01[2]={0x0UL, MATRIX_A}; + /* mag01[x] = x * MATRIX_A for x=0,1 */ + + if (mti >= N) { /* generate N words at one time */ + int kk; + + if (mti == N+1) /* if mt_init_genrand() has not been called, */ + mt_init_genrand(5489UL); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; + } + for (;kk> 1) ^ mag01[y & 0x1UL]; + } + y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; + + mti = 0; + } + + y = mt[mti++]; + + /* Tempering */ + y ^= (y >> 11); + y ^= (y << 7) & 0x9d2c5680UL; + y ^= (y << 15) & 0xefc60000UL; + y ^= (y >> 18); + + return y; +} + +/* generates a random number on [0,0x7fffffff]-interval */ +long mt_genrand_int31(void) +{ + return (long)( mt_genrand_int32()>>1); +} + +/* generates a random number on [0,1]-real-interval */ +double mt_genrand_real1(void) +{ + return mt_genrand_int32()*(1.0/4294967295.0); + /* divided by 2^32-1 */ +} + +/* generates a random number on [0,1)-real-interval */ +double mt_genrand_real2(void) +{ + return mt_genrand_int32()*(1.0/4294967296.0); + /* divided by 2^32 */ +} + +/* generates a random number on (0,1)-real-interval */ +double mt_genrand_real3(void) +{ + return (((double) mt_genrand_int32()) + 0.5)*(1.0/4294967296.0); + /* divided by 2^32 */ +} + +/* generates a random number on [0,1) with 53-bit resolution*/ +double mt_genrand_res53(void) +{ + unsigned long a=mt_genrand_int32()>>5, b=mt_genrand_int32()>>6; + return(a*67108864.0+b)*(1.0/9007199254740992.0); +} +/* These real versions are due to Isaku Wada, 2002/01/09 added */ + +/* +#include + +int main(void) +{ + int i; + unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4; + mt_init_by_array(init, length); + printf("1000 outputs of genrand_int32()\n"); + for (i=0; i<1000; i++) { + printf("%10lu ", mt_genrand_int32()); + if (i%5==4) printf("\n"); + } + printf("\n1000 outputs of genrand_real2()\n"); + for (i=0; i<1000; i++) { + printf("%10.8f ", mt_genrand_real2()); + if (i%5==4) printf("\n"); + } + return 0; +} +*/ diff --git a/gi/pyp-topics/src/mt19937ar.h b/gi/pyp-topics/src/mt19937ar.h new file mode 100644 index 00000000..caab4045 --- /dev/null +++ b/gi/pyp-topics/src/mt19937ar.h @@ -0,0 +1,44 @@ +/* mt19937ar.h + * + * Mark Johnson, 17th March 2006 + */ + +#ifndef MT19937AR_H +#define MT19937AR_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* initializes mt[N] with a seed */ + void mt_init_genrand(unsigned long s); + + /* initialize by an array with array-length */ + /* init_key is the array for initializing keys */ + /* key_length is its length */ + /* slight change for C++, 2004/2/26 */ + void mt_init_by_array(unsigned long init_key[], int key_length); + + /* generates a random number on [0,0xffffffff]-interval */ + unsigned long mt_genrand_int32(void); + + /* generates a random number on [0,0x7fffffff]-interval */ + long mt_genrand_int31(void); + + /* generates a random number on [0,1]-real-interval */ + double mt_genrand_real1(void); + + /* generates a random number on [0,1)-real-interval */ + double mt_genrand_real2(void); + + /* generates a random number on (0,1)-real-interval */ + double mt_genrand_real3(void); + + /* generates a random number on [0,1) with 53-bit resolution*/ + double mt_genrand_res53(void); + +#ifdef __cplusplus +}; +#endif + +#endif /* MT19937AR_H */ diff --git a/gi/pyp-topics/src/pyp-topics.cc b/gi/pyp-topics/src/pyp-topics.cc new file mode 100644 index 00000000..9b43d6d1 --- /dev/null +++ b/gi/pyp-topics/src/pyp-topics.cc @@ -0,0 +1,224 @@ +#include "pyp-topics.hh" + +void PYPTopics::sample(const Corpus& corpus, int samples) { + if (!m_backoff.get()) { + m_word_pyps.clear(); + m_word_pyps.push_back(PYPs()); + } + + std::cerr << " Training with " << m_word_pyps.size()-1 << " backoff level" + << (m_word_pyps.size()==2 ? ":" : "s:") << std::endl; + + for (int i=0; i<(int)m_word_pyps.size(); ++i) + m_word_pyps.at(i).resize(m_num_topics, PYP(0.5, 1.0)); + std::cerr << std::endl; + + m_document_pyps.resize(corpus.num_documents(), PYP(0.5, 1.0)); + + m_topic_p0 = 1.0/m_num_topics; + m_term_p0 = 1.0/corpus.num_types(); + m_backoff_p0 = 1.0/corpus.num_documents(); + + std::cerr << " Documents: " << corpus.num_documents() << " Terms: " + << corpus.num_types() << std::endl; + + // Initialisation pass + int document_id=0, topic_counter=0; + for (Corpus::const_iterator corpusIt=corpus.begin(); + corpusIt != corpus.end(); ++corpusIt, ++document_id) { + m_corpus_topics.push_back(DocumentTopics(corpusIt->size(), 0)); + + int term_index=0; + for (Document::const_iterator docIt=corpusIt->begin(); + docIt != corpusIt->end(); ++docIt, ++term_index) { + topic_counter++; + Term term = *docIt; + + // sample a new_topic + //int new_topic = (topic_counter % m_num_topics); + int new_topic = (document_id % m_num_topics); + + // add the new topic to the PYPs + m_corpus_topics[document_id][term_index] = new_topic; + increment(term, new_topic); + m_document_pyps[document_id].increment(new_topic, m_topic_p0); + } + } + + // Sampling phase + for (int curr_sample=0; curr_sample < samples; ++curr_sample) { + std::cerr << "\n -- Sample " << curr_sample << " "; std::cerr.flush(); + + // for each document in the corpus + int document_id=0; + for (Corpus::const_iterator corpusIt=corpus.begin(); + corpusIt != corpus.end(); ++corpusIt, ++document_id) { + // for each term in the document + int term_index=0; + for (Document::const_iterator docIt=corpusIt->begin(); + docIt != corpusIt->end(); ++docIt, ++term_index) { + Term term = *docIt; + + // remove the prevous topic from the PYPs + int current_topic = m_corpus_topics[document_id][term_index]; + decrement(term, current_topic); + m_document_pyps[document_id].decrement(current_topic); + + // sample a new_topic + int new_topic = sample(document_id, term); + + // add the new topic to the PYPs + m_corpus_topics[document_id][term_index] = new_topic; + increment(term, new_topic); + m_document_pyps[document_id].increment(new_topic, m_topic_p0); + } + if (document_id && document_id % 10000 == 0) { + std::cerr << "."; std::cerr.flush(); + } + } + + if (curr_sample != 0 && curr_sample % 10 == 0) { + std::cerr << " ||| Resampling hyperparameters "; std::cerr.flush(); + // resample the hyperparamters + F log_p=0.0; int resample_counter=0; + for (std::vector::iterator levelIt=m_word_pyps.begin(); + levelIt != m_word_pyps.end(); ++levelIt) { + for (PYPs::iterator pypIt=levelIt->begin(); + pypIt != levelIt->end(); ++pypIt) { + pypIt->resample_prior(); + log_p += pypIt->log_restaurant_prob(); + if (resample_counter++ % 100 == 0) { + std::cerr << "."; std::cerr.flush(); + } + } + } + + for (PYPs::iterator pypIt=m_document_pyps.begin(); + pypIt != m_document_pyps.end(); ++pypIt) { + pypIt->resample_prior(); + log_p += pypIt->log_restaurant_prob(); + } + std::cerr << " ||| LLH=" << log_p << std::endl; + } + } +} + +void PYPTopics::decrement(const Term& term, int topic, int level) { + //std::cerr << "PYPTopics::decrement(" << term << "," << topic << "," << level << ")" << std::endl; + m_word_pyps.at(level).at(topic).decrement(term); + if (m_backoff.get()) { + Term backoff_term = (*m_backoff)[term]; + if (!m_backoff->is_null(backoff_term)) + decrement(backoff_term, topic, level+1); + } +} + +void PYPTopics::increment(const Term& term, int topic, int level) { + //std::cerr << "PYPTopics::increment(" << term << "," << topic << "," << level << ")" << std::endl; + m_word_pyps.at(level).at(topic).increment(term, word_pyps_p0(term, topic, level)); + + if (m_backoff.get()) { + Term backoff_term = (*m_backoff)[term]; + if (!m_backoff->is_null(backoff_term)) + increment(backoff_term, topic, level+1); + } +} + +int PYPTopics::sample(const DocumentId& doc, const Term& term) { + // First pass: collect probs + F sum=0.0; + std::vector sums; + for (int k=0; kis_null(backoff_term)) { + assert (level < m_backoff->order()); + p0 = m_backoff->terms_at_level(level)*prob(backoff_term, topic, level+1); + } + else + p0 = m_term_p0; + } + //for (int i=0; i current_max) { + current_max = prob; + current_topic = k; + } + } + assert(current_topic >= 0); + return current_topic; +} + +std::ostream& PYPTopics::print_document_topics(std::ostream& out) const { + for (CorpusTopics::const_iterator corpusIt=m_corpus_topics.begin(); + corpusIt != m_corpus_topics.end(); ++corpusIt) { + int term_index=0; + for (DocumentTopics::const_iterator docIt=corpusIt->begin(); + docIt != corpusIt->end(); ++docIt, ++term_index) { + if (term_index) out << " "; + out << *docIt; + } + out << std::endl; + } + return out; +} + +std::ostream& PYPTopics::print_topic_terms(std::ostream& out) const { + for (PYPs::const_iterator pypsIt=m_word_pyps.front().begin(); + pypsIt != m_word_pyps.front().end(); ++pypsIt) { + int term_index=0; + for (PYP::const_iterator termIt=pypsIt->begin(); + termIt != pypsIt->end(); ++termIt, ++term_index) { + if (term_index) out << " "; + out << termIt->first << ":" << termIt->second; + } + out << std::endl; + } + return out; +} diff --git a/gi/pyp-topics/src/pyp-topics.hh b/gi/pyp-topics/src/pyp-topics.hh new file mode 100644 index 00000000..4036985a --- /dev/null +++ b/gi/pyp-topics/src/pyp-topics.hh @@ -0,0 +1,52 @@ +#ifndef PYP_TOPICS_HH +#define PYP_TOPICS_HH + +#include +#include + +#include "pyp.hh" +#include "corpus.hh" + + +class PYPTopics { +public: + typedef std::vector DocumentTopics; + typedef std::vector CorpusTopics; + typedef long double F; + +public: + PYPTopics(int num_topics) : m_num_topics(num_topics), m_word_pyps(1), m_backoff(0) {} + + void sample(const Corpus& corpus, int samples); + int sample(const DocumentId& doc, const Term& term); + int max(const DocumentId& doc, const Term& term); + + void set_backoff(const std::string& filename) { + m_backoff.reset(new TermBackoff); + m_backoff->read(filename); + m_word_pyps.clear(); + m_word_pyps.resize(m_backoff->order(), PYPs()); + } + + F prob(const Term& term, int topic, int level=0) const; + void decrement(const Term& term, int topic, int level=0); + void increment(const Term& term, int topic, int level=0); + + std::ostream& print_document_topics(std::ostream& out) const; + std::ostream& print_topic_terms(std::ostream& out) const; + +private: + F word_pyps_p0(const Term& term, int topic, int level) const; + + int m_num_topics; + F m_term_p0, m_topic_p0, m_backoff_p0; + + CorpusTopics m_corpus_topics; + typedef std::vector< PYP > PYPs; + PYPs m_document_pyps; + std::vector m_word_pyps; + + std::auto_ptr m_backoff; +}; + +#endif // PYP_TOPICS_HH diff --git a/gi/pyp-topics/src/pyp.hh b/gi/pyp-topics/src/pyp.hh new file mode 100644 index 00000000..b06c6021 --- /dev/null +++ b/gi/pyp-topics/src/pyp.hh @@ -0,0 +1,477 @@ +#ifndef _pyp_hh +#define _pyp_hh + +#include +#include +#include + +#include "log_add.h" +#include "gammadist.h" +#include "slice-sampler.h" +#include "mt19937ar.h" + +// +// Pitman-Yor process with customer and table tracking +// + +template > +class PYP : protected std::tr1::unordered_map +{ +public: + using std::tr1::unordered_map::const_iterator; + using std::tr1::unordered_map::iterator; + using std::tr1::unordered_map::begin; + using std::tr1::unordered_map::end; + + PYP(long double a, long double b, Hash hash=Hash()); + + int increment(Dish d, long double p0); + int decrement(Dish d); + + // lookup functions + int count(Dish d) const; + long double prob(Dish dish, long double p0) const; + long double prob(Dish dish, long double dcd, long double dca, + long double dtd, long double dta, long double p0) const; + + int num_customers() const { return _total_customers; } + int num_types() const { return std::tr1::unordered_map::size(); } + bool empty() const { return _total_customers == 0; } + + long double log_prob(Dish dish, long double log_p0) const; + // nb. d* are NOT logs + long double log_prob(Dish dish, long double dcd, long double dca, + long double dtd, long double dta, long double log_p0) const; + + int num_tables(Dish dish) const; + int num_tables() const; + + long double a() const { return _a; } + void set_a(long double a) { _a = a; } + + long double b() const { return _b; } + void set_b(long double b) { _b = b; } + + void clear(); + std::ostream& debug_info(std::ostream& os) const; + + long double log_restaurant_prob() const; + long double log_prior() const; + static long double log_prior_a(long double a, long double beta_a, long double beta_b); + static long double log_prior_b(long double b, long double gamma_c, long double gamma_s); + + void resample_prior(); + void resample_prior_a(); + void resample_prior_b(); + +private: + long double _a, _b; // parameters of the Pitman-Yor distribution + long double _a_beta_a, _a_beta_b; // parameters of Beta prior on a + long double _b_gamma_s, _b_gamma_c; // parameters of Gamma prior on b + + struct TableCounter + { + TableCounter() : tables(0) {}; + int tables; + std::map table_histogram; // num customers at table -> number tables + }; + typedef std::tr1::unordered_map DishTableType; + DishTableType _dish_tables; + int _total_customers, _total_tables; + + // Function objects for calculating the parts of the log_prob for + // the parameters a and b + struct resample_a_type { + int n, m; long double b, a_beta_a, a_beta_b; + const DishTableType& dish_tables; + resample_a_type(int n, int m, long double b, long double a_beta_a, + long double a_beta_b, const DishTableType& dish_tables) + : n(n), m(m), b(b), a_beta_a(a_beta_a), a_beta_b(a_beta_b), dish_tables(dish_tables) {} + + long double operator() (long double proposed_a) const { + long double log_prior = log_prior_a(proposed_a, a_beta_a, a_beta_b); + long double log_prob = 0.0; + long double lgamma1a = lgamma(1.0 - proposed_a); + for (typename DishTableType::const_iterator dish_it=dish_tables.begin(); dish_it != dish_tables.end(); ++dish_it) + for (std::map::const_iterator table_it=dish_it->second.table_histogram.begin(); + table_it !=dish_it->second.table_histogram.end(); ++table_it) + log_prob += (table_it->second * (lgamma(table_it->first - proposed_a) - lgamma1a)); + + log_prob += (proposed_a == 0.0 ? (m-1.0)*log(b) + : ((m-1.0)*log(proposed_a) + lgamma((m-1.0) + b/proposed_a) - lgamma(b/proposed_a))); + assert(std::isfinite(log_prob)); + return log_prob + log_prior; + } + }; + + struct resample_b_type { + int n, m; long double a, b_gamma_c, b_gamma_s; + resample_b_type(int n, int m, long double a, long double b_gamma_c, long double b_gamma_s) + : n(n), m(m), a(a), b_gamma_c(b_gamma_c), b_gamma_s(b_gamma_s) {} + + long double operator() (long double proposed_b) const { + long double log_prior = log_prior_b(proposed_b, b_gamma_c, b_gamma_s); + long double log_prob = 0.0; + log_prob += (a == 0.0 ? (m-1.0)*log(proposed_b) + : ((m-1.0)*log(a) + lgamma((m-1.0) + proposed_b/a) - lgamma(proposed_b/a))); + log_prob += (lgamma(1.0+proposed_b) - lgamma(n+proposed_b)); + return log_prob + log_prior; + } + }; +}; + +template +PYP::PYP(long double a, long double b, Hash cmp) +: std::tr1::unordered_map(), _a(a), _b(b), + _a_beta_a(1), _a_beta_b(1), _b_gamma_s(1), _b_gamma_c(1), + //_a_beta_a(1), _a_beta_b(1), _b_gamma_s(10), _b_gamma_c(0.1), + _total_customers(0), _total_tables(0) +{ +// std::cerr << "\t##PYP::PYP(a=" << _a << ",b=" << _b << ")" << std::endl; +} + +template +long double +PYP::prob(Dish dish, long double p0) const +{ + int c = count(dish), t = num_tables(dish); + long double r = num_tables() * _a + _b; + //std::cerr << "\t\t\t\tPYP::prob(" << dish << "," << p0 << ") c=" << c << " r=" << r << std::endl; + if (c > 0) + return (c - _a * t + r * p0) / (num_customers() + _b); + else + return r * p0 / (num_customers() + _b); +} + +template +long double +PYP::prob(Dish dish, long double dcd, long double dca, + long double dtd, long double dta, long double p0) +const +{ + int c = count(dish) + dcd, t = num_tables(dish) + dtd; + long double r = (num_tables() + dta) * _a + _b; + if (c > 0) + return (c - _a * t + r * p0) / (num_customers() + dca + _b); + else + return r * p0 / (num_customers() + dca + _b); +} + +template +long double +PYP::log_prob(Dish dish, long double log_p0) const +{ + using std::log; + int c = count(dish), t = num_tables(dish); + long double r = log(num_tables() * _a + b); + if (c > 0) + return Log::add(log(c - _a * t), r + log_p0) + - log(num_customers() + _b); + else + return r + log_p0 - log(num_customers() + b); +} + +template +long double +PYP::log_prob(Dish dish, long double dcd, long double dca, + long double dtd, long double dta, long double log_p0) +const +{ + using std::log; + int c = count(dish) + dcd, t = num_tables(dish) + dtd; + long double r = log((num_tables() + dta) * _a + b); + if (c > 0) + return Log::add(log(c - _a * t), r + log_p0) + - log(num_customers() + dca + _b); + else + return r + log_p0 - log(num_customers() + dca + b); +} + +template +int +PYP::increment(Dish dish, long double p0) { + int delta = 0; + TableCounter &tc = _dish_tables[dish]; + + // seated on a new or existing table? + int c = count(dish), t = num_tables(dish), T = num_tables(); + long double pshare = (c > 0) ? (c - _a*t) : 0.0; + long double pnew = (_b + _a*T) * p0; + assert (pshare >= 0.0); + //assert (pnew > 0.0); + + if (mt_genrand_res53() < pnew / (pshare + pnew)) { + // assign to a new table + tc.tables += 1; + tc.table_histogram[1] += 1; + _total_tables += 1; + delta = 1; + } + else { + // randomly assign to an existing table + // remove constant denominator from inner loop + long double r = mt_genrand_res53() * (c - _a*t); + for (std::map::iterator + hit = tc.table_histogram.begin(); + hit != tc.table_histogram.end(); ++hit) { + r -= ((hit->first - _a) * hit->second); + if (r <= 0) { + tc.table_histogram[hit->first+1] += 1; + hit->second -= 1; + if (hit->second == 0) + tc.table_histogram.erase(hit); + break; + } + } + if (r > 0) { + std::cerr << r << " " << c << " " << _a << " " << t << std::endl; + assert(false); + } + delta = 0; + } + + std::tr1::unordered_map::operator[](dish) += 1; + _total_customers += 1; + + return delta; +} + +template +int +PYP::count(Dish dish) const +{ + typename std::tr1::unordered_map::const_iterator + dcit = find(dish); + if (dcit != end()) + return dcit->second; + else + return 0; +} + +template +int +PYP::decrement(Dish dish) +{ + typename std::tr1::unordered_map::iterator dcit = find(dish); + if (dcit == end()) { + std::cerr << dish << std::endl; + assert(false); + } + + int delta = 0; + + typename std::tr1::unordered_map::iterator dtit = _dish_tables.find(dish); + if (dtit == _dish_tables.end()) { + std::cerr << dish << std::endl; + assert(false); + } + TableCounter &tc = dtit->second; + + //std::cerr << "\tdecrement for " << dish << "\n"; + //std::cerr << "\tBEFORE histogram: " << tc.table_histogram << " "; + //std::cerr << "count: " << count(dish) << " "; + //std::cerr << "tables: " << tc.tables << "\n"; + + long double r = mt_genrand_res53() * count(dish); + for (std::map::iterator hit = tc.table_histogram.begin(); + hit != tc.table_histogram.end(); ++hit) + { + //r -= (hit->first - _a) * hit->second; + r -= (hit->first) * hit->second; + if (r <= 0) + { + if (hit->first > 1) + tc.table_histogram[hit->first-1] += 1; + else + { + delta = -1; + tc.tables -= 1; + _total_tables -= 1; + } + + hit->second -= 1; + if (hit->second == 0) tc.table_histogram.erase(hit); + break; + } + } + if (r > 0) { + std::cerr << r << " " << count(dish) << " " << _a << " " << num_tables(dish) << std::endl; + assert(false); + } + + // remove the customer + dcit->second -= 1; + _total_customers -= 1; + assert(dcit->second >= 0); + if (dcit->second == 0) { + erase(dcit); + _dish_tables.erase(dtit); + //std::cerr << "\tAFTER histogram: Empty\n"; + } + else { + //std::cerr << "\tAFTER histogram: " << _dish_tables[dish].table_histogram << " "; + //std::cerr << "count: " << count(dish) << " "; + //std::cerr << "tables: " << _dish_tables[dish].tables << "\n"; + } + + return delta; +} + +template +int +PYP::num_tables(Dish dish) const +{ + typename std::tr1::unordered_map::const_iterator + dtit = _dish_tables.find(dish); + + //assert(dtit != _dish_tables.end()); + if (dtit == _dish_tables.end()) + return 0; + + return dtit->second.tables; +} + +template +int +PYP::num_tables() const +{ + return _total_tables; +} + +template +std::ostream& +PYP::debug_info(std::ostream& os) const +{ + int hists = 0, tables = 0; + for (typename std::tr1::unordered_map::const_iterator + dtit = _dish_tables.begin(); dtit != _dish_tables.end(); ++dtit) + { + hists += dtit->second.table_histogram.size(); + tables += dtit->second.tables; + + assert(dtit->second.tables > 0); + assert(!dtit->second.table_histogram.empty()); + + for (std::map::const_iterator + hit = dtit->second.table_histogram.begin(); + hit != dtit->second.table_histogram.end(); ++hit) + assert(hit->second > 0); + } + + os << "restaurant has " + << _total_customers << " customers; " + << _total_tables << " tables; " + << tables << " tables'; " + << num_types() << " dishes; " + << _dish_tables.size() << " dishes'; and " + << hists << " histogram entries\n"; + + return os; +} + +template +void +PYP::clear() +{ + this->std::tr1::unordered_map::clear(); + _dish_tables.clear(); + _total_tables = _total_customers = 0; +} + +// log_restaurant_prob returns the log probability of the PYP table configuration. +// Excludes Hierarchical P0 term which must be calculated separately. +template +long double +PYP::log_restaurant_prob() const { + if (_total_customers < 1) + return (long double)0.0; + + long double log_prob = 0.0; + long double lgamma1a = lgamma(1.0-_a); + + //std::cerr << "-------------------\n" << std::endl; + for (typename DishTableType::const_iterator dish_it=_dish_tables.begin(); + dish_it != _dish_tables.end(); ++dish_it) { + for (std::map::const_iterator table_it=dish_it->second.table_histogram.begin(); + table_it !=dish_it->second.table_histogram.end(); ++table_it) { + log_prob += (table_it->second * (lgamma(table_it->first - _a) - lgamma1a)); + //std::cerr << "|" << dish_it->first->parent << " --> " << dish_it->first->rhs << " " << table_it->first << " " << table_it->second << " " << log_prob; + } + } + //std::cerr << std::endl; + + log_prob += (_a == (long double)0.0 ? (_total_tables-1.0)*log(_b) : (_total_tables-1.0)*log(_a) + lgamma((_total_tables-1.0) + _b/_a) - lgamma(_b/_a)); + //std::cerr << "\t\t" << log_prob << std::endl; + log_prob += (lgamma(1.0 + _b) - lgamma(_total_customers + _b)); + + //std::cerr << _total_customers << " " << _total_tables << " " << log_prob << " " << log_prior() << std::endl; + //std::cerr << _a << " " << _b << std::endl; + if (!std::isfinite(log_prob)) { + assert(false); + } + //return log_prob; + return log_prob + log_prior(); +} + +template +long double +PYP::log_prior() const { + long double prior = 0.0; + if (_a_beta_a > 0.0 && _a_beta_b > 0.0 && _a > 0.0) + prior += log_prior_a(_a, _a_beta_a, _a_beta_b); + if (_b_gamma_s > 0.0 && _b_gamma_c > 0.0) + prior += log_prior_b(_b, _b_gamma_c, _b_gamma_s); + + return prior; +} + +template +long double +PYP::log_prior_a(long double a, long double beta_a, long double beta_b) { + return lbetadist(a, beta_a, beta_b); +} + +template +long double +PYP::log_prior_b(long double b, long double gamma_c, long double gamma_s) { + return lgammadist(b, gamma_c, gamma_s); +} + +template +void +PYP::resample_prior() { + for (int num_its=5; num_its >= 0; --num_its) { + resample_prior_b(); + resample_prior_a(); + } + resample_prior_b(); +} + +template +void +PYP::resample_prior_b() { + if (_total_tables == 0) + return; + + int niterations = 10; // number of resampling iterations + //std::cerr << "\n## resample_prior_b(), initial a = " << _a << ", b = " << _b << std::endl; + resample_b_type b_log_prob(_total_customers, _total_tables, _a, _b_gamma_c, _b_gamma_s); + _b = slice_sampler1d(b_log_prob, _b, mt_genrand_res53, (long double) 0.0, std::numeric_limits::infinity(), + (long double) 0.0, niterations, 100*niterations); + //std::cerr << "\n## resample_prior_b(), final a = " << _a << ", b = " << _b << std::endl; +} + +template +void +PYP::resample_prior_a() { + if (_total_tables == 0) + return; + + int niterations = 10; + //std::cerr << "\n## Initial a = " << _a << ", b = " << _b << std::endl; + resample_a_type a_log_prob(_total_customers, _total_tables, _b, _a_beta_a, _a_beta_b, _dish_tables); + _a = slice_sampler1d(a_log_prob, _a, mt_genrand_res53, std::numeric_limits::min(), + (long double) 1.0, (long double) 0.0, niterations, 100*niterations); +} + +#endif diff --git a/gi/pyp-topics/src/slice-sampler.h b/gi/pyp-topics/src/slice-sampler.h new file mode 100644 index 00000000..3108a0f7 --- /dev/null +++ b/gi/pyp-topics/src/slice-sampler.h @@ -0,0 +1,192 @@ +//! slice-sampler.h is an MCMC slice sampler +//! +//! Mark Johnson, 1st August 2008 + +#ifndef SLICE_SAMPLER_H +#define SLICE_SAMPLER_H + +#include +#include +#include +#include +#include + +//! slice_sampler_rfc_type{} returns the value of a user-specified +//! function if the argument is within range, or - infinity otherwise +// +template +struct slice_sampler_rfc_type { + F min_x, max_x; + const Fn& f; + U max_nfeval, nfeval; + slice_sampler_rfc_type(F min_x, F max_x, const Fn& f, U max_nfeval) + : min_x(min_x), max_x(max_x), f(f), max_nfeval(max_nfeval), nfeval(0) { } + + F operator() (F x) { + if (min_x < x && x < max_x) { + assert(++nfeval <= max_nfeval); + F fx = f(x); + assert(std::isfinite(fx)); + return fx; + } + else + return -std::numeric_limits::infinity(); + } +}; // slice_sampler_rfc_type{} + +//! slice_sampler1d() implements the univariate "range doubling" slice sampler +//! described in Neal (2003) "Slice Sampling", The Annals of Statistics 31(3), 705-767. +// +template +F slice_sampler1d(const LogF& logF0, //!< log of function to sample + F x, //!< starting point + Uniform01& u01, //!< uniform [0,1) random number generator + F min_x = -std::numeric_limits::infinity(), //!< minimum value of support + F max_x = std::numeric_limits::infinity(), //!< maximum value of support + F w = 0.0, //!< guess at initial width + unsigned nsamples=1, //!< number of samples to draw + unsigned max_nfeval=200) //!< max number of function evaluations +{ + typedef unsigned U; + slice_sampler_rfc_type logF(min_x, max_x, logF0, max_nfeval); + + assert(std::isfinite(x)); + + if (w <= 0.0) { // set w to a default width + if (min_x > -std::numeric_limits::infinity() && max_x < std::numeric_limits::infinity()) + w = (max_x - min_x)/4; + else + w = std::max(((x < 0.0) ? -x : x)/4, (F) 0.1); + } + assert(std::isfinite(w)); + + F logFx = logF(x); + for (U sample = 0; sample < nsamples; ++sample) { + F logY = logFx + log(u01()+1e-100); //! slice logFx at this value + assert(std::isfinite(logY)); + + F xl = x - w*u01(); //! lower bound on slice interval + F logFxl = logF(xl); + F xr = xl + w; //! upper bound on slice interval + F logFxr = logF(xr); + + while (logY < logFxl || logY < logFxr) // doubling procedure + if (u01() < 0.5) + logFxl = logF(xl -= xr - xl); + else + logFxr = logF(xr += xr - xl); + + F xl1 = xl; + F xr1 = xr; + while (true) { // shrinking procedure + F x1 = xl1 + u01()*(xr1 - xl1); + if (logY < logF(x1)) { + F xl2 = xl; // acceptance procedure + F xr2 = xr; + bool d = false; + while (xr2 - xl2 > 1.1*w) { + F xm = (xl2 + xr2)/2; + if ((x < xm && x1 >= xm) || (x >= xm && x1 < xm)) + d = true; + if (x1 < xm) + xr2 = xm; + else + xl2 = xm; + if (d && logY >= logF(xl2) && logY >= logF(xr2)) + goto unacceptable; + } + x = x1; + goto acceptable; + } + goto acceptable; + unacceptable: + if (x1 < x) // rest of shrinking procedure + xl1 = x1; + else + xr1 = x1; + } + acceptable: + w = (4*w + (xr1 - xl1))/5; // update width estimate + } + return x; +} + +/* +//! slice_sampler1d() implements a 1-d MCMC slice sampler. +//! It should be correct for unimodal distributions, but +//! not for multimodal ones. +// +template +F slice_sampler1d(const LogP& logP, //!< log of distribution to sample + F x, //!< initial sample + Uniform01& u01, //!< uniform random number generator + F min_x = -std::numeric_limits::infinity(), //!< minimum value of support + F max_x = std::numeric_limits::infinity(), //!< maximum value of support + F w = 0.0, //!< guess at initial width + unsigned nsamples=1, //!< number of samples to draw + unsigned max_nfeval=200) //!< max number of function evaluations +{ + typedef unsigned U; + assert(std::isfinite(x)); + if (w <= 0.0) { + if (min_x > -std::numeric_limits::infinity() && max_x < std::numeric_limits::infinity()) + w = (max_x - min_x)/4; + else + w = std::max(((x < 0.0) ? -x : x)/4, 0.1); + } + // TRACE4(x, min_x, max_x, w); + F logPx = logP(x); + assert(std::isfinite(logPx)); + U nfeval = 1; + for (U sample = 0; sample < nsamples; ++sample) { + F x0 = x; + F logU = logPx + log(u01()+1e-100); + assert(std::isfinite(logU)); + F r = u01(); + F xl = std::max(min_x, x - r*w); + F xr = std::min(max_x, x + (1-r)*w); + // TRACE3(x, logPx, logU); + while (xl > min_x && logP(xl) > logU) { + xl -= w; + w *= 2; + ++nfeval; + if (nfeval >= max_nfeval) + std::cerr << "## Error: nfeval = " << nfeval << ", max_nfeval = " << max_nfeval << ", sample = " << sample << ", nsamples = " << nsamples << ", r = " << r << ", w = " << w << ", xl = " << xl << std::endl; + assert(nfeval < max_nfeval); + } + xl = std::max(xl, min_x); + while (xr < max_x && logP(xr) > logU) { + xr += w; + w *= 2; + ++nfeval; + if (nfeval >= max_nfeval) + std::cerr << "## Error: nfeval = " << nfeval << ", max_nfeval = " << max_nfeval << ", sample = " << sample << ", nsamples = " << nsamples << ", r = " << r << ", w = " << w << ", xr = " << xr << std::endl; + assert(nfeval < max_nfeval); + } + xr = std::min(xr, max_x); + while (true) { + r = u01(); + x = r*xl + (1-r)*xr; + assert(std::isfinite(x)); + logPx = logP(x); + // TRACE4(logPx, x, xl, xr); + assert(std::isfinite(logPx)); + ++nfeval; + if (nfeval >= max_nfeval) + std::cerr << "## Error: nfeval = " << nfeval << ", max_nfeval = " << max_nfeval << ", sample = " << sample << ", nsamples = " << nsamples << ", r = " << r << ", w = " << w << ", xl = " << xl << ", xr = " << xr << ", x = " << x << std::endl; + assert(nfeval < max_nfeval); + if (logPx > logU) + break; + else if (x > x0) + xr = x; + else + xl = x; + } + // w = (4*w + (xr-xl))/5; // gradually adjust w + } + // TRACE2(logPx, x); + return x; +} // slice_sampler1d() +*/ + +#endif // SLICE_SAMPLER_H diff --git a/gi/pyp-topics/src/train.cc b/gi/pyp-topics/src/train.cc new file mode 100644 index 00000000..0d107f11 --- /dev/null +++ b/gi/pyp-topics/src/train.cc @@ -0,0 +1,136 @@ +// STL +#include +#include + +// Boost +#include +#include +#include + +// Local +#include "pyp-topics.hh" +#include "corpus.hh" +#include "gzstream.hh" +#include "mt19937ar.h" + +static const char *REVISION = "$Revision: 0.1 $"; + +// Namespaces +using namespace boost; +using namespace boost::program_options; +using namespace std; + +int main(int argc, char **argv) +{ + std::cout << "Pitman Yor topic models: Copyright 2010 Phil Blunsom\n"; + std::cout << REVISION << '\n' << std::endl; + + //////////////////////////////////////////////////////////////////////////////////////////// + // Command line processing + variables_map vm; + + // Command line processing + options_description cmdline_specific("Command line specific options"); + cmdline_specific.add_options() + ("help,h", "print help message") + ("config,c", value(), "config file specifying additional command line options") + ; + options_description generic("Allowed options"); + generic.add_options() + ("documents,d", value(), "file containing the documents") + ("topics,t", value()->default_value(50), "number of topics") + ("document-topics-out,o", value(), "file to write the document topics to") + ("topic-words-out,w", value(), "file to write the topic word distribution to") + ("samples,s", value()->default_value(10), "number of sampling passes through the data") + ("test-corpus", value(), "file containing the test data") + ("backoff-paths", value(), "file containing the term backoff paths") + ; + options_description config_options, cmdline_options; + config_options.add(generic); + cmdline_options.add(generic).add(cmdline_specific); + + store(parse_command_line(argc, argv, cmdline_options), vm); + if (vm.count("config") > 0) { + ifstream config(vm["config"].as().c_str()); + store(parse_config_file(config, cmdline_options), vm); + } + notify(vm); + //////////////////////////////////////////////////////////////////////////////////////////// + + if (vm.count("help")) { + cout << cmdline_options << "\n"; + return 1; + } + + if (vm.count("documents") == 0) { + cerr << "Please specify a file containing the documents." << endl; + cout << cmdline_options << "\n"; + return 1; + } + + // seed the random number generator + //mt_init_genrand(time(0)); + + // read the data + Corpus corpus; + corpus.read(vm["documents"].as()); + + // run the sampler + PYPTopics model(vm["topics"].as()); + + // read the backoff dictionary + if (vm.count("backoff-paths")) + model.set_backoff(vm["backoff-paths"].as()); + + // train the sampler + model.sample(corpus, vm["samples"].as()); + + if (vm.count("document-topics-out")) { + ogzstream documents_out(vm["document-topics-out"].as().c_str()); + //model.print_document_topics(documents_out); + + int document_id=0; + for (Corpus::const_iterator corpusIt=corpus.begin(); + corpusIt != corpus.end(); ++corpusIt, ++document_id) { + std::vector unique_terms; + for (Document::const_iterator docIt=corpusIt->begin(); + docIt != corpusIt->end(); ++docIt) { + if (unique_terms.empty() || *docIt != unique_terms.back()) + unique_terms.push_back(*docIt); + } + documents_out << unique_terms.size(); + for (std::vector::const_iterator termIt=unique_terms.begin(); + termIt != unique_terms.end(); ++termIt) + documents_out << " " << *termIt << ":" << model.max(document_id, *termIt); + documents_out << std::endl; + } + documents_out.close(); + } + + if (vm.count("topic-words-out")) { + ogzstream topics_out(vm["topic-words-out"].as().c_str()); + model.print_topic_terms(topics_out); + topics_out.close(); + } + + if (vm.count("test-corpus")) { + TestCorpus test_corpus; + test_corpus.read(vm["test-corpus"].as()); + ogzstream topics_out((vm["test-corpus"].as() + ".topics.gz").c_str()); + + for (TestCorpus::const_iterator corpusIt=test_corpus.begin(); + corpusIt != test_corpus.end(); ++corpusIt) { + int index=0; + for (DocumentTerms::const_iterator instanceIt=corpusIt->begin(); + instanceIt != corpusIt->end(); ++instanceIt, ++index) { + int topic = model.max(instanceIt->doc, instanceIt->term); + if (index != 0) topics_out << " "; + topics_out << topic; + } + topics_out << std::endl; + } + topics_out.close(); + } + + return 0; +} diff --git a/gi/pyp-topics/src/utility.h b/gi/pyp-topics/src/utility.h new file mode 100644 index 00000000..405a5b0a --- /dev/null +++ b/gi/pyp-topics/src/utility.h @@ -0,0 +1,962 @@ +// utility.h +// +// (c) Mark Johnson, 24th January 2005 +// +// modified 6th May 2002 to ensure write/read consistency, fixed 18th July 2002 +// modified 14th July 2002 to include insert() (generic inserter) +// modified 26th September 2003 to use mapped_type instead of data_type +// 25th August 2004 added istream >> const char* +// 24th January 2005 added insert_newkey() +// +// Defines: +// loop macros foreach, cforeach +// dfind (default find function) +// afind (find function that asserts key exists) +// insert_newkey (inserts a new key into a map) +// insert (generic inserter into standard data structures) +// disjoint (set operation) +// first_lessthan and second_lessthan (compares elements of pairs) +// +// Simplified interfaces to STL routines: +// +// includes (simplified interface) +// set_intersection (simplified interface) +// inserter (simplified interface) +// max_element (simplified interface) +// min_element (simplified interface) +// hash functions for pairs, vectors, lists, slists and maps +// input and output for pairs and vectors +// resource_usage (interface improved) + + +#ifndef UTILITY_H +#define UTILITY_H + +#include +// #include // Comment out this line if boost is not used +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (__GNUC__ > 3) || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 1) +#define EXT_NAMESPACE __gnu_cxx +#else +#define EXT_NAMESPACE std +#endif + +namespace ext = EXT_NAMESPACE; + +inline float power(float x, float y) { return powf(x, y); } +inline double power(double x, double y) { return pow(x, y); } +inline long double power(long double x, long double y) { return powl(x, y); } + +typedef unsigned U; +typedef long double F; // slower than double, but underflows less + +/////////////////////////////////////////////////////////////////////////// +// // +// Looping constructs // +// // +/////////////////////////////////////////////////////////////////////////// + +// foreach is a simple loop construct +// +// STORE should be an STL container +// TYPE is the typename of STORE +// VAR will be defined as a local variable of type TYPE::iterator +// +#define foreach(TYPE, VAR, STORE) \ + for (TYPE::iterator VAR = (STORE).begin(); VAR != (STORE).end(); ++VAR) + +// cforeach is just like foreach, except that VAR is a const_iterator +// +// STORE should be an STL container +// TYPE is the typename of STORE +// VAR will be defined as a local variable of type TYPE::const_iterator +// +#define cforeach(TYPE, VAR, STORE) \ + for (TYPE::const_iterator VAR = (STORE).begin(); VAR != (STORE).end(); ++VAR) + + +/////////////////////////////////////////////////////////////////////////// +// // +// Map searching // +// // +// dfind(map, key) returns the key's value in map, or map's default // +// value if no such key exists (the default value is not inserted) // +// // +// afind(map, key) returns a reference to the key's value in map, and // +// asserts that this value exists // +// // +/////////////////////////////////////////////////////////////////////////// + +// dfind(Map, Key) returns the value Map associates with Key, or the +// Map's default value if no such Key exists +// +template +inline typename Map::mapped_type dfind(Map& m, const Key& k) +{ + typename Map::iterator i = m.find(k); + if (i == m.end()) + return typename Map::mapped_type(); + else + return i->second; +} + +template +inline const typename Map::mapped_type dfind(const Map& m, const Key& k) +{ + typename Map::const_iterator i = m.find(k); + if (i == m.end()) + return typename Map::mapped_type(); + else + return i->second; +} + + +// afind(map, key) returns a reference to the value associated +// with key in map. It uses assert to check that the key's value +// is defined. +// +template +inline typename Map::mapped_type& afind(Map& m, const Key& k) +{ + typename Map::iterator i = m.find(k); + assert(i != m.end()); + return i->second; +} + +template +inline const typename Map::mapped_type& afind(const Map& m, const Key& k) +{ + typename Map::const_iterator i = m.find(k); + assert(i != m.end()); + return i->second; +} + +//! insert_newkey(map, key, value) checks that map does not contain +//! key, and binds key to value. +// +template +inline typename Map::value_type& +insert_newkey(Map& m, const Key& k,const Value& v) +{ + std::pair itb + = m.insert(Map::value_type(k, v)); + assert(itb.second); + return *(itb.first); +} // insert_newkey() + + +/////////////////////////////////////////////////////////////////////////// +// // +// Insert operations // +// // +/////////////////////////////////////////////////////////////////////////// + + +template +void insert(std::list& xs, const T& x) { + xs.push_back(x); +} + +template +void insert(std::set& xs, const T& x) { + xs.insert(x); +} + +template +void insert(std::vector& xs, const T& x) { + xs.push_back(x); +} + + +/////////////////////////////////////////////////////////////////////////// +// // +// Additional versions of standard algorithms // +// // +/////////////////////////////////////////////////////////////////////////// + +template +inline bool includes(const Set1& set1, const Set2& set2) +{ + return std::includes(set1.begin(), set1.end(), set2.begin(), set2.end()); +} + +template +inline bool includes(const Set1& set1, const Set2& set2, Compare comp) +{ + return std::includes(set1.begin(), set1.end(), set2.begin(), set2.end(), comp); +} + + +template +bool disjoint(InputIter1 first1, InputIter1 last1, + InputIter2 first2, InputIter2 last2) +{ + while (first1 != last1 && first2 != last2) + if (*first1 < *first2) + ++first1; + else if (*first2 < *first1) + ++first2; + else // *first1 == *first2 + return false; + return true; +} + +template +bool disjoint(InputIter1 first1, InputIter1 last1, + InputIter2 first2, InputIter2 last2, Compare comp) +{ + while (first1 != last1 && first2 != last2) + if (comp(*first1, *first2)) + ++first1; + else if (comp(*first2, *first1)) + ++first2; + else // *first1 == *first2 + return false; + return true; +} + +template +inline bool disjoint(const Set1& set1, const Set2& set2) +{ + return disjoint(set1.begin(), set1.end(), set2.begin(), set2.end()); +} + +template +inline bool disjoint(const Set1& set1, const Set2& set2, Compare comp) +{ + return disjoint(set1.begin(), set1.end(), set2.begin(), set2.end(), comp); +} + + +template +inline OutputIterator set_intersection(const Set1& set1, const Set2& set2, + OutputIterator result) +{ + return set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), result); +} + +template +inline OutputIterator set_intersection(const Set1& set1, const Set2& set2, + OutputIterator result, Compare comp) +{ + return set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), result, comp); +} + + +template +inline std::insert_iterator inserter(Container& container) +{ + return std::inserter(container, container.begin()); +} + +// max_element +// +template inline typename Es::iterator max_element(Es& es) +{ + return std::max_element(es.begin(), es.end()); +} + +template inline typename Es::const_iterator max_element(const Es& es) +{ + return std::max_element(es.begin(), es.end()); +} + +template +inline typename Es::iterator max_element(Es& es, BinaryPredicate comp) +{ + return std::max_element(es.begin(), es.end(), comp); +} + +template +inline typename Es::const_iterator max_element(const Es& es, BinaryPredicate comp) +{ + return std::max_element(es.begin(), es.end(), comp); +} + +// min_element +// +template inline typename Es::iterator min_element(Es& es) +{ + return std::min_element(es.begin(), es.end()); +} + +template inline typename Es::const_iterator min_element(const Es& es) +{ + return std::min_element(es.begin(), es.end()); +} + +template +inline typename Es::iterator min_element(Es& es, BinaryPredicate comp) +{ + return std::min_element(es.begin(), es.end(), comp); +} + +template +inline typename Es::const_iterator min_element(const Es& es, BinaryPredicate comp) +{ + return std::min_element(es.begin(), es.end(), comp); +} + +// first_lessthan and second_lessthan +// +struct first_lessthan { + template + bool operator() (const T1& e1, const T2& e2) { + return e1.first < e2.first; + } +}; + +struct second_lessthan { + template + bool operator() (const T1& e1, const T2& e2) { + return e1.second < e2.second; + } +}; + +// first_greaterthan and second_greaterthan +// +struct first_greaterthan { + template + bool operator() (const T1& e1, const T2& e2) { + return e1.first > e2.first; + } +}; + +struct second_greaterthan { + template + bool operator() (const T1& e1, const T2& e2) { + return e1.second > e2.second; + } +}; + + +/////////////////////////////////////////////////////////////////////////// +// // +// hash<> specializations // +// // +// These must be in namespace std. They permit the corresponding STL // +// container to be used as a key in an STL hash table. // +// // +/////////////////////////////////////////////////////////////////////////// + +//namespace EXT_NAMESPACE { +namespace std { + /* + // hash function for bool + // + template <> struct hash + { + size_t operator() (bool b) const + { + return b; + } // operator() + }; // hash{} + + // hash function for double + // + template <> struct hash + { + size_t operator() (double d) const + { + int exponent; + double fraction = frexp(d, &exponent); + return size_t(exponent) ^ size_t(1000000.0*(fabs(fraction-0.5))); + } // operator() + }; // hash{} + + // hash function for strings + // + template <> struct hash + { + size_t operator()(const std::string& s) const + { + typedef std::string::const_iterator CI; + + unsigned long h = 0; + unsigned long g; + CI p = s.begin(); + CI end = s.end(); + + while (p!=end) { + h = (h << 4) + (*p++); + if ((g = h&0xf0000000)) { + h = h ^ (g >> 24); + h = h ^ g; + }} + return size_t(h); + } // operator() + }; // hash{} + +*/ + // hash function for arbitrary pairs + // + template struct hash > { + size_t operator()(const std::pair& p) const + { + size_t h1 = hash()(p.first); + size_t h2 = hash()(p.second); + return h1 ^ (h1 >> 1) ^ h2 ^ (h2 << 1); + } + }; + + + // hash function for vectors + // + template struct hash > + { // This is the fn hashpjw of Aho, Sethi and Ullman, p 436. + size_t operator()(const std::vector& s) const + { + typedef typename std::vector::const_iterator CI; + + unsigned long h = 0; + unsigned long g; + CI p = s.begin(); + CI end = s.end(); + + while (p!=end) { + h = (h << 5) + hash()(*p++); + if ((g = h&0xff000000)) { + h = h ^ (g >> 23); + h = h ^ g; + }} + return size_t(h); + } + }; + + // hash function for slists + // + template struct hash > + { // This is the fn hashpjw of Aho, Sethi and Ullman, p 436. + size_t operator()(const ext::slist& s) const + { + typedef typename ext::slist::const_iterator CI; + + unsigned long h = 0; + unsigned long g; + CI p = s.begin(); + CI end = s.end(); + + while (p!=end) { + h = (h << 7) + hash()(*p++); + if ((g = h&0xff000000)) { + h = h ^ (g >> 23); + h = h ^ g; + }} + return size_t(h); + } + }; + + // hash function for maps + // + template struct hash > + { + size_t operator()(const std::map& m) const + { + typedef typename std::map M; + typedef typename M::const_iterator CI; + + unsigned long h = 0; + unsigned long g; + CI p = m.begin(); + CI end = m.end(); + + while (p != end) { + h = (h << 11) + hash()(*p++); + if ((g = h&0xff000000)) { + h = h ^ (g >> 23); + h = h ^ g; + }} + return size_t(h); + } + }; + +} // namespace EXT_NAMESPACE + + + +/////////////////////////////////////////////////////////////////////////// +// // +// Write/Read code // +// // +// These routines should possess write/read invariance IF their elements // +// also have write-read invariance. Whitespace, '(' and ')' are used as // +// delimiters. // +// // +/////////////////////////////////////////////////////////////////////////// + + +// Define istream >> const char* so that it consumes the characters from the +// istream. Just as in scanf, a space consumes an arbitrary amount of whitespace. +// +inline std::istream& operator>> (std::istream& is, const char* cp) +{ + if (*cp == '\0') + return is; + else if (*cp == ' ') { + char c; + if (is.get(c)) { + if (isspace(c)) + return is >> cp; + else { + is.unget(); + return is >> (cp+1); + } + } + else { + is.clear(is.rdstate() & ~std::ios::failbit); // clear failbit + return is >> (cp+1); + } + } + else { + char c; + if (is.get(c)) { + if (c == *cp) + return is >> (cp+1); + else { + is.unget(); + is.setstate(std::ios::failbit); + } + } + return is; + } +} + + +// Write out an auto_ptr object just as you would write out the pointer object +// +template +inline std::ostream& operator<<(std::ostream& os, const std::auto_ptr& sp) +{ + return os << sp.get(); +} + + +// Pairs +// +template +std::ostream& operator<< (std::ostream& os, const std::pair& p) +{ + return os << '(' << p.first << ' ' << p.second << ')'; +} + +template +std::istream& operator>> (std::istream& is, std::pair& p) +{ + char c; + if (is >> c) { + if (c == '(') { + if (is >> p.first >> p.second >> c && c == ')') + return is; + else + is.setstate(std::ios::badbit); + } + else + is.putback(c); + } + is.setstate(std::ios::failbit); + return is; +} + +// Lists +// +template +std::ostream& operator<< (std::ostream& os, const std::list& xs) +{ + os << '('; + for (typename std::list::const_iterator xi = xs.begin(); xi != xs.end(); ++xi) { + if (xi != xs.begin()) + os << ' '; + os << *xi; + } + return os << ')'; +} + +template +std::istream& operator>> (std::istream& is, std::list& xs) +{ + char c; // This code avoids unnecessary copy + if (is >> c) { // read the initial '(' + if (c == '(') { + xs.clear(); // clear the list + do { + xs.push_back(T()); // create a new elt in list + is >> xs.back(); // read element + } + while (is.good()); // read as long as possible + xs.pop_back(); // last read failed; pop last elt + is.clear(is.rdstate() & ~std::ios::failbit); // clear failbit + if (is >> c && c == ')') // read terminating ')' + return is; // successful return + else + is.setstate(std::ios::badbit); // something went wrong, set badbit + } + else // c is not '(' + is.putback(c); // put c back into input + } + is.setstate(std::ios::failbit); // read failed, set failbit + return is; +} + +// Vectors +// +template +std::ostream& operator<< (std::ostream& os, const std::vector& xs) +{ + os << '('; + for (typename std::vector::const_iterator xi = xs.begin(); xi != xs.end(); ++xi) { + if (xi != xs.begin()) + os << ' '; + os << *xi; + } + return os << ')'; +} + +template +std::istream& operator>> (std::istream& is, std::vector& xs) +{ + char c; // This code avoids unnecessary copy + if (is >> c) { // read the initial '(' + if (c == '(') { + xs.clear(); // clear the list + do { + xs.push_back(T()); // create a new elt in list + is >> xs.back(); // read element + } + while (is.good()); // read as long as possible + xs.pop_back(); // last read failed; pop last elt + is.clear(is.rdstate() & ~std::ios::failbit); // clear failbit + if (is >> c && c == ')') // read terminating ')' + return is; // successful return + else + is.setstate(std::ios::badbit); // something went wrong, set badbit + } + else // c is not '(' + is.putback(c); // put c back into input + } + is.setstate(std::ios::failbit); // read failed, set failbit + return is; +} + +// Slists +// +template +std::ostream& operator<< (std::ostream& os, const ext::slist& xs) +{ + os << '('; + for (typename ext::slist::const_iterator xi = xs.begin(); xi != xs.end(); ++xi) { + if (xi != xs.begin()) + os << ' '; + os << *xi; + } + return os << ')'; +} + +template +std::istream& operator>> (std::istream& is, ext::slist& xs) +{ + char c; + if (is >> c) { + if (c == '(') { + xs.clear(); + T e; + if (is >> e) { + xs.push_front(e); + typename ext::slist::iterator xi = xs.begin(); + while (is >> e) + xi = xs.insert_after(xi, e); + is.clear(is.rdstate() & ~std::ios::failbit); + if (is >> c && c == ')') + return is; + else + is.setstate(std::ios::badbit); + } + else { // empty list + is.clear(is.rdstate() & ~std::ios::failbit); + if (is >> c && c == ')') + return is; + else // didn't see closing ')' + is.setstate(std::ios::badbit); + } + } + else // didn't read '(' + is.putback(c); + } + is.setstate(std::ios::failbit); + return is; +} + +// Sets +// +template +std::ostream& operator<< (std::ostream& os, const std::set& s) +{ + os << '('; + for (typename std::set::const_iterator i = s.begin(); i != s.end(); ++i) { + if (i != s.begin()) + os << ' '; + os << *i; + } + return os << ')'; +} + +template +std::istream& operator>> (std::istream& is, std::set& s) +{ + char c; + if (is >> c) { + if (c == '(') { + s.clear(); + T e; + while (is >> e) + s.insert(e); + is.clear(is.rdstate() & ~std::ios::failbit); + if (is >> c && c == ')') + return is; + else + is.setstate(std::ios::badbit); + } + else + is.putback(c); + } + is.setstate(std::ios::failbit); + return is; +} + +// Hash_sets +// +template +std::ostream& operator<< (std::ostream& os, const std::unordered_set& s) +{ + os << '('; + for (typename std::unordered_set::const_iterator i = s.begin(); i != s.end(); ++i) { + if (i != s.begin()) + os << ' '; + os << *i; + } + return os << ')'; +} + +template +std::istream& operator>> (std::istream& is, std::unordered_set& s) +{ + char c; + if (is >> c) { + if (c == '(') { + s.clear(); + T e; + while (is >> e) + s.insert(e); + is.clear(is.rdstate() & ~std::ios::failbit); + if (is >> c && c == ')') + return is; + else + is.setstate(std::ios::badbit); + } + else + is.putback(c); + } + is.setstate(std::ios::failbit); + return is; +} + + +// Maps +// +template +std::ostream& operator<< (std::ostream& os, const std::map& m) +{ + typedef std::map M; + os << '('; + for (typename M::const_iterator it = m.begin(); it != m.end(); ++it) { + if (it != m.begin()) + os << ' '; + os << *it; + } + return os << ")"; +} + +template +std::istream& operator>> (std::istream& is, std::map& m) +{ + char c; + if (is >> c) { + if (c == '(') { + m.clear(); + std::pair e; + while (is >> e) + m.insert(e); + is.clear(is.rdstate() & ~std::ios::failbit); + if (is >> c && c == ')') + return is; + else + is.setstate(std::ios::badbit); + } + else + is.putback(c); + } + is.setstate(std::ios::failbit); + return is; +} + +// Hash_maps +// +template +std::ostream& operator<< (std::ostream& os, const std::unordered_map& m) +{ + typedef std::unordered_map M; + os << '('; + for (typename M::const_iterator it = m.begin(); it != m.end(); ++it) { + if (it != m.begin()) + os << ' '; + os << *it; + } + return os << ")"; +} + +template +std::istream& operator>> (std::istream& is, std::unordered_map& m) +{ + char c; + if (is >> c) { + if (c == '(') { + m.clear(); + std::pair e; + while (is >> e) + m.insert(e); + is.clear(is.rdstate() & ~std::ios::failbit); + if (is >> c && c == ')') + return is; + else + is.setstate(std::ios::badbit); + } + else + is.putback(c); + } + is.setstate(std::ios::failbit); + return is; +} + + +/////////////////////////////////////////////////////////////////////////// +// // +// Boost library additions // +// // +/////////////////////////////////////////////////////////////////////////// + +#ifdef BOOST_SHARED_PTR_HPP_INCLUDED + +// enhancements to boost::shared_ptr so it can be used with hash +// +namespace std { + template struct equal_to > + : public binary_function, boost::shared_ptr, bool> { + bool operator() (const boost::shared_ptr& p1, const boost::shared_ptr& p2) const { + return equal_to()(p1.get(), p2.get()); + } + }; +} // namespace std + +//namespace EXT_NAMESPACE { +namespace std { + template struct hash > { + size_t operator() (const boost::shared_ptr& a) const { + return hash()(a.get()); + } + }; +} // namespace ext + +template +inline std::ostream& operator<< (std::ostream& os, const boost::shared_ptr& sp) +{ + return os << sp.get(); +} + +#endif // BOOST_SHARED_PTR_HPP_INCLUDED + +struct resource_usage { }; + +#ifndef __i386 +inline std::ostream& operator<< (std::ostream& os, resource_usage r) +{ + return os; +} +#else // Assume we are on a 586 linux +inline std::ostream& operator<< (std::ostream& os, resource_usage r) +{ + FILE* fp = fopen("/proc/self/stat", "r"); + assert(fp); + int utime; + int stime; + unsigned int vsize; + unsigned int rss; + int result = + fscanf(fp, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %d %d %*d %*d %*d %*d" + "%*u %*u %*d %u %u", &utime, &stime, &vsize, &rss); + assert(result == 4); + fclose(fp); + // s << "utime = " << utime << ", stime = " << stime << ", vsize = " << vsize << ", rss = " << rss + ; + // return s << "utime = " << utime << ", vsize = " << vsize; + return os << "utime " << float(utime)/1.0e2 << "s, vsize " + << float(vsize)/1048576.0 << " Mb."; +} +#endif + +//! A default_value_type{} object is used to read an object from a stream, +//! assigning a default value if the read fails. Users should not need to +//! construct such objects, but should use default_value() instead. +// +template +struct default_value_type { + object_type& object; + const default_type defaultvalue; + default_value_type(object_type& object, const default_type defaultvalue) + : object(object), defaultvalue(defaultvalue) { } +}; + +//! default_value() is used to read an object from a stream, assigning a +//! default value if the read fails. It returns a default_value_type{} +//! object, which does the actual reading. +// +template +default_value_type +default_value(object_type& object, const default_type defaultvalue=default_type()) { + return default_value_type(object, defaultvalue); +} + +//! This version of operator>>() reads default_value_type{} from an input stream. +// +template +std::istream& operator>> (std::istream& is, + default_value_type dv) { + if (is) { + if (is >> dv.object) + ; + else { + is.clear(is.rdstate() & ~std::ios::failbit); // clear failbit + dv.object = dv.defaultvalue; + } + } + return is; +} + +// inline F random1() { return rand()/(RAND_MAX+1.0); } +inline F random1() { return mt_genrand_res53(); } + +#endif // UTILITY_H -- cgit v1.2.3