#! /usr/bin/env python # def r8row_to_r8vec ( m, n, a ): #*****************************************************************************80 # ## R8ROW_TO_R8VEC converts an R8ROW into an R8VEC. # # Discussion: # # An R8ROW is an M by N array of R8's, regarded as an array of M rows, # each of length N. # # Example: # # M = 3, N = 4 # # A = # 11 12 13 14 # 21 22 23 24 # 31 32 33 34 # # X = ( 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34 ) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 28 February 2016 # # Author: # # John Burkardt # # Parameters: # # Input, integer M, N, the number of rows and columns. # # Input, real A(M,N), the R8ROW. # # Output, real X(M*N), a vector containing the M rows of A. # import numpy as np x = np.zeros ( m * n ) k = 0 for i in range ( 0, m ): for j in range ( 0, n ): x[k] = a[i,j] k = k + 1 return x def r8row_to_r8vec_test ( ): #*****************************************************************************80 # ## R8ROW_TO_R8VEC_TEST tests R8ROW_TO_R8VEC. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 29 February 2016 # # Author: # # John Burkardt # from r8row_indicator import r8row_indicator from r8row_print import r8row_print from r8vec_print import r8vec_print m = 3 n = 4 print '' print 'R8ROW_TO_R8VEC_TEST' print ' R8ROW_TO_R8VEC converts an R8ROW to an R8VEC.' a = r8row_indicator ( m, n ) r8row_print ( m, n, a, ' The array of rows:' ) x = r8row_to_r8vec ( m, n, a ) r8vec_print ( m * n, x, ' The resulting vector of rows:' ) # # Terminate. # print '' print 'R8ROW_TO_R8VEC_TEST:' print ' Normal end of execution.' return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8row_to_r8vec_test ( ) timestamp ( )