help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: late Re: A Simple Matrix Construction Question


From: David Bateman
Subject: Re: late Re: A Simple Matrix Construction Question
Date: Wed, 5 Feb 2003 08:12:22 -0600
User-agent: Mutt/1.3.28i

According to address@hidden <address@hidden> (on 02/05/03):
> Sorry about the delay, but I think my answer worths it:
> If you pretend to do the following:
> 
>         A_mxn = B_mxc .* C_cxn
> 
> and C is a 1xn row/column vector, you can do this
> 
>         A_mxn = B_mxc * diag(C_1xn)
> 
> instead of 
> 
>         A_mxn = B_mxc .* C_1xn(1:c,1)


I'm not sure I understand this since you haven't 
defined all your terms, but

> 
> It's the solution to a problem I had some days ago.
> > There is probably a really simple way to do the
> > following, but I'm suffering from a mental block.
> > 
> > I have a row array 'Y' of arbitrary length, 1xn.
> > 
> > I want to create an mxn matrix where all of the rows
> > are the same as 'Y'.
> > 
> > Of course, I want to do this without resorting to
> > loops.

If this is what you want to do, why not do for example

m = 4;
n = 5;
y = rand(1,n);
x = y(ones(m,1),:);

where x will now be a m by n matrix with m copies of y,
one per row. Indexing should definitively be more
computationally efficient than doing a matrix multiply
which is O(n^3).

Regards
David
 
-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 25 00 (Ph)
Espace Technologique, Commune de St Aubin    +33 1 69 35 25 01 (Fax)
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[X] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]