[vfs]

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

[vfs]

Joshi, Anand
I am in a process of implementing a file watcher functionality using
VFS. Its basically a multi threaded file watcher in JAVA 1.6 which will
watch for multiple files at different location Local, FTP, SFTP and so
on and will transfer files in any combination. Since this is a multi
threaded design, I want somebody to point me out to the right
information about Multithreading and Common VFS.

 

Thanks
Standard & Poor's: Empowering Investors and Markets for 150 Years
 
--------------------------------------------------------

The information contained in this message is intended only for the recipient, and may be a confidential attorney-client communication or may otherwise be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, please be aware that any dissemination or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by replying to the message and deleting it from your computer. The McGraw-Hill Companies, Inc. reserves the right, subject to applicable local law, to monitor and review the content of any electronic message or information sent to or from McGraw-Hill employee e-mail addresses without informing the sender or recipient of the message.
--------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

[Math] BigDecimal to power

Andy Turner
Hi,

I've implemented code for calculating a BigDecimal raised to the power of another BigDecimal and which returns the result rounded to a specified number of decimal places. It is in the maths package of my Generic library and can be found via the following URL:
http://www.geog.leeds.ac.uk/people/a.turner/src/andyt/java/generic/

There are no third party dependencies. I have not fully tested the code and already after I released I found a bug which is only updated in subversion repository. Anyway in general the methods work and should be generally useful. I looked for code to do this two years ago and although I expect there are other implementations, I had no luck finding any and this week I bit the bullet.

I have posted on a few forums today about this to try to encourage uptake.

Maybe you have some suggestions about where it goes from here? Maybe it is something for commons Math?

Best wishes,

Andy
http://www.geog.leeds.ac.uk/people/a.turner/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

Gary Gregory
For commons math you'd have to change the license to asl 2.

Gary

On Dec 16, 2010, at 9:07, "Andy Turner" <[hidden email]> wrote:

> Hi,
>
> I've implemented code for calculating a BigDecimal raised to the power of another BigDecimal and which returns the result rounded to a specified number of decimal places. It is in the maths package of my Generic library and can be found via the following URL:
> http://www.geog.leeds.ac.uk/people/a.turner/src/andyt/java/generic/
>
> There are no third party dependencies. I have not fully tested the code and already after I released I found a bug which is only updated in subversion repository. Anyway in general the methods work and should be generally useful. I looked for code to do this two years ago and although I expect there are other implementations, I had no luck finding any and this week I bit the bullet.
>
> I have posted on a few forums today about this to try to encourage uptake.
>
> Maybe you have some suggestions about where it goes from here? Maybe it is something for commons Math?
>
> Best wishes,
>
> Andy
> http://www.geog.leeds.ac.uk/people/a.turner/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Math] BigDecimal to power

Andy Turner
Can do if the code is wanted...
________________________________________
From: Gary Gregory [[hidden email]]
Sent: 16 December 2010 18:58
To: Commons Users List
Cc: [hidden email]
Subject: Re: [Math] BigDecimal to power

For commons math you'd have to change the license to asl 2.

Gary

On Dec 16, 2010, at 9:07, "Andy Turner" <[hidden email]> wrote:

> Hi,
>
> I've implemented code for calculating a BigDecimal raised to the power of another BigDecimal and which returns the result rounded to a specified number of decimal places. It is in the maths package of my Generic library and can be found via the following URL:
> http://www.geog.leeds.ac.uk/people/a.turner/src/andyt/java/generic/
>
> There are no third party dependencies. I have not fully tested the code and already after I released I found a bug which is only updated in subversion repository. Anyway in general the methods work and should be generally useful. I looked for code to do this two years ago and although I expect there are other implementations, I had no luck finding any and this week I bit the bullet.
>
> I have posted on a few forums today about this to try to encourage uptake.
>
> Maybe you have some suggestions about where it goes from here? Maybe it is something for commons Math?
>
> Best wishes,
>
> Andy
> http://www.geog.leeds.ac.uk/people/a.turner/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Math] BigDecimal to power

