Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 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

>
> 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...

--

Date Subject Author
6/11/13 Wanderson
6/11/13 dpb
6/11/13 Wanderson
6/11/13 dpb
6/11/13 Wanderson
6/11/13 dpb
6/12/13 dpb
6/12/13 Wanderson
6/12/13 Wanderson
6/12/13 dpb
6/12/13 Alan Weiss
6/12/13 dpb
6/13/13 Steven Lord
6/15/13 Bruno Luong