• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tensor.tensor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tensor.tensor函数的典型用法代码示例。如果您正苦于以下问题:Python tensor函数的具体用法?Python tensor怎么用?Python tensor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tensor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: totensor

    def totensor(self):
        sz = self.tsize
        order = numpy.concatenate((self.rindices, self.cindices))
        order = order.tolist()
        data = self.data.reshape(tools.getelts(sz, order))

        data = tensor.tensor(data).ipermute(order).data

        return tensor.tensor(data, sz)
开发者ID:smileyk,项目名称:tensor_analysis,代码行数:9,代码来源:tenmat.py


示例2: convolve

 def convolve(self, h, idx):
     obj = t.tensor(self)
     if isinstance(h, t.tensor): h = h.arr
     N = obj.len(idx)
     obj.transpose([obj.index(idx), 0])
     z = zeros(obj.arr.shape) 
     obj.arr = append(obj.arr, z, axis=0)
     obj.transpose([obj.index(idx), -1],opt=True)
     X = fft.rfft(obj.arr)
     H = fft.rfft(append(h, zeros(2*N - h.size)))
     return t.tensor(fft.irfft(X*H)[0:N], obj.idx, obj.ud)
开发者ID:uyuutosa,项目名称:public,代码行数:11,代码来源:handle_tensor.py


示例3: __init__

    def __init__(self,i,n):
        # our inde scheme starts at 0, so subtract 1 from n
        # when naming the momenta
        k = n-1
        il = lorentz_key(i) if (i<0) else i
        p_str = "p{0}[{1}]"
        array = [tensor([c_variable(p_str.format(k,vect_gauge_dict[0]))], None), 
                 tensor([c_variable(p_str.format(k,vect_gauge_dict[1]))], None), 
                 tensor([c_variable(p_str.format(k,vect_gauge_dict[2]))], None), 
                 tensor([c_variable(p_str.format(k,vect_gauge_dict[3]))], None)]

        super(P,self).__init__(array,il)
开发者ID:alisw,项目名称:SHERPA,代码行数:12,代码来源:lorentz_structures.py


示例4: ctor

def ctor(verbose):
    
    dat = numpy.arange(24).reshape([2,3,4]);
    
    t = tensor.tensor(dat);
    print t;
    if (verbose):
        obj = tenmat.tenmat(t, [1,0]);
        print obj;
        print obj.copy();
        
    dat = dat.reshape([4,6]);
    t = tensor.tensor(dat);
    if (verbose):
        obj = tenmat.tenmat(t, [0], [1], [4,6]);
        print obj;
开发者ID:gbrouwer,项目名称:Tensor,代码行数:16,代码来源:tenmatTests.py


示例5: tensorProduct

 def tensorProduct(self,other):
     """Add other as a component(s) on the right of self. e.g. (a|b).tensorProduct(c) = a|b|c"""
     if type(other) in [relation.relation,doublyDefined.doublyDefined,coefficient.coefficient, str, float, int, monomial.monomial]:
         return self.tensorProduct(pureTensor(other))
     if not isinstance(other,pureTensor):
         return reduce(lambda x,y: x+y, [self.tensorProduct(z) for z in other], tensor.tensor())
     return pureTensor(self.monomials + other.monomials, self.coefficient * other.coefficient)
开发者ID:campbellC,项目名称:polygnome,代码行数:7,代码来源:pureTensor.py


示例6: i_3Inner

 def i_3Inner(pT):
     answer = tensor()
     doublyDefined = pT[1]
     for generator, rel in doublyDefined.leftHandRepresentation:
         rightHandSide = generator * i_2(pureTensor([1,rel,1]),alg)
         answer = answer + pureTensor(1).tensorProduct(rightHandSide)
     return answer
开发者ID:campbellC,项目名称:polygnome,代码行数:7,代码来源:chainMaps.py


示例7: m_1Inner

 def m_1Inner(b):
     b = b[1].clean()
     answer = tensor()
     if b.degree() != 0:
         for i in range(b.degree()):
             answer += b.coefficient * pureTensor([b[0:i],b[i],b[i+1:]])
     return answer
开发者ID:campbellC,项目名称:polygnome,代码行数:7,代码来源:chainMaps.py


示例8: mov_ave

 def mov_ave(self, wid, dx, idx, fs):
     f =  fft.rfftfreq(self.len(idx), float(fs))
     L = int(float(wid) / float(dx))
     H = ((sin(pi *  f * L / fs) / sin(pi * f / fs)) * exp(-1j * pi * f * (L-1) / fs)) / L
     H[0] = 1.
     X = self.rfft(idx).arr * H
     return t.tensor(fft.irfft(X), self.idx, self.ud)
开发者ID:uyuutosa,项目名称:public,代码行数:7,代码来源:handle_tensor.py


示例9: totensorTests

def totensorTests(verbose):
    
    dat = numpy.arange(24).reshape([2,3,4]);
    t = tensor.tensor(dat);
    obj = tenmat.tenmat(t,[2,1]);
    if(verbose):
        print obj;
        print obj.totensor();
开发者ID:gbrouwer,项目名称:Tensor,代码行数:8,代码来源:tenmatTests.py


示例10: k_4Inner

 def k_4Inner(pT):
     answer= tensor()
     doublyDefined = pT[1]
     for generator, rel in doublyDefined.leftHandRepresentation:
         answer = answer + pureTensor((generator,rel,1)).clean()
     for rel, generator in doublyDefined.rightHandRepresentation:
         answer = answer - pureTensor((1,rel,generator)).clean()
     return answer
开发者ID:campbellC,项目名称:polygnome,代码行数:8,代码来源:chainMaps.py


