summaryrefslogtreecommitdiff
path: root/python/src/utils.pxd
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-06-23 15:54:38 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-06-23 15:54:38 -0400
commitd790e7aea5ffdf3c3e15683fe3d8b2b17a92b62f (patch)
treeda6b55bd5cc4fb18283e86167202ed62f440a646 /python/src/utils.pxd
parent648575a8604243259c110a363f02fbb64d44bcf9 (diff)
parent7b0e318e5c9e33c6191b1d1e2d7350d961555d4e (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/src/utils.pxd')
-rw-r--r--python/src/utils.pxd55
1 files changed, 40 insertions, 15 deletions
diff --git a/python/src/utils.pxd b/python/src/utils.pxd
index 786cd265..3d518524 100644
--- a/python/src/utils.pxd
+++ b/python/src/utils.pxd
@@ -1,5 +1,6 @@
from libcpp.string cimport string
from libcpp.vector cimport vector
+from libcpp.pair cimport pair
cdef extern from "<iostream>" namespace "std":
cdef cppclass istream:
@@ -8,30 +9,60 @@ cdef extern from "<iostream>" namespace "std":
pass
cdef cppclass istringstream(istream):
istringstream(char*)
+ ostream cout
cdef extern from "utils/weights.h":
ctypedef double weight_t
cdef extern from "utils/logval.h":
cdef cppclass LogVal[T]:
- pass
+ double as_float()
-cdef extern from "utils/prob.h":
- cdef cppclass prob_t:
- pass
+ double log(LogVal[double]&)
cdef extern from "utils/wordid.h":
ctypedef int WordID
-cdef extern from "utils/sparse_vector.h":
- cdef cppclass SparseVector[T]:
+cdef extern from "utils/small_vector.h":
+ cdef cppclass SmallVector[T]:
pass
+cdef extern from "utils/sparse_vector.h":
+ cdef cppclass FastSparseVector[T]:
+ cppclass const_iterator:
+ const_iterator(FastSparseVector[T]&, bint is_end)
+ pair[unsigned, T]* ptr "operator->" ()
+ const_iterator& operator++()
+ bint operator==(const_iterator&)
+ bint operator!=(const_iterator&)
+ FastSparseVector()
+ FastSparseVector(FastSparseVector[T]&)
+ const_iterator begin()
+ const_iterator end()
+ void init_vector(vector[T]* vp)
+ T value(unsigned k)
+ void set_value(unsigned k, T& v)
+ size_t size()
+ bint nonzero(unsigned k)
+ bint operator==(FastSparseVector[T]&)
+ T dot(vector[weight_t]&) # cython bug when [T]
+ T dot(FastSparseVector[T]&)
+
+ FastSparseVector[weight_t] operator+(FastSparseVector[weight_t]&, FastSparseVector[weight_t]&)
+ FastSparseVector[weight_t] operator-(FastSparseVector[weight_t]&, FastSparseVector[weight_t]&)
+ ostream operator<<(ostream& out, FastSparseVector[weight_t]& v)
+
+cdef extern from "utils/weights.h" namespace "Weights":
+ void InitSparseVector(vector[weight_t]& dv, FastSparseVector[weight_t]* sv)
+
cdef extern from "utils/tdict.cc" namespace "TD":
- cdef string GetString(vector[WordID] st)
+ string GetString(vector[WordID]& st)
+ unsigned NumWords()
+ WordID TDConvert "TD::Convert" (char*)
+ char* TDConvert "TD::Convert" (WordID)
cdef extern from "utils/verbose.h":
- cdef void SetSilent(bint)
+ void SetSilent(bint)
cdef extern from "utils/fdict.h" namespace "FD":
WordID FDConvert "FD::Convert" (char*)
@@ -39,15 +70,9 @@ cdef extern from "utils/fdict.h" namespace "FD":
cdef extern from "utils/filelib.h":
cdef cppclass ReadFile:
- ReadFile(string)
+ ReadFile(string&)
istream* stream()
cdef extern from "utils/sampler.h":
cdef cppclass MT19937:
pass
-
-"""
-cdef extern from "<boost/shared_ptr.hpp>" namespace "boost":
- cdef cppclass shared_ptr[T]:
- void reset(T*)
-"""