Révision 166

pobysoPythonSage/src/testPobyso.sage (revision 166)
292 292
                                               intervalCenterSo, 
293 293
                                               errorTypeSo)
294 294
        sollya_lib_clear_obj(taylorformSo)
295

  
295 296
    wrapped = test_pobyso_wrapper(test, 
296 297
                                  functionSo, 
297 298
                                  degreeSo, 
298 299
                                  intervalCenterSo, 
299 300
                                  errorTypeSo)
300 301
    timing = min(timeit.repeat(wrapped, repeat=repeat, number=number))
301
    sollya_lib_clear_obj(functionSo,None)
302
    sollya_lib_clear_obj(degreeSo,None)
303
    sollya_lib_clear_obj(rangeSo,None)
304
    sollya_lib_clear_obj(intervalCenterSo,None)
305
    sollya_lib_clear_obj(errorTypeSo,None)
302
    sollya_lib_clear_obj(functionSo, None)
303
    sollya_lib_clear_obj(degreeSo, None)
304
    sollya_lib_clear_obj(rangeSo, None)
305
    sollya_lib_clear_obj(intervalCenterSo, None)
306
    sollya_lib_clear_obj(errorTypeSo, None)
306 307
    return timing
307 308
# End   test_pobyso_taylor_so_so_2
308 309
 
pobysoPythonSage/src/pobyso.py (revision 166)
788 788
    if not weightSa is None:
789 789
        weightAsStringSa = weightSa._assume_str().replace('_SAGE_VAR_', '')
790 790
        weightSo = pobyso_parse_string_sa_so(weightAsStringSa)
791
        if pobyso_is_error(weightSo):
791
        if pobyso_is_error_so_sa(weightSo):
792 792
            sollya_lib_clear_obj(functionSo)
793 793
            sollya_lib_clear_obj(rangeSo)
794 794
            sollya_lib_clear_obj(approxErrorSo)   
......
834 834
    if neededPrecisionSa > currentPrecSa:
835 835
        currentPrecSo = pobyso_get_prec_so()
836 836
        pobyso_set_prec_sa_so(neededPrecisionSa)
837
    print "Guessing degree..."
837
    #print "Guessing degree..."
838 838
    # weightSo and degreeBoundsSo are optional arguments.
839 839
    # As declared, sollya_lib_guessdegree must take 5 arguments.
840 840
    if weightSo is None:
......
846 846
    else:
847 847
        degreeRangeSo =  sollya_lib_guessdegree(functionSo, rangeSo, errorSo, \
848 848
                                                weightSo, degreeBoundSo, None)
849
    print "Degree guess done."
849
    #print "...degree guess done."
850 850
    # Restore internal precision, if applicable.
851 851
    if neededPrecisionSa > currentPrecSa:
852 852
        pobyso_set_prec_so_so(currentPrecSo)
pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage (revision 166)
1
load(str('/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage'))
1
load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage")
2
#load(str('/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageMatrixOperations.sage'))
2 3
print "sagePolynomialOperations loading..."
3 4
def spo_add_polynomial_coeffs_to_matrix_row(poly, 
4 5
                                            knownMonomials, 
pobysoPythonSage/src/sageSLZ/sageSLZ.sage (revision 166)
476 476
      output polynomial ; this error <= approxPrecSaS.
477 477
    
478 478
    """
479
    ## Superficial argument check.
480
    if lowerBoundSa > upperBoundSa:
481
        return None
479 482
    RRR = lowerBoundSa.parent()
480
    intervalShrinkConstFactorSa = RRR('0.5')
483
    intervalShrinkConstFactorSa = RRR('0.8')
481 484
    absoluteErrorTypeSo = pobyso_absolute_so_so()
482 485
    currentRangeSo = pobyso_bounds_to_range_sa_so(lowerBoundSa, upperBoundSa)
483 486
    currentUpperBoundSa = upperBoundSa
......
491 494
                                                    absoluteErrorTypeSo)
492 495
    maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo)
493 496
    while maxErrorSa > approxPrecSa:
494
        #print "++Approximation error:", maxErrorSa
497
        print "++Approximation error:", maxErrorSa
495 498
        sollya_lib_clear_obj(polySo)
496 499
        sollya_lib_clear_obj(intervalCenterSo)
497 500
        sollya_lib_clear_obj(maxErrorSo)
......
691 694
    # Scalling the domain -> [1,2[.
692 695
    boundsIntervalRifSa = RealIntervalField(floatingPointPrecSa)
693 696
    domainBoundsIntervalSa = boundsIntervalRifSa(lowerBoundSa, upperBoundSa)
694
    (domainScalingExpressionSa, invDomainScalingExpressionSa) = \
697
    (invDomainScalingExpressionSa, domainScalingExpressionSa) = \
695 698
        slz_interval_scaling_expression(domainBoundsIntervalSa, x)
696 699
    if debug:
697 700
        print "domainScalingExpression for argument :", \
......
718 721
    if debug:
719 722
        print 'ff:', ff, '- Image:', flbSa, fubSa, imageBinadeBottomSa
720 723
    imageBoundsIntervalSa = boundsIntervalRifSa(flbSa, fubSa)
721
    (imageScalingExpressionSa, invImageScalingExpressionSa) = \
724
    (invImageScalingExpressionSa,imageScalingExpressionSa) = \
722 725
        slz_interval_scaling_expression(imageBoundsIntervalSa, x)
723 726
    if debug:
724 727
        print "imageScalingExpression for argument :", \
......
779 782
                                            lowerBoundSa,                     \
780 783
                                            upperBoundSa,                     \
781 784
                                            floatingPointPrecSa)
782
    #
785
    # In case bounds were in the negative real one may need to
786
    # switch scaled bounds.
787
    if scaledLowerBoundSa > scaledUpperBoundSa:
788
        scaledLowerBoundSa, scaledUpperBoundSa = \
789
            scaledUpperBoundSa, scaledLowerBoundSa
790
        #print "Switching!"
783 791
    print "Approximation precision: ", RR(approxPrecSa)
784 792
    # Prepare the arguments for the Taylor expansion computation with Sollya.
785 793
    functionSo = \
......
788 796
    scaledBoundsSo = pobyso_bounds_to_range_sa_so(scaledLowerBoundSa, 
789 797
                                                  scaledUpperBoundSa)
790 798
    # Compute the first Taylor expansion.
799
    print "Computing first Taylor expansion..."
791 800
    (polySo, boundsSo, intervalCenterSo, maxErrorSo) = \
792 801
        slz_compute_polynomial_and_interval(functionSo, degreeSo,
793 802
                                        scaledLowerBoundSa, scaledUpperBoundSa,
794 803
                                        approxPrecSa, internalSollyaPrecSa)
804
    print "...done."
795 805
    if polySo is None:
796 806
        print "slz_get_intervals_and_polynomials: Aborting and returning None!"
797 807
        if precChangedSa:
......
805 815
                                              upperBoundSa.parent().precision()))
806 816
    boundsSa = pobyso_range_to_interval_so_sa(boundsSo, realIntervalField)
807 817
    errorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo)
808
    print "First approximation error:", errorSa.n(digits=50)
818
    print "First approximation error:", errorSa.n(digits=10)
809 819
    # If the error and interval are OK a the first try, just return.
810 820
    if boundsSa.endpoints()[1] >= scaledUpperBoundSa:
811 821
        # Change variable stuff in Sollya x -> x0-x.
......
905 915
def slz_interval_scaling_expression(boundsInterval, expVar):
906 916
    """
907 917
    Compute the scaling expression to map an interval that spans at most
908
    a single binade to [1, 2) and the inverse expression as well.
918
    a single binade into [1, 2) and the inverse expression as well.
909 919
    If the interval spans more than one binade, result is wrong since
910 920
    scaling is only based on the lower bound.
911 921
    Not very sure that the transformation makes sense for negative numbers.
......
981 991
    if boundsInterval.endpoints()[0] > 0:
982 992
        return((2^(-lbBinade) * expVar),(2^(lbBinade) * expVar))
983 993
    else:
984
        return((-(2^(-lbBinade+1)) * expVar),(-(2^(lbBinade-1)) * expVar))
994
        return((-(2^(-ubBinade)) * expVar),(-(2^(ubBinade)) * expVar))
985 995
"""
986 996
    # Code sent to attic. Should be the base for a 
987 997
    # "slz_interval_translate_expression" rather than scale.

Formats disponibles : Unified diff