コード例 #1
0
def transform_point(point, transform):
    """transform a point"""
    hpoint = Vec(point)
    hpoint.append(1.0)
    hres = transform.mmul(hpoint)
    res = vector.vector(hres[0:-1]) / hres[-1]
    return res
コード例 #2
0
ファイル: intersections.py プロジェクト: philetus/geosolver
def transform_point(point, transform):
    """transform a point"""
    hpoint = Vec(point)
    hpoint.append(1.0)
    hres = transform.mmul(hpoint)
    res = vector.vector(hres[0:-1]) / hres[-1]
    return res
コード例 #3
0
ファイル: configuration.py プロジェクト: philetus/geosolver
 def transform(self, t):
     """returns a new configuration, which is this one transformed by matrix t"""
     newmap = {}
     for v in self.map:
         p = self.map[v]
         ph = Vec(p)
         ph.append(1.0)
         ph = t.mmul(ph)
         p = vector.vector(ph[0:-1]) / ph[-1]
         newmap[v] = p
     return Configuration(newmap)
コード例 #4
0
ファイル: configuration.py プロジェクト: kmolab/geosolver
 def transform(self, t):
     """returns a new configuration, which is this one transformed by matrix t"""
     newmap = {}
     for v in self.map:
         p = self.map[v]
         ph = Vec(p)
         ph.append(1.0)
         ph = t.mmul(ph)
         p = vector.vector(ph[0:-1]) / ph[-1]
         newmap[v] = p
     return Configuration(newmap)
コード例 #5
0
ファイル: configuration.py プロジェクト: kmolab/geosolver
def perp2D(v):
    w = Vec(v)
    w[0] = -v[1]
    w[1] = v[0]
    return w
コード例 #6
0
import hmm_forward
from matfunc import Table, Vec, Matrix

## example 10.2 from Li Hang's book (Statistical Learning Methods), pg. 177

a1 = Table([0.5, 0.2, 0.3])
a2 = Table([0.3, 0.5, 0.2])
a3 = Table([0.2, 0.3, 0.5])

A = Matrix([a1, a2, a3])
#print "matrix A is:\n", A

b1 = ([0.5, 0.5])
b2 = ([0.4, 0.6])
b3 = ([0.7, 0.3])

B = Matrix([b1, b2, b3])
#print "matrix B is:\n", B

pi = Vec([0.2, 0.4, 0.4])

T = 3
O = Table([0, 1, 0])  # red , white, red

print "The prob is:\n", hmm_forward.forward(A, B, pi, O)