dpb
Posts:
8,111
Registered:
6/7/07


Re: Multiplying each colum of my matrix by a constant
Posted:
Jun 12, 2013 11:08 AM


On 6/12/2013 9:47 AM, Wanderson wrote: ...
>> > > If the object is speed in an inner loop, then for the 3x3 case the >> > original version of writing out the three explicit multiplies may >> well > be the most efficacious route. For higher dimensions it gets >> klunky > certainly but for as few as three it's not so bad. >> > >  >> >> Thanks again dpb, >> In fact, my matrices dimensions vary inside my program rsrs. >> I start with an 3x3 matrix and they will growing as (2k+1) x (2k+1) >> dimension. >> I'll try the repmat idea, this function seems to be very usefull to >> many things, I should learn more about it. > > BTW[2] rsrs > > I just implemented the repmat solution in my code, but it is slower than > the bsxfun() option. ...
I'm not terribly surprisedif you'll look, you'll find that repmat() is not builtin as one might expect but just an mfile implementation. bsxfun() is builtin
So, since you've got a variablesized case, I'm guessing the best implementation (other than mexfile) will be to use the loop after all.
Again, doublecheck the File Exchange for a replacement bxsfun()  it does seem to me like somebody (Bruno maybe?) posted one there that is betterperforming...