Andy Turner
Hi,

I changed the license for my code and wrote some junit tests while refactoring.

I think there are many improvements since I originally emailed. I have not had any off list expressions of interest and I wonder if there is yet any other interest in making this available as part of Commons Math?

I have added an entry in the wish list and created a JIRA issue (which I am watching) and attached a zip file containing a copy of the src and tests code to it:
https://issues.apache.org/jira/browse/MATH-490 

The main reason I developed this code was that I needed to raise a BigDecimal to the power of another BigDecimal. Dealing with all the different cases has been a challenge. Although I'm not 100% confident I have handled every case, I'm reasonably happy with this effort.

In terms of junit tests: where the expected result was not obvious to me and I could think of no obvious other way to calculate it using the java core code, I have used results returned from my methods to set expected results. This is better than nothing, but developers of this code should be warned that test failures may be a result of original errors rather than as a consequence of changes they have made. I wonder if there are some canonical math compliance test data that I should use... I was thinking that I should document or use some attribution or something to distinguish the different types of test if I got this far.

Does anyone have any good advice for me at this stage?

Best wishes,

Andy
http://www.geog.leeds.ac.uk/people/a.turner/
 

-----Original Message-----
From: Andy Turner [mailto:[hidden email]]
Sent: 16 December 2010 22:29
To: Commons Users List
Subject: RE: [Math] BigDecimal to power

Can do if the code is wanted...
________________________________________
From: Gary Gregory [[hidden email]]
Sent: 16 December 2010 18:58
To: Commons Users List
Cc: [hidden email]
Subject: Re: [Math] BigDecimal to power

For commons math you'd have to change the license to asl 2.

Gary

On Dec 16, 2010, at 9:07, "Andy Turner" <[hidden email]> wrote:

> Hi,
>
> I've implemented code for calculating a BigDecimal raised to the power of another BigDecimal and which returns the result rounded to a specified number of decimal places. It is in the maths package of my Generic library and can be found via the following URL:
> http://www.geog.leeds.ac.uk/people/a.turner/src/andyt/java/generic/
>
> There are no third party dependencies. I have not fully tested the code and already after I released I found a bug which is only updated in subversion repository. Anyway in general the methods work and should be generally useful. I looked for code to do this two years ago and although I expect there are other implementations, I had no luck finding any and this week I bit the bullet.
>
> I have posted on a few forums today about this to try to encourage uptake.
>
> Maybe you have some suggestions about where it goes from here? Maybe it is something for commons Math?
>
> Best wishes,
>
> Andy
> http://www.geog.leeds.ac.uk/people/a.turner/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: RE: [Math] BigDecimal to power

Mikkel Meyer Andersen-2
Hi,

First of all, thanks!

In terms of power, I have already submitted a patch proposal for dealing
with matrix powers based on repeated squaring. I haven't looked at your code
yet, but we might be able to make a common codebase by smart interfacing.
I'll take a look at it, hopefully some time next week.

Cheers, Mikkel.
Den 20/01/2011 19.45 skrev "Andy Turner" <[hidden email]>:
> Hi,
>
> I changed the license for my code and wrote some junit tests while
refactoring.
>
> I think there are many improvements since I originally emailed. I have not
had any off list expressions of interest and I wonder if there is yet any
other interest in making this available as part of Commons Math?
>
> I have added an entry in the wish list and created a JIRA issue (which I
am watching) and attached a zip file containing a copy of the src and tests
code to it:
> https://issues.apache.org/jira/browse/MATH-490
>
> The main reason I developed this code was that I needed to raise a
BigDecimal to the power of another BigDecimal. Dealing with all the
different cases has been a challenge. Although I'm not 100% confident I have
handled every case, I'm reasonably happy with this effort.
>
> In terms of junit tests: where the expected result was not obvious to me
and I could think of no obvious other way to calculate it using the java
core code, I have used results returned from my methods to set expected
results. This is better than nothing, but developers of this code should be
warned that test failures may be a result of original errors rather than as
a consequence of changes they have made. I wonder if there are some
canonical math compliance test data that I should use... I was thinking that
I should document or use some attribution or something to distinguish the
different types of test if I got this far.

