def consequences_of_nonnegative_solution_assumption(self, eqs):
        r"""
        Return equations implied by the assumption of the existence of nonnegative solutions.
        """
        n_zeros_prev = -1
        zeros = []
        gb = eqs
        while n_zeros_prev!=len(zeros):
            n_zeros_prev = len(zeros)
            gb = self._ring_ramification.ideal(gb + zeros).groebner_basis()
#             gb = self._ring_ramification.ideal(gb + zeros).groebner_basis()
            zeros = []
            for eq in gb:
                coefs = eq.coefficients()
                if sum([sgn(a)*sgn(b) for a,b in zip(coefs[:-1],coefs[1:])])==len(coefs)-1:
                    zeros += eq.variables()
        return [zeros, gb]
Exemple #2
0
 def _sage_(self):
     import sage.all as sage
     return sage.sgn(self.args[0]._sage_())
Exemple #3
0
 def _sage_(self):
     import sage.all as sage
     return sage.sgn(self.args[0]._sage_())
Exemple #4
0
def fundamental_discriminants(A, B):
    """Return the fundamental discriminants between A and B (inclusive), as Sage integers,
    ordered by absolute value, with negatives first when abs same."""
    v = [ZZ(D) for D in range(A, B + 1) if is_fundamental_discriminant(D)]
    v.sort(key=lambda x: (abs(x), sgn(x)))
    return v
def gen_fricterm( rbt ):
  from sage.all import zero_matrix, SR, sgn
  fric = zero_matrix(SR, rbt.dof, 1 )
  for i in xrange(1,rbt.dof+1):
    fric[i-1,0] = rbt.fvi[i] * rbt.dq[i-1,0] + rbt.fci[i] * sgn(rbt.dq[i-1,0])
  return fric