function chebyshev1_handle ( order, output ) %% CHEBYSHEV1_HANDLE handles the Gauss-Chebyshev type 1 quadrature rule. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 01 March 2008 % % Author: % % John Burkardt % % Parameters: % % Input, integer ORDER, the order of the rule. % % Input, string OUTPUT, specifies the output. % * 'C++', print as C++ code. % * 'F77', print as FORTRAN77 code. % * 'F90', print as FORTRAN90 code. % * 'MAT', print as MATLAB code. % * file, write files 'file_w.txt', 'file_x.txt', 'file_r.txt' defining weights, % abscissas, and region. % r(1) = - 1.0; r(2) = + 1.0; [ x, w ] = chebyshev1_compute ( order ); if ( s_eqi ( output, 'C++' ) ) fprintf ( 1, '//\n' ); fprintf ( 1, '// Weights W, abscissas X and range R\n' ); fprintf ( 1, '// for a Gauss-Chebyshev type 1 quadrature rule\n' ); fprintf ( 1, '// ORDER = %d\n', order ); fprintf ( 1, '//\n' ); fprintf ( 1, '// Standard rule:\n' ); fprintf ( 1, '// Integral ( -1 <= x <= +1 ) f(x) / sqrt(1-x^2) dx\n' ); fprintf ( 1, '// is to be approximated by\n' ); fprintf ( 1, '// sum ( 1 <= I <= ORDER ) w(i) * f(x(i)).\n' ); fprintf ( 1, '//\n' ); for i = 1 : order fprintf ( 1, ' w[%d] = %24.16f;\n', i-1, w(i) ); end fprintf ( 1, '\n' ); for i = 1 : order fprintf ( 1, ' x[%d] = %24.16f;\n', i-1, x(i) ); end fprintf ( 1, '\n' ); for i = 1 : 2 fprintf ( 1, ' r[%d] = %24.16f;\n', i-1, r(i) ); end elseif ( s_eqi ( output, 'F77' ) ) fprintf ( 1, 'c\n' ); fprintf ( 1, 'c Weights W, abscissas X and range R\n' ); fprintf ( 1, 'c for a Gauss-Chebyshev type 1 quadrature rule\n' ); fprintf ( 1, 'c ORDER = %d\n', order ); fprintf ( 1, 'c\n' ); fprintf ( 1, 'c Standard rule:\n' ); fprintf ( 1, 'c Integral ( -1 <= x <= +1 ) f(x) / sqrt(1-x^2) dx\n' ); fprintf ( 1, 'c is to be approximated by\n' ); fprintf ( 1, 'c sum ( 1 <= I <= ORDER ) w(i) * f(x(i)).\n' ); fprintf ( 1, 'c\n' ); for i = 1 : order fprintf ( 1, ' w(%d) = %24.16f\n', i, w(i) ); end fprintf ( 1, '\n' ); for i = 1 : order fprintf ( 1, ' x(%d) = %24.16f\n', i, x(i) ); end fprintf ( 1, '\n' ); for i = 1 : 2 fprintf ( 1, ' r(%d) = %24.16f\n', i, r(i) ); end elseif ( s_eqi ( output, 'F90' ) ) fprintf ( 1, '!\n' ); fprintf ( 1, '! Weights W, abscissas X and range R\n' ); fprintf ( 1, '! for a Gauss-Chebyshev type 1 quadrature rule\n' ); fprintf ( 1, '! ORDER = %d\n', order ); fprintf ( 1, '!\n' ); fprintf ( 1, '! Standard rule:\n' ); fprintf ( 1, '! Integral ( -1 <= x <= +1 ) f(x) / sqrt(1-x^2) dx\n' ); fprintf ( 1, '! is to be approximated by\n' ); fprintf ( 1, '! sum ( 1 <= I <= ORDER ) w(i) * f(x(i)).\n' ); fprintf ( 1, '!\n' ); for i = 1 : order fprintf ( 1, ' w(%d) = %24.16f\n', i, w(i) ); end fprintf ( 1, '\n' ); for i = 1 : order fprintf ( 1, ' x(%d) = %24.16f\n', i, x(i) ); end fprintf ( 1, '\n' ); for i = 1 : 2 fprintf ( 1, ' r(%d) = %24.16f\n', i, r(i) ); end elseif ( s_eqi ( output, 'MAT' ) ) fprintf ( 1, '%%\n' ); fprintf ( 1, '%% Weights W, abscissas X and range R\n' ); fprintf ( 1, '%% for a Gauss-Chebyshev type 1e quadrature rule\n' ); fprintf ( 1, '%% ORDER = %d\n', order ); fprintf ( 1, '%%\n' ); fprintf ( 1, '%% Standard rule:\n' ); fprintf ( 1, '%% Integral ( -1 <= x <= +1 ) f(x) / sqrt(1-x^2) dx\n' ); fprintf ( 1, '%% is to be approximated by\n' ); fprintf ( 1, '%% sum ( 1 <= I <= ORDER ) w(i) * f(x(i)).\n' ); fprintf ( 1, '%%\n' ); for i = 1 : order fprintf ( 1, ' w(%d) = %24.16f;\n', i, w(i) ); end fprintf ( 1, '\n' ); for i = 1 : order fprintf ( 1, ' x(%d) = %24.16f;\n', i, x(i) ); end fprintf ( 1, '\n' ); for i = 1 : 2 fprintf ( 1, ' r(%d) = %24.16f;\n', i, r(i) ); end else output_x = strcat ( output, '_x.txt' ); output_w = strcat ( output, '_w.txt' ); output_r = strcat ( output, '_r.txt' ); fprintf ( 1, '\n' ); fprintf ( 1,' Creating quadrature files.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' "Root" file name is "%s".\n', output ); fprintf ( 1, '\n' ); fprintf ( 1, ' Weight file will be "%s".\n', output_w ); fprintf ( 1, ' Abscissa file will be "%s".\n', output_x ); fprintf ( 1, ' Region file will be "%s".\n', output_r ); header = 0; dtable_write ( output_w, 1, order, w, header ); dtable_write ( output_x, 1, order, x, header ); dtable_write ( output_r, 1, 2, r, header ); end