>
> Does anyone have any good advice for me at this stage?
>
> Best wishes,
>
> Andy
> http://www.geog.leeds.ac.uk/people/a.turner/
>
>
> -----Original Message-----
> From: Andy Turner [mailto:[hidden email]]
> Sent: 16 December 2010 22:29
> To: Commons Users List
> Subject: RE: [Math] BigDecimal to power
>
> Can do if the code is wanted...
> ________________________________________
> From: Gary Gregory [[hidden email]]
> Sent: 16 December 2010 18:58
> To: Commons Users List
> Cc: [hidden email]
> Subject: Re: [Math] BigDecimal to power
>
> For commons math you'd have to change the license to asl 2.
>
> Gary
>
> On Dec 16, 2010, at 9:07, "Andy Turner" <[hidden email]> wrote:
>
>> Hi,
>>
>> I've implemented code for calculating a BigDecimal raised to the power of
another BigDecimal and which returns the result rounded to a specified
number of decimal places. It is in the maths package of my Generic library
and can be found via the following URL:
>> http://www.geog.leeds.ac.uk/people/a.turner/src/andyt/java/generic/
>>
>> There are no third party dependencies. I have not fully tested the code
and already after I released I found a bug which is only updated in
subversion repository. Anyway in general the methods work and should be
generally useful. I looked for code to do this two years ago and although I
expect there are other implementations, I had no luck finding any and this
week I bit the bullet.
>>
>> I have posted on a few forums today about this to try to encourage
uptake.
>>
>> Maybe you have some suggestions about where it goes from here? Maybe it
is something for commons Math?

>>
>> Best wishes,
>>
>> Andy
>> http://www.geog.leeds.ac.uk/people/a.turner/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

Gilles Sadowski
In reply to this post by Andy Turner
Hello.

When proposing code, I think that you might get better attention by posting
to the "dev" ML.

> I changed the license for my code and wrote some junit tests while refactoring.
>
> I think there are many improvements since I originally emailed. I have not had any off list expressions of interest and I wonder if there is yet any other interest in making this available as part of Commons Math?

