[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Applying function to vector by index
From: |
Paul Kienzle |
Subject: |
Re: Applying function to vector by index |
Date: |
Thu, 12 Dec 2002 09:40:11 -0500 |
User-agent: |
Mutt/1.2.5.1i |
On Tue, Dec 10, 2002 at 10:38:48AM +0100, Schloegl Alois wrote:
>
>
> Zitiere Andy Adler <address@hidden>:
>
> > I've got most of a patch in place, but there's all
> > sorts of weird side cases.
> >
> > For example, what should sparse(eye(2)).^(1+1i) give?
> >
> > Matlab gives:
> > >> full(sparse(eye(2)).^(1+1i))
> >
> > ans =
> >
> > 1 0
> > 0 1
> >
> > >> full(full(eye(2)).^(1+1i))
> >
> > ans =
> >
> > 1.0000 NaN + NaNi
> > NaN + NaNi 1.0000
> >
> >
> > That's because a^(b+ci) = e^(ln(a))*(b+ci)
> > and ln(a) is NaN
>
>
> It should be
> a^(b+ci) = e^(ln(a)*(b+ci))
> = e^(ln(a)*b + ln(a)*ci)
> = e^(ln(a)*b)*e^(ln(a)*ci)
>
> ln(a) = [0,-inf;-inf,0]
>
> Because e^(ln(a)*i) is limited (abs(e^(ln(a)*i)<=1) and b>0, the result
> converges. Hence, the result [1,0;0,1] is correct.
However, for b <=0 the result should be NaN.
Matlab is inconsistent in this case:
>> eye(2).^(-2+i)
ans =
1.0000 NaN + NaNi
NaN + NaNi 1.0000
>> sparse(eye(2)).^(-2+i)
ans =
(1,1) 1
(2,2) 1
-------------------------------------------------------------
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
-------------------------------------------------------------
- Applying function to vector by index, Iago Mosqueira, 2002/12/09
- Re: Applying function to vector by index, Mike Miller, 2002/12/09
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/09
- Re: Applying function to vector by index, Iago Mosqueira, 2002/12/09
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/09
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/09
- Re: Applying function to vector by index, Andy Adler, 2002/12/09
- Re: Applying function to vector by index, Schloegl Alois, 2002/12/10
- Re: Applying function to vector by index,
Paul Kienzle <=
- Re: Applying function to vector by index, Andy Adler, 2002/12/12
- Re: Applying function to vector by index, Schloegl Alois, 2002/12/12
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/12
- Re: Applying function to vector by index, Andy Adler, 2002/12/12
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/12
- Re: Applying function to vector by index, Andy Adler, 2002/12/11