thank you both for the explanation! The fill! option is a bit faster than copying or using zeros... thank you again!
On Wednesday, March 5, 2014 12:26:00 PM UTC-5, Jacob Quinn wrote: > > Or avoid re-allocating by calling: > > fill!(*A*, *0*) > > > On Wed, Mar 5, 2014 at 12:21 PM, Stefan Karpinski > <ste...@karpinski.org<javascript:> > > wrote: > >> Like C or Python, but unlike Matlab or R, when you write s = sT, s is a >> reference to the same array as sT, so if you change one, you change both >> – since they are the same array. If you want to make a copy, you can >> explicitly make a copy: s = copy(sT). If the matrix you are copying is >> all zeros, you're probably better off just make a new array of zeros than >> copying the other one. >> >> >> On Wed, Mar 5, 2014 at 12:15 PM, Jason Solack <jays...@gmail.com<javascript:> >> > wrote: >> >>> Hello everyone, i have some code that loops quite a bit. I have set up >>> before the loop begins a template array of zeros >>> >>> sT= zeros(Float64,1000) >>> >>> then within my loop i'm setting an array s = sT >>> >>> s=sT >>> >>> i'm then doing a bunch of work with the s array... at the top of the >>> loop i'd like to "zero out" the array without reinitiallizing it. After an >>> iteration my sT array has values in it and i don't see any reason why that >>> would happen. >>> >>> Any ideas how these values are being put into my sT array? >>> >>> Thank you! >>> >>> Jason >>> >> >> >