Example #1
0
	def _doReplace(self,norm_exp):
		#Search for the free variable in the norm_exp's terms
		pos=find_term(self.free_var,norm_exp.terms)

		#If we found the variable
		if None is not pos:
			#Get the variable to potentially be removed
			remove_var=norm_exp.terms[pos]

			#If we are removing equalities OR
			#If we are removing inequalities AND the var has the opposite sign of the found variable
			#remove the found var and add in the equivalent expression
			if self.remove_equality or (not self.remove_equality and self.free_var.coeff*-1==sign(remove_var.coeff)):
				#Multiply the expression to replace the free variable by its coefficient
				replace_exp=NormExp([],remove_var.coeff)*self.exp

				#Subtract off the variable
				new_exp=norm_exp-NormExp([remove_var],0)

				#Add in the replacement expression
				new_exp=new_exp+replace_exp

				#Update the current norm_exp with the new terms and constant
				norm_exp.terms=new_exp.terms
				norm_exp.const=new_exp.const

				self.replaced=True
				self.changed=True
Example #2
0
	def testSign6(self):
		from iegen.util import sign
		self.failUnless(1==sign(6),'sign(6)!=1')
Example #3
0
	def testSignNeg1(self):
		from iegen.util import sign
		self.failUnless(-1==sign(-1),'sign(-1)!=-1')