Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Multiplying each colum of my matrix by a constant
Replies: 13   Last Post: Jun 15, 2013 3:54 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 8,187
Registered: 6/7/07
Re: Multiplying each colum of my matrix by a constant
Posted: Jun 12, 2013 11:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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 surprised--if you'll look, you'll find that repmat() is
not builtin as one might expect but just an m-file implementation.
bsxfun() is builtin

So, since you've got a variable-sized case, I'm guessing the best
implementation (other than mex-file) will be to use the loop after all.

Again, double-check the File Exchange for a replacement bxsfun() -- it
does seem to me like somebody (Bruno maybe?) posted one there that is
better-performing...

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.