What is the fastest way of filling a matrix with identical column vectors in IDL?
Specifically, if A is a float matrix (m x n) and V is a vector with m elements, is there a faster way than … (loop operation) FOR i=0,n-1 DO A[*,i]=V David Fanning provided the following: (matrix operation) vector = Replicate(1, n) array = V ## vector Stein Vidar contributed the following addition: (rebin operation) array = rebin(reform(v,m,1,/overwrite),m,n,/sample) Timing results from Stein Vidar’s UNIX system: { alpha OSF unix 5.2 Oct 30 1998} Time for Loop: 0.27343702 Time for Matrix: 0.093750000 Time for Rebin: 0.067382932 Timing results from David Fanning’s Windows NT system: { x86 Win32 Windows 5.2 Oct 30 1998} Time for Loop: 0.10000002 Time for Matrix: 0.019999981 Time for Rebin: 0.039999962 Stein mentions, “Note that the relative speeds can vary quite a lot on different architectures.