<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://community.opensourcedotnet.info/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Math.NET Mathematics Library</title><link>http://community.opensourcedotnet.info/forums/5.aspx</link><description>Opensource .NET framework for numeric and symbolic mathematics.</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56110.aspx</link><pubDate>Mon, 31 Mar 2008 10:07:26 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56110</guid><dc:creator>Christoph R&amp;#252;egg</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56110.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56110</wfw:commentRss><description>&lt;p&gt;FYI: The Iridium 2008 March Release (v2008.3.12.405) is now &lt;a href="http://community.opensourcedotnet.info/files/folders/mathnet/entry56105.aspx"&gt;available&lt;/a&gt;, which includes the mentioned fix.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56072.aspx</link><pubDate>Thu, 13 Mar 2008 06:50:20 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56072</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56072.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56072</wfw:commentRss><description>&lt;p&gt;Hi Christoph,&lt;/p&gt;
&lt;p&gt;Thank you for looking into it.&lt;/p&gt;
&lt;p&gt;Keep up the good work. :)&lt;/p&gt;
&lt;p&gt;Cheers.&lt;/p&gt;
&lt;p&gt;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56070.aspx</link><pubDate>Wed, 12 Mar 2008 12:55:28 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56070</guid><dc:creator>Christoph R&amp;#252;egg</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56070.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56070</wfw:commentRss><description>&lt;p&gt;Your issue around Complex Power should be fixed in revision 382, see &lt;a href="http://tracker.opensourcedotnet.info/Default.aspx?p=2&amp;amp;i=107"&gt;IRID-107&lt;/a&gt;. However, I didn&amp;#39;t touch other methods.&lt;/p&gt;&lt;p&gt;Note that Complex Power still retuns NaN, in the case (0) ^ (z) where Re(z) = 0 but Im(z) != 0. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56051.aspx</link><pubDate>Fri, 08 Feb 2008 16:30:36 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56051</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56051.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56051</wfw:commentRss><description>&lt;p&gt;Ok, thanks for looking into it.&lt;/p&gt;
&lt;p&gt;Btw, in the meantime I have been trying to write my own Complex struct which is the only thing I need in my current project.&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;goal is to have something that *never* gives back a NaN whichever the arguments, and this is proving to be much more difficult than I could imagine.&lt;/p&gt;
&lt;p&gt;For instance, I am stuck with a basic pair of functions, FixedModulus and FixedAngle, the latter leveraging the first, whose purpose is simply to reduce the angle to the canonical (-pi, pi] range. Trivial, were it not that I am getting mad in defining what should happen at the boundaries, that is when the divisor is 0 or when one or both of the operands are infinite.&lt;/p&gt;
&lt;p&gt;By digging the web I have found something very interesting about &amp;quot;zero-module&amp;quot; and &amp;quot;infinity-module&amp;quot;: &lt;a href="http://www.gwiep.net/books/parad09.htm"&gt;http://www.gwiep.net/books/parad09.htm&lt;/a&gt;. Still it doesn&amp;#39;t cover all needed cases and I even wander if what I&amp;#39;m trying to do does make any sense at all.&lt;/p&gt;
&lt;p&gt;Anyway,&amp;nbsp;despite I am nothing more than passionate with Math, I am a professional programmer, so should you be interested in what I am trying, should you be interested in introducing some of this into your own library, and/or should you have any kind of suggestions (even a get a life :)...&amp;nbsp;well, you&amp;#39;d be infinitely welcome!&lt;/p&gt;
&lt;p&gt;In case, just let me know.&lt;/p&gt;
&lt;p&gt;Cheers. -LV&lt;br /&gt;&lt;font color="#008000" size="2"&gt;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56050.aspx</link><pubDate>Thu, 07 Feb 2008 23:42:41 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56050</guid><dc:creator>Christoph R&amp;#252;egg</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56050.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56050</wfw:commentRss><description>&lt;p&gt;Yes, I think you&amp;#39;re right. I&amp;#39;ll have a look at all this methods and check for these cases. I&amp;#39;ll let you know here when I create a bug in the &lt;a href="http://tracker.opensourcedotnet.info/Default.aspx?IRID"&gt;issue tracker&lt;/a&gt;. &lt;/p&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56046.aspx</link><pubDate>Sun, 03 Feb 2008 20:23:32 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56046</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56046.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56046</wfw:commentRss><description>&lt;p&gt;Sorry, should read:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(value1.IsZero &amp;amp;&amp;amp; value2.IsZero)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Complex.NaN;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(value1.IsZero)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Complex.Zero;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return value1.Power(value2);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56043.aspx</link><pubDate>Sun, 03 Feb 2008 20:01:49 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56043</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56043.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56043</wfw:commentRss><description>&lt;p&gt;Yep, that is true and correct but does not seem to solve the issue. Indeed I now realize my post above was quite a bit off mark.&lt;/p&gt;
&lt;p&gt;If we look at the Power function for instance:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Complex Power(Complex exponent)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (exponent * NaturalLogarithm()).Exponential();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;This should return Zero when applied to number Zero, unless the exponent is Zero as well, in which case it should return NaN. At the moment it is returning NaN whichever the exponent.&lt;/p&gt;
&lt;p&gt;To reproduce this is fairly simple:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void Main(string[ args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(Complex.Zero.Power(2).ToString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(Timeout.Infinite);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;By debug-stepping into the Power function, here is what happens:&lt;/p&gt;
&lt;p&gt;1) NaturalLogarithm() correctly returns (re=-Infinity, im=0);&lt;/p&gt;
&lt;p&gt;Then it goes to the * operator:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static Complex operator *(Complex multiplicand, Complex multiplier)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Complex(multiplicand.real * multiplier.real - multiplicand.imag * multiplier.imag, multiplicand.real * multiplier.imag + multiplicand.imag * multiplier.real);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;2) Here the * operator fails in calculating the imaginary party, bacause re=2*-Inf-0*0=-Inf is correct, but im=2*0+0*-Inf=NaN is not, and here we get the NaN.&lt;/p&gt;
&lt;p&gt;In general, I guess the basic problem is the built-in double operators and the Math class cannot check the order of an infinite versus the order of an infinitesimal (what above I called checking for zero denominators and the like), so maybe here we have another instance of a special case (like when you check for IsReal or IsRealPositive on top of many functions).&lt;/p&gt;
&lt;p&gt;Well, hope it is not too confused, anyway a very simple test like the above Complex.Zero.Power(2) is enough to show the problem.&lt;/p&gt;
&lt;p&gt;To work around this, my program&amp;#39;s code at the moment looks like:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(value1.IsZero)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Complex.Zero;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return value1.Power(value2);&lt;/p&gt;
&lt;p&gt;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56039.aspx</link><pubDate>Sun, 03 Feb 2008 10:25:06 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56039</guid><dc:creator>Christoph R&amp;#252;egg</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56039.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56039</wfw:commentRss><description>This should actually work in the new &lt;a href="http://community.opensourcedotnet.info/files/folders/mathnet/entry56036.aspx"&gt;release from yesterday&lt;/a&gt;: The natural logarithm of zero returns a new complex value with zero imaginary part and minus infinity real part.&lt;br /&gt;</description></item><item><title>Re: Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56038.aspx</link><pubDate>Sun, 03 Feb 2008 09:53:16 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56038</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56038.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56038</wfw:commentRss><description>&lt;p&gt;P.S. I have seen your comment about IsReal that has become IsPositiveReal (&lt;a href="http://community.opensourcedotnet.info/forums/t/418.aspx"&gt;http://community.opensourcedotnet.info/forums/t/418.aspx&lt;/a&gt;), but I guess that won&amp;#39;t solve this one.&lt;/p&gt;
&lt;p&gt;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Possible bug in Complex class?</title><link>http://community.opensourcedotnet.info/forums/thread/56037.aspx</link><pubDate>Sun, 03 Feb 2008 09:41:40 GMT</pubDate><guid isPermaLink="false">5e0c48d9-3477-4155-b28a-6cca64e53d2a:56037</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://community.opensourcedotnet.info/forums/thread/56037.aspx</comments><wfw:commentRss>http://community.opensourcedotnet.info/forums/commentrss.aspx?SectionID=5&amp;PostID=56037</wfw:commentRss><description>&lt;p&gt;Hello Mr Ruegg,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been &amp;nbsp;trying to use your Math.NET library for a simple project of mine where I need some basic complex math, and&amp;nbsp;I must say the whole library looks very interesting and promising.&lt;/p&gt;
&lt;p&gt;Anyway, I have noticed a strange behaviour in that I get an exception if I call the Exponent function on a complex whose value is zero.&lt;/p&gt;
&lt;p&gt;By inspecting the code, I have tracked it down to the &lt;font size="2"&gt;&lt;strong&gt;NaturalLogarithm&lt;/strong&gt; function which reads like this:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// &amp;lt;summary&amp;gt;Natural Logarithm of this &amp;lt;c&amp;gt;Complex&amp;lt;/c&amp;gt; (Base E).&amp;lt;/summary&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Complex NaturalLogarithm()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(IsReal)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Complex(Math.Log(real), 0d);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Complex(0.5d * Math.Log(ModulusSquared), Argument);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;This of course fails if the number is zero, and so most of the functions in the class would fail because they rely on this &lt;strong&gt;NaturalLogarithm &lt;/strong&gt;function.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;I guess in transforming from rectangular to exponential and back, there should always be checks for zero denominators and stuff like that, anyway my mathematical background is not that strong so I might be just missing something.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt;What&amp;#39;s the culprit?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Thanks. -LV&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>