#! /usr/bin/env python3 # def wathen_st_size ( nx, ny ): #*****************************************************************************80 # ## WATHEN_ST_SIZE: Size of Wathen matrix stored in sparse triplet format. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 31 August 2014 # # Author: # # John Burkardt. # # Reference: # # Nicholas Higham, # Algorithm 694: A Collection of Test Matrices in MATLAB, # ACM Transactions on Mathematical Software, # Volume 17, Number 3, September 1991, pages 289-305. # # Andrew Wathen, # Realistic eigenvalue bounds for the Galerkin mass matrix, # IMA Journal of Numerical Analysis, # Volume 7, Number 4, October 1987, pages 449-457. # # Parameters: # # Input, integer NX, NY, values which determine the size of the matrix. # # Output, integer NZ_NUM, the number of items of data used to describe # the matrix. # nz_num = nx * ny * 64 return nz_num def wathen_st_size_test ( ): #*****************************************************************************80 # ## WATHEN_ST_SIZE_TEST tests WATHEN_ST_SIZE. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 30 November 2016 # # Author: # # John Burkardt # # Reference: # # Nicholas Higham, # Algorithm 694: A Collection of Test Matrices in MATLAB, # ACM Transactions on Mathematical Software, # Volume 17, Number 3, September 1991, pages 289-305. # # Andrew Wathen, # Realistic eigenvalue bounds for the Galerkin mass matrix, # IMA Journal of Numerical Analysis, # Volume 7, 1987, pages 449-457. # import platform print ( '' ) print ( 'WATHEN_ST_SIZE_TEST_TEST:' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' WATHEN_ST_SIZE returns NZ_NUM, the number of nonzeros' ) print ( ' in a sparse triplet format for a Wathen finite element' ) print ( ' matrix, given NX and NY, the number of rows and columns of' ) print ( ' nodes in the underlying grid.' ) print ( '' ) print ( ' NX / NY: 1 2 3 4 5 6' ) print ( '' ) for ny in range ( 1, 11 ): print ( ' %2d' % ( ny ), end = '' ) for nx in range ( 1, 7 ): n = wathen_st_size ( nx, ny ) print ( ' %5d' % ( n ), end = '' ) print ( '' ) # # Terminate. # print ( '' ) print ( 'WATHEN_ST_SIZE_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) wathen_st_size_test ( ) timestamp ( )