示例11: i_2Inner

 def i_2Inner(pT):
     answer = tensor()
     rel = pT[1]
     for term in rel.leadingMonomial:
         answer = answer + term.coefficient * pureTensor((1,term[0],term[1],1))
     for term in rel.lowerOrderTerms:
         answer = answer - term.coefficient * pureTensor((1,term[0],term[1],1))
     return answer
开发者ID:campbellC,项目名称:polygnome,代码行数:8,代码来源:chainMaps.py


示例12: totensor

 def totensor(self):
     """returns a new tensor object that contains the same values"""
     temp = numpy.ndarray(self.shape);
     temp.fill(0);
     
     for i in range(0, len(self.vals)):
         temp.put(tools.sub2ind(self.shape, self.subs[i])[0], self.vals[i][0]);
     
     return tensor.tensor(temp, self.shape);
开发者ID:pengyuan,项目名称:markov2tensor,代码行数:9,代码来源:sptensor.py


示例13: listOfPolysToTensors

 def listOfPolysToTensors(ps):
     ps = iter(ps)
     pureTensors = [pureTensor.pureTensor(mono) for mono in next(ps)]
     for poly in ps:
         newPureTensors = []
         for mono in poly:
             newPureTensors.extend([x.tensorProduct(mono) for x in pureTensors])
         pureTensors = newPureTensors
     return tensor.tensor(pureTensors)
开发者ID:campbellC,项目名称:polygnome,代码行数:9,代码来源:tensorAlgebra.py


示例14: ctorTests

def ctorTests(verbose):
    arr = numpy.arange(24).reshape([2,3,4]);
    A = numpy.array([[1,2],[3,4],[5,6]]);
    B = numpy.array([[1,2,3],[4,5,6]]);
    C = numpy.array([[1,2,3,4]]);
    
    obj = ttensor.ttensor(tensor.tensor(arr), [A, B, C]);
    print obj;
    print obj.shape;
开发者ID:pengyuan,项目名称:markov2tensor,代码行数:9,代码来源:ttensorTests.py


示例15: tosptensor

def tosptensor(verbose):
    
    dat = numpy.array([1,2,3,4,5,6,7,8,9,10,0,0,13,14,15,16,17,18]);
    siz = numpy.array([3,3,2]);
    
    obj = tensor.tensor(dat, siz);
    if(verbose == 1):
        print obj;
        print (obj.tosptensor());
开发者ID:gbrouwer,项目名称:Tensor,代码行数:9,代码来源:tensorTests.py


示例16: test2

def test2():
#    A = numpy.array([[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]]);
#    A = numpy.arange(12).reshape([4,3]) + 1;
    A = numpy.arange(1000).reshape([10,10,10])+1;
    (ans1, ans2) = DTA.DTA(tensor.tensor(A), [2,2,2]);
    print ans1;
    for i in range(0, len(ans2)):
        print "{0} th array\n {1}".format(i, ans2[i]);
        
    print ans1.totensor();
开发者ID:monsendag,项目名称:tensor,代码行数:10,代码来源:DTATests.py


示例17: append

 def append(self, obj, idx):
     ## \brief Append a tensor to other tensor.
     self.same_trans(obj)    
     self.transpose([idx,0])
     obj.transpose([idx,0])
     if self.idx != obj.idx:
         raise ValueError, "Index is not much."
     ret = t.tensor(append(self.arr, obj.arr, axis=0), self.idx, self.ud)
     
     return ret
开发者ID:uyuutosa,项目名称:public,代码行数:10,代码来源:handle_tensor.py


示例18: mov_grad

    def mov_grad(self, obj, wid, dx, idx, fs):
        x = obj
        y = self
        xy = x * y
        L = abs(int(float(wid)/float(dx))) 
        h = t.tensor(ones(L), idx, self.gud(idx))

        conv_x = x.convolve(h, idx)
        a = (L * xy.convolve(h, idx) - conv_x * y.convolve(h, idx)) / (L * (x**2).convolve(h, idx) - conv_x ** 2)
        return a
开发者ID:uyuutosa,项目名称:public,代码行数:10,代码来源:handle_tensor.py


示例19: k_2Inner

 def k_2Inner(tens):
     assert isinstance(tens,pureTensor)
     answer= tensor()
     rel =tens.monomials[1]
     for i in rel.leadingMonomial:
         answer = answer + i.coefficient * pureTensor((i.submonomial(0,1),i.submonomial(1,2), 1))
         answer = answer + i.coefficient * pureTensor((1,i.submonomial(0,1),i.submonomial(1,2)))
     for i in rel.lowerOrderTerms:
         answer = answer - i.coefficient * pureTensor((i.submonomial(0,1),i.submonomial(1,2), 1))
         answer = answer - i.coefficient * pureTensor((1,i.submonomial(0,1),i.submonomial(1,2)))
     return answer
开发者ID:campbellC,项目名称:polygnome,代码行数:11,代码来源:chainMaps.py


示例20: ctor

def ctor(verbose):
    dat = numpy.arange(24);
    dat[10] = 100;
    dat[16] = -1;
    siz = numpy.array([4,3,2]);
    
    obj = tensor.tensor(dat, siz);
    if(verbose == 1):
        print obj;
        print obj.ndims();
    
    obj2 = tensor.tensor(dat.reshape([2,3,4]),siz);
    if(verbose == 1):
        print obj;
        print obj.shape;
    
    dat = numpy.array([1,2,3,4,5,6,7,8,9,10,0,0,13,14,15,16,17,18]);
    obj2 = tensor.tensor(dat);
    if(verbose == 1):
        print obj2;
        print obj2.shape;
开发者ID:gbrouwer,项目名称:Tensor,代码行数:21,代码来源:tensorTests.py



注:本文中的tensor.tensor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python generator_utils.maybe_download函数代码示例发布时间:2022-05-27
下一篇:
Python log_utils.log函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap