#*****************************************************************************80 # ## gdls_test tests gdls. # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Modified: # # 20 March 2020 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "gdls_test\n" ) cat ( " ", version$version.string, "\n" ) cat ( " gdls solves a least squares problem using gradient descent.\n" ) cat ( "\n" ) source ( "/home/burkardt/public_html/r_src/gdls/gdls.R" ) source ( "/home/burkardt/public_html/r_src/vecnorm/vecnorm.R" ) # # Define the matrix by columns... # A = matrix ( cbind ( 1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ), ncol = 2 ) b = matrix ( cbind ( 52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46 ), ncol = 1 ) x_exact = matrix ( cbind ( 61.272, -39.062 ), ncol = 1 ) x <- gdls ( A, b, alpha = 0.010, tol = 1.0e-7, m = 1.0e6 ) cat ( " x = ", x, "\n" ) cat ( " x_exact = ", x_exact, "\n" ) cat ( " error = ", vecnorm ( x - x_exact ), "\n" ) cat ( "\n" ) cat ( " residual = ", vecnorm ( b - A %*% x ), "\n" ) cat ( " exact residual = ", vecnorm ( b - A %*% x_exact ), "\n" ) # # Terminate. # cat ( "\n" ) cat ( "gdls_test\n" ) cat ( " Normal end of execution.\n" ) cat ( date ( ), "\n" ) quit ( )