#! /usr/bin/env python # def r8col_min ( m, n, a ): #*****************************************************************************80 # ## R8COL_MIN returns the column minimums 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 AMIN(N), the minimums of the columns. # import numpy as np amin = np.zeros ( n, dtype = np.float64 ) for j in range ( 0, n ): amin[j] = a[0,j] for i in range ( 1, m ): if ( a[i,j] < amin[j] ): amin[j] = a[i,j] return amin def r8col_min_test ( ): #*****************************************************************************80 # ## R8COL_MIN_TEST tests R8COL_MIN # # 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_MIN_TEST' print ' For an R8COL, an array of column vectors' print ' R8COL_MIN computes minimums' 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:' ) amin = r8col_min ( m, n, a ) r8vec_print ( n, amin, ' Column minimums:' ) # # Terminate. # print '' print 'R8COL_MIN_TEST' print ' Normal end of execution.' return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8col_min_test ( ) timestamp ( )