#! /usr/bin/env python # def uu_product ( i, j, x ): #*****************************************************************************80 # ## UU_PRODUCT: evaluate U(i,x)*U(j,x) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 July 2015 # # Author: # # John Burkardt # # Parameters: # # Input, integer I, J, the indices. # # Input, real X, the argument. # # Output, real VALUE, the value. # from u_polynomial_value import u_polynomial_value value = 0.0 for k in range ( abs ( i - j ), i + j + 1, 2 ): value = value + u_polynomial_value ( k, x ) return value def uu_product_test ( ): #*****************************************************************************80 # ## UU_PRODUCT_TEST tests UU_PRODUCT. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 July 2015 # # Author: # # John Burkardt # import platform from i4_uniform_ab import i4_uniform_ab from r8_uniform_ab import r8_uniform_ab from u_polynomial_value import u_polynomial_value print ( '' ) print ( 'UU_PRODUCT_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' UU_PRODUCT(I,J;X) = U(I,X) * U(J,X)' ) r8_lo = -1.0 r8_hi = +1.0 seed = 123456789 print ( '' ) print ( ' I J X UI UJ UI*UJ UU_PRODUCT' ) print ( '' ) for test in range ( 0, 10 ): x, seed = r8_uniform_ab ( r8_lo, r8_hi, seed ) i, seed = i4_uniform_ab ( 0, 6, seed ) ui = u_polynomial_value ( i, x ) j, seed = i4_uniform_ab ( -1, 4, seed ) uj = u_polynomial_value ( j, x ) uiuj = uu_product ( i, j, x ) print ( ' %2d %2d %14.6g %14.6g %14.6g %14.6g %14.6g'\ % ( i, j, x, ui, uj, ui * uj, uiuj ) ) # # Terminate. # print ( '' ) print ( 'UU_PRODUCT_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) uu_product_test ( ) timestamp ( )