Révision 205 pobysoPythonSage/src/sageSLZ/sageSLZ.sage

sageSLZ.sage (revision 205)
1138 1138
      Check if an element (argument) of the domain of function (function)
1139 1139
      yields a HTRN case (rounding to next) for the target precision 
1140 1140
      (as impersonated by targetRF) for a given accuracy (targetAccuracy). 
1141
      
1142
      The strategy is: 
1143
      - compute the image at high (quasi-exact) precision;
1144
      - round it to nearest to precision;
1145
      - round it to exactly to (precision+1), the computed number has two
1146
        midpoint neighbors;
1147
      - check the distance between these neighbors and the quasi-exact value;
1148
        - if none of them is closer than the targetAccuracy, return False,
1149
        - else return true.
1150
      - Powers of two are a special case when comparing the midpoint in
1151
        the 0 direction..
1141 1152
    """
1142 1153
    ## Arguments filtering. 
1143 1154
    ## TODO: filter the first argument for consistence.
......
1175 1186
    #print "QuasiEx value :", quasiExactValue.n(prec=250).str(base=2)
1176 1187
    #print "Lower midpoint:", \
1177 1188
    #  roundedValuePrecPlusOnePrev.n(prec=targetPlusOnePrecRF.prec()).str(base=2)
1178
    ## Begining of the general case : check with the midpoint with 
1189
    ## Make quasiExactValue = 0 a special case to move it out of the way.
1190
    if quasiExactValue == 0:
1191
        return False
1192
    ## Begining of the general case : check with the midpoint of 
1179 1193
    #  greatest absolute value.
1180 1194
    if quasiExactValue > 0:
1181 1195
        if abs(quasiExactRF(roundedValuePrecPlusOneNext) - quasiExactValue) <\
......
1191 1205
            #print "Upper midpoint:", \
1192 1206
            #  roundedValuePrecPlusOneNext.n(prec=targetPlusOnePrecRF.prec()).str(base=2)
1193 1207
            return True
1194
    else:
1208
    else: # quasiExactValue < 0, the 0 case has been previously filtered out.
1195 1209
        if abs(quasiExactRF(roundedValuePrecPlusOnePrev) - quasiExactValue) < \
1196 1210
           binadeCorrectedTargetAccuracy:
1197 1211
            #print "Too close to the upper midpoint: ", \
......
1376 1390
    return ccComplientRowsList
1377 1391
# End slz_reduce_and_test_base
1378 1392

  
1393
def slz_resultant(poly1, poly2, elimVar):
1394
    """
1395
    Compute the resultant for two polynomials for a given variable
1396
    and return the (poly1, poly2, resultant) if the resultant
1397
    is not 0.
1398
    Return () otherwise.
1399
    """
1400
    polynomialRing0    = poly1.parent()
1401
    resultantInElimVar = poly1.resultant(poly2,polynomialRing0(elimVar))
1402
    if resultantInElimVar.is_zero():
1403
        return None
1404
    else:
1405
        return resultantInElimVar
1406
# End slz_resultant.
1407
#
1379 1408
def slz_resultant_tuple(poly1, poly2, elimVar):
1380 1409
    """
1381 1410
    Compute the resultant for two polynomials for a given variable

Formats disponibles : Unified diff