help-octave
[Top][All Lists]
Advanced

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

Re: Applying each element of a vector to each row of a matrix


From: Martin Helm
Subject: Re: Applying each element of a vector to each row of a matrix
Date: Sun, 19 Dec 2010 18:02:23 +0100
User-agent: KMail/1.13.5 (Linux/2.6.34.7-0.5-desktop; KDE/4.5.4; x86_64; ; )

Am Sonntag, 19. Dezember 2010, 17:11:42 schrieb Jordi Gutiérrez Hermoso:
> 2010/12/19 Martin Helm <address@hidden>:
> > Am Sonntag, 19. Dezember 2010, 16:33:20 schrieb Jordi Gutiérrez
> > 
> > Hermoso:
> >> I'm often found with a situation in which I have some matrix A and
> >> some vector v and I would like to do something like multiply each
> >> column or row in A by each element of v.
> > 
> > There is a special type "diagonal matrix" which should fit your
> > needs.
> 
> [snip]
> 
> > diag(v)*a for example
> 
> Ah, yes, I hadn't thought of that. Jaroslav worked on extending diag
> matrices. But that only covers the multiplication and division cases.
> 
> Sometimes I also want to do this with exponentiation. What then?
> 
> - Jordi G. H.

But exponentiation of a diagonal matrix is trivial:

expm(diag(v)) gives you the same result as diag(exp(v)) where the first will be 
expensive whereas the latter is a cheap operation or did I misunderstand you 
now?



reply via email to

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