#! /usr/bin/env python # def r8col_max ( m, n, a ): #*****************************************************************************80 # ## R8COL_MAX returns the column maximums of an R8COL. # # Discussion: # # An R8COL is an M by N array of R8's, regarded as an array of N columns, # each of length M. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 February 2016 # # Author: # # John Burkardt # # Parameters: # # Input, integer M, N, the number of rows and columns. # # Input, real A(M,N), the array to be examined. # # Output, real AMAX(N), the maximums of the columns. # import numpy as np amax = np.zeros ( n, dtype = np.float64 ) for j in range ( 0, n ): amax[j] = a[0,j] for i in range ( 1, m ): if ( amax[j] < a[i,j] ): amax[j] = a[i,j] return amax def r8col_max_test ( ): #*****************************************************************************80 # ## R8COL_MAX_TEST tests R8COL_MAX # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 26 February 2016 # # Author: # # John Burkardt # import numpy as np from r8col_print import r8col_print from r8vec_print import r8vec_print m = 3 n = 4 print '' print 'R8COL_MAX_TEST' print ' For an R8COL, an array of column vectors' print ' R8COL_MAX computes maximums' a = np.zeros ( [ m, n ] ) k = 0 for i in range ( 0, m ): for j in range ( 0, n ): k = k + 1 a[i,j] = k r8col_print ( m, n, a, ' The array:' ) amax = r8col_max ( m, n, a ) r8vec_print ( n, amax, ' Column maximums:' ) # # Terminate. # print '' print 'R8COL_MAX_TEST' print ' Normal end of execution.' return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8col_max_test ( ) timestamp ( )