#! /usr/bin/env python # def r8col_to_r8vec ( m, n, a ): #*****************************************************************************80 # ## R8COL_TO_R8VEC copies an R8COL matrix to an R8VEC. # # 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: # # 24 February 2016 # # Author: # # John Burkardt # # Parameters: # # Input, integer M, N, the number of rows and columns in the array. # # Input, real A(M,N), the array to be copied. # # Output, real X(M*N), the vector. # import numpy as np x = np.zeros ( m * n ) k = 0 for j in range ( 0, n ): for i in range ( 0, m ): x[k] = a[i,j] k = k + 1 return x def r8col_to_r8vec_test ( ): #*****************************************************************************80 # ## R8COL_TO_R8VEC_TEST tests R8COL_TO_R8VEC. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 24 February 2016 # # Author: # # John Burkardt # from r8col_indicator import r8col_indicator from r8col_print import r8col_print from r8vec_print import r8vec_print m = 4 n = 3 print '' print 'R8COL_TO_R8VEC_TEST' print ' R8COL_TO_R8VEC converts an R8COL matrix to an R8VEC vector.' a_r8ge = r8col_indicator ( m, n ) r8col_print ( m, n, a_r8ge, ' R8COL matrix:' ) a_r8vec = r8col_to_r8vec ( m, n, a_r8ge ) r8vec_print ( m * n, a_r8vec, ' Corresponding R8VEC vector:' ) # # Terminate. # print '' print 'R8COL_TO_R8VEC_TEST:' print ' Normal end of execution.' return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) r8col_to_r8vec_test ( ) timestamp ( )