[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 19:41:08 +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, 18:08:45 schrieb Jordi Gutiérrez Hermoso:
> 2010/12/19 Martin Helm <address@hidden>:
> > 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?
> >
> > But exponentiation of a diagonal matrix is trivial:
> No, no... exponentiate each row or column of a matrix by each element
> of a vector.
Ah - I see, sorry misunderstood completely. I have no good solution for that I
think repmat is the best solution or something similar to that
a .^ (diag(v)*ones(size(a)))
maybe someone knows a good trick to to it better with less overhead.
- Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix,
Martin Helm <=
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Olaf Till, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jonathan Webster, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Jonathan Webster, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Judd Storrs, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Francesco Potortì, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Judd Storrs, 2010/12/20