From: Chris B. <cb...@jp...> - 2000-11-29 19:06:18
|
Daehyok Shin wrote: > When I initialize an array, I use > a = ones(shape)*initial_val > > But, I am wondering if Numpy has more efficient way. > For example, > a = array(initial_value, shape) I don't know if it's any more efficient (what you have is pretty fast already), but another option is to use resize: >>> shape = (3,4) >>> initial_val = 5.0 >>> resize(initial_val,shape) array([[ 5., 5., 5., 5.], [ 5., 5., 5., 5.], [ 5., 5., 5., 5.]]) >>> -Chris -- Christopher Barker, Ph.D. cb...@jp... --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ |