当前位置: 首页>>代码示例>>Python>>正文


Python Matrix.cholesky方法代码示例

本文整理汇总了Python中sage.matrix.constructor.Matrix.cholesky方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.cholesky方法的具体用法?Python Matrix.cholesky怎么用?Python Matrix.cholesky使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sage.matrix.constructor.Matrix的用法示例。


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

示例1: decompose

# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import cholesky [as 别名]
 def decompose(self):
     """
         Gives an SOS decomposition of f if exists as a list of polynomials
         of at most half degree of f.
         This method also fills the 'Info' as 'minimize' does. In addition,
         returns Info['is sos'] which is Boolean depending on the status of 
         sdp solver.
     """
     n = self.NumVars
     N0 = self.NumMonomials(n, self.MainPolyHlfDeg)
     N1 = self.NumMonomials(n, self.MainPolyTotDeg)
     self.MatSize = [N0, N1]
     
     vec = self.MonomialsVec(self.MainPolyHlfDeg)
     m = Matrix(1, N0, vec)
     Mmnt = m.transpose() * m
     Blck = [[] for i in range(N1)]
     C = []
     
     h = Matrix(self.Field, N0, N0, 0)
     C.append(h)
     decomp = []
     
     for i in range(N1):
         p = self.Monomials[i]
         A = self.Calpha(p, Mmnt)
         Blck[i].append(A)
     
     from SDP import SDP
     sos_sdp = SDP.sdp(solver = self.solver, Settings = {'detail':self.detail})
     sos_sdp.solve(C, self.PolyCoefFullVec(), Blck)
     
     if sos_sdp.Info['Status'] == 'Optimal':
         self.Info['status'] = 'Feasible'
         GramMtx = Matrix(sos_sdp.Info['X'][0])
         try:
             self.Info['Message'] = "A SOS decomposition of the polynomial were found."
             self.Info['is sos'] = True
             H1 = GramMtx.cholesky();
             tmpM = Matrix(1, N0, vec)
             decomp = list(tmpM*H1)[0]
             self.Info['Wall'] = sos_sdp.Info['Wall']
             self.Info['CPU'] = sos_sdp.Info['CPU']
         except:
             self.Info['Message'] = "The given polynomial seems to be a sum of squares, but no SOS decomposition were extracted."
             self.Info['is sos'] = False
             self.Info['Wall'] = sos_sdp.Info['Wall']
             self.Info['CPU'] = sos_sdp.Info['CPU']
     else:
         self.Info['Message'] = "The given polynomial is not a sum of squares."
         self.Info['status'] = 'Infeasible'
         self.Info['is sos']= False
     
     self.Info["Size"] = self.MatSize
     return decomp
开发者ID:hiepdang,项目名称:CvxAlgGeo,代码行数:57,代码来源:semidefinite.py


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