If the functionality is desired (let's wait for the others to answer this),
there would nevertheless be quite some changes needed for the code to fit in
Commons Math; a few things I noticed by glancing at the source:

* "main" methods
* access to "System.out" for printing
* not fully documented
* class names contain an underscore

> [...]
>
> The main reason I developed this code was that I needed to raise a BigDecimal to the power of another BigDecimal. Dealing with all the different cases has been a challenge. Although I'm not 100% confident I have handled every case, I'm reasonably happy with this effort.
>
> In terms of junit tests: where the expected result was not obvious to me and I could think of no obvious other way to calculate it using the java core code, I have used results returned from my methods to set expected results. This is better than nothing, but developers of this code should be warned that test failures may be a result of original errors rather than as a consequence of changes they have made. I wonder if there are some canonical math compliance test data that I should use... I was thinking that I should document or use some attribution or something to distinguish the different types of test if I got this far.
>
> Does anyone have any good advice for me at this stage?

It certainly would be better to compare with the results of another library.
At least, the "self-tests" should be marked as such.

I know that Perl has "Math::BigInt" and "Math::BigFloat" modules that might
be used to compute independent results.


Thanks,
Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

sebb-2-2
On 21 January 2011 13:19, Gilles Sadowski <[hidden email]> wrote:

> Hello.
>
> When proposing code, I think that you might get better attention by posting
> to the "dev" ML.
>
>> I changed the license for my code and wrote some junit tests while refactoring.
>>
>> I think there are many improvements since I originally emailed. I have not had any off list expressions of interest and I wonder if there is yet any other interest in making this available as part of Commons Math?
>
> If the functionality is desired (let's wait for the others to answer this),
> there would nevertheless be quite some changes needed for the code to fit in
> Commons Math; a few things I noticed by glancing at the source:
>
> * "main" methods
> * access to "System.out" for printing
> * not fully documented
> * class names contain an underscore

Also package names are not org.apache.commons.mathx.

There are also some @author tags which ought to be removed - credit
can be give elsewhere.
[Author tags quickly become unmanageable in code that is developed by
a community]

>> [...]
>>
>> The main reason I developed this code was that I needed to raise a BigDecimal to the power of another BigDecimal. Dealing with all the different cases has been a challenge. Although I'm not 100% confident I have handled every case, I'm reasonably happy with this effort.
>>
>> In terms of junit tests: where the expected result was not obvious to me and I could think of no obvious other way to calculate it using the java core code, I have used results returned from my methods to set expected results. This is better than nothing, but developers of this code should be warned that test failures may be a result of original errors rather than as a consequence of changes they have made. I wonder if there are some canonical math compliance test data that I should use... I was thinking that I should document or use some attribution or something to distinguish the different types of test if I got this far.
>>
>> Does anyone have any good advice for me at this stage?
>
> It certainly would be better to compare with the results of another library.
> At least, the "self-tests" should be marked as such.
>
> I know that Perl has "Math::BigInt" and "Math::BigFloat" modules that might
> be used to compute independent results.

Also, some of the test cases are very large - it's better to have lots
of smaller tests, so all errors can be found at once.

>
> Thanks,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Math] BigDecimal to power

Andy Turner
I can spend some time to change the code. I'll wait to here from others if the functionality is wanted as part of Commons Math before I do too much...

I am using the Netbeans IDE with which it is trivial to make some of the changes you suggest (package and class naming, removing the @author tags and main methods).

I'll generate javadocs and make sure there are no issues with that. I'll make sure there is a clear description of each method and that any conditions or information about parameter values is detailed. I'll go through all the code and consider adding more comments in the methods to explain what is going on. Before I do this last bit, I'll have a look at some of the Maths source code to try and get a clearer idea of what is wanted in terms of in code documentation. Is there a particularly well documented class that anyone suggests I look at, or is there another resource you advise I use as a guide?

There must be reasons why System.out calls are not wanted. I shall make sure to use System.err when this is more appropriate. I have had issues with logging in the past (in non-test code) to do with it using too many of a very limited addressing (I think it was to do with file handlers with parallelised code executed on compute elements with multiple processors). Anyway, maybe I was doing something wrong and I should learn to do logging better.

I shall mark those tests that are "self tests" and distinguish them from tests that are based on my human reckoning. I'll also try to add more tests that use other standard Java and Commons code. I was thinking to add comments in the testing code along the following lines:
// Source of tests expected result = "self test"
// Source of tests expected result = "human calculation"
// Source of tests expected result = "java.lang.Math.min(int,int)"
// Source of tests expected result = "Perl"

The library ojalgo (http://ojalgo.org/) might be used for some tests - it provides higher precision for some arithmetic than the standard offerings.

I'll look into using the Perl you mention. I can see some methods that could be used for equivallence testing, although not all methods I have developed have an equivallent (noteably, there is no power function for BigFloat as yet):
http://perldoc.perl.org/Math/BigInt.html#bpow%28%29
http://perldoc.perl.org/Math/BigFloat.html#bexp%28%29

For each class I aimed to provide a test method for every public method, but that within that test method, there may be multiple tests for different parameter inputs. With regard some tests being too large, what is the prefered way to break these up?

Thanks for showing some interest :-)

Best wishes,

Andy
________________________________________
From: sebb [[hidden email]]
Sent: 21 January 2011 13:36
To: Commons Developers List; [hidden email]
Subject: Re: [Math] BigDecimal to power

On 21 January 2011 13:19, Gilles Sadowski <[hidden email]> wrote:

> Hello.
>
> When proposing code, I think that you might get better attention by posting
> to the "dev" ML.
>
>> I changed the license for my code and wrote some junit tests while refactoring.
>>
>> I think there are many improvements since I originally emailed. I have not had any off list expressions of interest and I wonder if there is yet any other interest in making this available as part of Commons Math?
>
> If the functionality is desired (let's wait for the others to answer this),
> there would nevertheless be quite some changes needed for the code to fit in
> Commons Math; a few things I noticed by glancing at the source:
>
> * "main" methods
> * access to "System.out" for printing
> * not fully documented
> * class names contain an underscore

Also package names are not org.apache.commons.mathx.

There are also some @author tags which ought to be removed - credit
can be give elsewhere.
[Author tags quickly become unmanageable in code that is developed by
a community]

>> [...]
>>
>> The main reason I developed this code was that I needed to raise a BigDecimal to the power of another BigDecimal. Dealing with all the different cases has been a challenge. Although I'm not 100% confident I have handled every case, I'm reasonably happy with this effort.
>>
>> In terms of junit tests: where the expected result was not obvious to me and I could think of no obvious other way to calculate it using the java core code, I have used results returned from my methods to set expected results. This is better than nothing, but developers of this code should be warned that test failures may be a result of original errors rather than as a consequence of changes they have made. I wonder if there are some canonical math compliance test data that I should use... I was thinking that I should document or use some attribution or something to distinguish the different types of test if I got this far.
>>
>> Does anyone have any good advice for me at this stage?
>
> It certainly would be better to compare with the results of another library.
> At least, the "self-tests" should be marked as such.
>
> I know that Perl has "Math::BigInt" and "Math::BigFloat" modules that might
> be used to compute independent results.

Also, some of the test cases are very large - it's better to have lots
of smaller tests, so all errors can be found at once.

>
> Thanks,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

Luc Maisonobe
Hi Andy,

Le 21/01/2011 18:22, Andy Turner a écrit :
> I can spend some time to change the code. I'll wait to here from
> others if the functionality is wanted as part of Commons Math before
> I do too much...

It may interesting to add this feature. I didn't look precisely but how
does it compare to our arbitrary precision dflp package ?

>
> I am using the Netbeans IDE with which it is trivial to make some of
> the changes you suggest (package and class naming, removing the
> @author tags and main methods).
>
> I'll generate javadocs and make sure there are no issues with that.
> I'll make sure there is a clear description of each method and that
> any conditions or information about parameter values is detailed.
> I'll go through all the code and consider adding more comments in the
> methods to explain what is going on. Before I do this last bit, I'll
> have a look at some of the Maths source code to try and get a clearer
> idea of what is wanted in terms of in code documentation. Is there a
> particularly well documented class that anyone suggests I look at, or
> is there another resource you advise I use as a guide?

There are guidelines here: <http://commons.apache.org/math/developers.html>

There is also a code style configuration file available here
<http://people.apache.org/~luc/Apache-commons.xml>, but it is for Eclipse.

In order to check your code is compliant with some of our rules, you can
use checkstyle. There is a checkstyle configuration file at the top of
the source distribution.

>
> There must be reasons why System.out calls are not wanted. I shall
> make sure to use System.err when this is more appropriate. I have had

Neither System.out nor System.err are allowed. Apache Commons Math is a
low level library and it can be used in many different systems. It can
be used in applications that are not connected to a console. Errors are
provided by exceptions and the application developers can do what they
want with them, printing them by temselves to System.out or System.err
for example, but also displaying a popup window in a graphical
environment, sending a notification through network in a distributed
environment, logging something in a file, or a database, or a system log ...

Also the units tests should be able to run unattended in continuous
integrations systems like Gump, Confluence, Hudson or in our maven build
system... So even in tests, we don't allow output. We use only the
automatic output features of Junit when test fails (these outputs are in
fact already wrapped by these integration frameworks).

> issues with logging in the past (in non-test code) to do with it
> using too many of a very limited addressing (I think it was to do
> with file handlers with parallelised code executed on compute
> elements with multiple processors). Anyway, maybe I was doing
> something wrong and I should learn to do logging better.

Logging is a controversial issue here. We have had numerous discussions
about it in the past. You can see for example this thread:
<http://markmail.org/thread/a5jl6fkjjtm5qbsw>, or the part of another
thread that starts roughly at this message:
<http://markmail.org/message/6besiqutg4bh52zw> or even this very old
message: <http://markmail.org/message/ml7gxlmszk7xkcly>.

The bottom line is: no logging in Commons Math.

>
> I shall mark those tests that are "self tests" and distinguish them
> from tests that are based on my human reckoning. I'll also try to add
> more tests that use other standard Java and Commons code. I was
> thinking to add comments in the testing code along the following
> lines: // Source of tests expected result = "self test" // Source of
> tests expected result = "human calculation" // Source of tests
> expected result = "java.lang.Math.min(int,int)" // Source of tests
> expected result = "Perl"

This would be fine if you can do it. We didn't did it on many of our
tests and it is one of our problems.

>
> The library ojalgo (http://ojalgo.org/) might be used for some tests
> - it provides higher precision for some arithmetic than the standard
> offerings.

We do have an arbitrary precision package in Commons Math, the dflp
pacakge. You specify the precision you need, and you have available all
traditional functions (including trigonometric, hyperbolic, exponentials
...)

>
> I'll look into using the Perl you mention. I can see some methods
> that could be used for equivallence testing, although not all methods
> I have developed have an equivallent (noteably, there is no power
> function for BigFloat as yet):
> http://perldoc.perl.org/Math/BigInt.html#bpow%28%29 
> http://perldoc.perl.org/Math/BigFloat.html#bexp%28%29
>
> For each class I aimed to provide a test method for every public
> method, but that within that test method, there may be multiple tests
> for different parameter inputs. With regard some tests being too
> large, what is the prefered way to break these up?

We mainly break up tests at top functional level only.

best regards,
Luc

>
> Thanks for showing some interest :-)
>
> Best wishes,
>
> Andy ________________________________________ From: sebb
> [[hidden email]] Sent: 21 January 2011 13:36 To: Commons Developers
> List; [hidden email] Subject: Re: [Math] BigDecimal to
> power
>
> On 21 January 2011 13:19, Gilles Sadowski
> <[hidden email]> wrote:
>> Hello.
>>
>> When proposing code, I think that you might get better attention by
>> posting to the "dev" ML.
>>
>>> I changed the license for my code and wrote some junit tests
>>> while refactoring.
>>>
>>> I think there are many improvements since I originally emailed. I
>>> have not had any off list expressions of interest and I wonder if
>>> there is yet any other interest in making this available as part
>>> of Commons Math?
>>
>> If the functionality is desired (let's wait for the others to
>> answer this), there would nevertheless be quite some changes needed
>> for the code to fit in Commons Math; a few things I noticed by
>> glancing at the source:
>>
>> * "main" methods * access to "System.out" for printing * not fully
>> documented * class names contain an underscore
>
> Also package names are not org.apache.commons.mathx.
>
> There are also some @author tags which ought to be removed - credit
> can be give elsewhere. [Author tags quickly become unmanageable in
> code that is developed by a community]
>
>>> [...]
>>>
>>> The main reason I developed this code was that I needed to raise
>>> a BigDecimal to the power of another BigDecimal. Dealing with all
>>> the different cases has been a challenge. Although I'm not 100%
>>> confident I have handled every case, I'm reasonably happy with
>>> this effort.
>>>
>>> In terms of junit tests: where the expected result was not
>>> obvious to me and I could think of no obvious other way to
>>> calculate it using the java core code, I have used results
>>> returned from my methods to set expected results. This is better
>>> than nothing, but developers of this code should be warned that
>>> test failures may be a result of original errors rather than as a
>>> consequence of changes they have made. I wonder if there are some
>>> canonical math compliance test data that I should use... I was
>>> thinking that I should document or use some attribution or
>>> something to distinguish the different types of test if I got
>>> this far.
>>>
>>> Does anyone have any good advice for me at this stage?
>>
>> It certainly would be better to compare with the results of another
>> library. At least, the "self-tests" should be marked as such.
>>
>> I know that Perl has "Math::BigInt" and "Math::BigFloat" modules
>> that might be used to compute independent results.
>
> Also, some of the test cases are very large - it's better to have
> lots of smaller tests, so all errors can be found at once.
>
>>
>> Thanks, Gilles
>>
>> ---------------------------------------------------------------------
>>
>>
To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
> ---------------------------------------------------------------------
>
>
To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Math] BigDecimal to power

Andy Turner
Hi and thanks Luc,

> It may interesting to add this feature. I didn't look precisely but how
> does it compare to our arbitrary precision dflp package ?

I don't see a dflp package in 2.1. Can you give me a better pointer? I want to compare...

If anyone knows a way of raising a BigDecimal to the power of another BigDecimal and getting the result correct to a specified number of decimal places using commons Math or anything else open source, please let us know.

I found http://gmplib.org/, which looks to implement some arbitrary rational number arithmetic (http://gmplib.org/manual/Rational-Arithmetic.html#Rational-Arithmetic). It does not look like Java, but I'm going to take a look soon anyway...

> Neither System.out nor System.err are allowed. Apache Commons Math is a
> low level library and it can be used in many different systems. It can
> be used in applications that are not connected to a console. Errors are
> provided by exceptions and the application developers can do what they
> want with them, printing them by temselves to System.out or System.err
> for example, but also displaying a popup window in a graphical
> environment, sending a notification through network in a distributed
> environment, logging something in a file, or a database, or a system log ...
>
> Also the units tests should be able to run unattended in continuous
> integrations systems like Gump, Confluence, Hudson or in our maven build
> system... So even in tests, we don't allow output. We use only the
> automatic output features of Junit when test fails (these outputs are in
> fact already wrapped by these integration frameworks).

Thanks, that's clear, I can see a better way now :-)

Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

Luc Maisonobe

----- "Andy Turner" <[hidden email]> a écrit :

> Hi and thanks Luc,
>
> > It may interesting to add this feature. I didn't look precisely but
> how
> > does it compare to our arbitrary precision dflp package ?
>
> I don't see a dflp package in 2.1. Can you give me a better pointer? I
> want to compare...

It is in the subversion repository. You'll have to check it out.

Luc

>
> If anyone knows a way of raising a BigDecimal to the power of another
> BigDecimal and getting the result correct to a specified number of
> decimal places using commons Math or anything else open source, please
> let us know.
>
> I found http://gmplib.org/, which looks to implement some arbitrary
> rational number arithmetic
> (http://gmplib.org/manual/Rational-Arithmetic.html#Rational-Arithmetic).
> It does not look like Java, but I'm going to take a look soon
> anyway...
>
> > Neither System.out nor System.err are allowed. Apache Commons Math
> is a
> > low level library and it can be used in many different systems. It
> can
> > be used in applications that are not connected to a console. Errors
> are
> > provided by exceptions and the application developers can do what
> they
> > want with them, printing them by temselves to System.out or
> System.err
> > for example, but also displaying a popup window in a graphical
> > environment, sending a notification through network in a
> distributed
> > environment, logging something in a file, or a database, or a system
> log ...
> >
> > Also the units tests should be able to run unattended in continuous
> > integrations systems like Gump, Confluence, Hudson or in our maven
> build
> > system... So even in tests, we don't allow output. We use only the
> > automatic output features of Junit when test fails (these outputs
> are in
> > fact already wrapped by these integration frameworks).
>
> Thanks, that's clear, I can see a better way now :-)
>
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

paul womack
In reply to this post by Andy Turner
Andy Turner wrote:
> Hi,
>
> I've implemented code for calculating a BigDecimal raised to the power of another BigDecimal and which returns the result rounded to a specified number of decimal places. It is in the maths package of my Generic library and can be found via the following URL:
> http://www.geog.leeds.ac.uk/people/a.turner/src/andyt/java/generic/
>
> There are no third party dependencies. I have not fully tested the code and already after I released I found a bug which is only updated in subversion repository. Anyway in general the methods work and should be generally useful. I looked for code to do this two years ago and although I expect there are other implementations, I had no luck finding any and this week I bit the bullet.

I was recently doing something unrelated in Excel and OOCalc.

Someone had pointed out that cube root can (under some circumstances) be a useful
transform for the x axis when plotting a graph.

It's similar to log(x) for positive x, but has (very!) different behaviour
for x < 1, and (very!) different behaviour for x < 0. In particular
the sign of the cube root is the same as the sign of x.

This applies for all odd numbered roots. Anyway.

I discovered that Excel is quite capable of evaluating power(x, 1/3) for negative x,
where oocalc isn't.

I assume that oocalc is using the "obvious" but flawed implementation of power(x, y)

invlog(log(x) *  y))

You might want to check your implementation under such data.

    BugBear

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Math] BigDecimal to power

