Révision 219 pobysoPythonSage/src/pobyso.py

pobyso.py (revision 219)
1128 1128
                                                           itpSo,
1129 1129
                                                           ftpSo,
1130 1130
                                                           maxPrecSo,
1131
                                                           maxErrSo):
1132
    print "Input arguments:"
1133
    #pobyso_autoprint(polySo)
1134
    #pobyso_autoprint(funcSo)
1135
    #pobyso_autoprint(icSo)
1136
    #pobyso_autoprint(intervalSo)
1137
    #pobyso_autoprint(itpSo)
1138
    #pobyso_autoprint(ftpSo)
1139
    #pobyso_autoprint(maxPrecSo)
1140
    #pobyso_autoprint(maxErrSo)
1141
    #print "________________"
1131
                                                           maxErrSo,
1132
                                                           debug=False):
1133
    if debug:
1134
        print "Input arguments:"
1135
        pobyso_autoprint(polySo)
1136
        pobyso_autoprint(funcSo)
1137
        pobyso_autoprint(icSo)
1138
        pobyso_autoprint(intervalSo)
1139
        pobyso_autoprint(itpSo)
1140
        pobyso_autoprint(ftpSo)
1141
        pobyso_autoprint(maxPrecSo)
1142
        pobyso_autoprint(maxErrSo)
1143
        print "________________"
1142 1144
    
1143 1145
    ## Higher order function see: 
1144 1146
    #  http://effbot.org/pyfaq/how-do-you-make-a-higher-order-function-in-python.htm
......
1155 1157
    
1156 1158
    #
1157 1159
    degreeSa        = pobyso_polynomial_degree_so_sa(polySo)
1158
    print "degreeSa:", degreeSa
1159 1160
    ratio           = precision_decay_ratio_function(degreeSa)
1160
    print "ratio:", ratio
1161 1161
    itpSa           = pobyso_constant_from_int_so_sa(itpSo)
1162
    print "itpsSa:", itpSa
1163 1162
    ftpSa           = pobyso_constant_from_int_so_sa(ftpSo)
1164
    print "ftpSa:", ftpSa
1165 1163
    maxPrecSa       = pobyso_constant_from_int_so_sa(maxPrecSo)
1166
    print "maxPrecSa:", maxPrecSa
1167 1164
    maxErrSa        = pobyso_get_constant_as_rn_so_sa(maxErrSo)
1168
    print "maxErrSa:", maxErrSa
1165
    if debug:
1166
        print "degreeSa:", degreeSa
1167
        print "ratio:", ratio
1168
        print "itpsSa:", itpSa
1169
        print "ftpSa:", ftpSa
1170
        print "maxPrecSa:", maxPrecSa
1171
        print "maxErrSa:", maxErrSa
1169 1172
    lastResPolySo   = None
1170 1173
    lastInfNormSo   = None
1171
    print "About to enter the while loop..."
1174
    #print "About to enter the while loop..."
1172 1175
    while True: 
1173 1176
        resPolySo   = pobyso_constant_0_sa_so()
1174 1177
        pDeltaSa    = ftpSa - itpSa
......
1179 1182
            #print ratio(indexSa)
1180 1183
            ctpSa = floor(ftpSa - (pDeltaSa * ratio(indexSa)))
1181 1184
            ctpSo = pobyso_constant_from_int_sa_so(ctpSa)
1182
            print "Index:", indexSa, " - Target precision:", 
1183
            pobyso_autoprint(ctpSo)
1185
            if debug:
1186
                print "Index:", indexSa, " - Target precision:", 
1187
                pobyso_autoprint(ctpSo)
1184 1188
            cmonSo  = \
1185 1189
                sollya_lib_build_function_mul(sollya_lib_coeff(polySo, indexSo),
1186 1190
                                      sollya_lib_build_function_pow( \
......
1201 1205
                                                  resPolyCvSo)
1202 1206
        infNormSo = sollya_lib_dirtyinfnorm(errFuncSo, intervalSo)
1203 1207
        cerrSa    = pobyso_get_constant_as_rn_so_sa(infNormSo)
1204
        print "Infnorm (Sollya):", pobyso_autoprint(infNormSo)
1208
        if debug:
1209
            print "Infnorm (Sollya):", 
1210
            pobyso_autoprint(infNormSo)
1205 1211
        sollya_lib_clear_obj(errFuncSo)
1206 1212
        #print "Infnorm  (Sage):", cerrSa
1207 1213
        if (cerrSa > maxErrSa):
1208
            print "Error is too large."
1214
            if debug:
1215
                print "Error is too large."
1209 1216
            if lastResPolySo is None:
1210
                print "Enlarging prec."
1217
                if debug:
1218
                    print "Enlarging prec."
1211 1219
                ntpSa = floor(ftpSa + ftpSa/50)
1212 1220
                ## Can't enlarge (numerical)
1213 1221
                if ntpSa == ftpSa:
......
1221 1229
                continue
1222 1230
            ## One enlargement took place.
1223 1231
            else:
1224
                print "Exit with the last before last polynomial."
1232
                if debug:
1233
                    print "Exit with the last before last polynomial."
1225 1234
                sollya_lib_clear_obj(resPolySo)
1226 1235
                sollya_lib_clear_obj(infNormSo)
1227 1236
                return (lastResPolySo, lastInfNormSo)
1228 1237
        # cerrSa <= maxErrSa: scrap more bits, possibly.
1229 1238
        else:
1230
            print "Error is too small"
1231
            if cerrSa <= (maxErrSa/2): 
1232
                print "Shrinking prec."
1239
            if debug:
1240
                print "Error is too small"
1241
            if cerrSa <= (maxErrSa/2):
1242
                if debug: 
1243
                    print "Shrinking prec."
1233 1244
                ntpSa = floor(ftpSa - ftpSa/50)
1234 1245
                ## Can't shrink (numerical)
1235 1246
                if ntpSa == ftpSa:

Formats disponibles : Unified diff