Andy Turner
Indeed, dealing with all the special cases involves dealing with complex roots and my implementation doesn't. So there is more work to do, but I don't think it is too much... I am confident that it will do cube roots though I should check some more of these :-)

Anyway, it seems this functionality is still some way off making it into Commons Math if indeed it does...

Best wishes,

Andy


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Math] BigDecimal to power

Andy Turner
In reply to this post by Luc Maisonobe
>> I don't see a dflp package in 2.1. Can you give me a better pointer? I
>> want to compare...
>
> It is in the subversion repository. You'll have to check it out.

I did, but have not found it!

I did find other pow functions in the org.apache.commons.math.util.MathUtils class.

Andy

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

Phil Steitz
On Thu, Jan 27, 2011 at 1:33 PM, Andy Turner <[hidden email]> wrote:
>>> I don't see a dflp package in 2.1. Can you give me a better pointer? I
>>> want to compare...
>>
>> It is in the subversion repository. You'll have to check it out.
>
> I did, but have not found it!
>
It is a top-level package:
 src/main/java/org/apache/commons/math/dfp/ in either trunk or the
MATH_2_X branch

You can find instructions on how to checkout the sources here:
http://commons.apache.org/svninfo.html

At the moment,
http://svn.apache.org/repos/asf/commons/proper/math/trunk/ contains
3.0 development sources and
http://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X/
is the where 2.2 work is happening.  The package you are looking for
is in both and (I think) identical.

Phil
> I did find other pow functions in the org.apache.commons.math.util.MathUtils class.
>
> Andy
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Math] BigDecimal to power

Luc Maisonobe
In reply to this post by Andy Turner
Le 27/01/2011 19:33, Andy Turner a écrit :
>>> I don't see a dflp package in 2.1. Can you give me a better pointer? I
>>> want to compare...
>>
>> It is in the subversion repository. You'll have to check it out.
>
> I did, but have not found it!

Sorry, I wrote dflp but it is dfp. It is a top level package.
You can see it here fro trunk (i.e. where work on version 3.0 is done):
<http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/dfp/>
and here for upcoming 2.2 version:
<http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/dfp/>

Luc
>
> I did find other pow functions in the org.apache.commons.math.util.MathUtils class.
>
> Andy
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]