You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "DI COSTANZO (Created) (JIRA)" <ji...@apache.org> on 2011/10/03 12:10:34 UTC

[jira] [Created] (MATH-682) Pascal triangle

Pascal triangle 
----------------

                 Key: MATH-682
                 URL: https://issues.apache.org/jira/browse/MATH-682
             Project: Commons Math
          Issue Type: New Feature
    Affects Versions: 3.0
         Environment: All
            Reporter: DI COSTANZO
            Priority: Trivial


Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
double[] getTriangleCoefficient(final int order)


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Gilles (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119249#comment-13119249 ] 

Gilles commented on MATH-682:
-----------------------------

It should not be implemented in "MathUtils"; this class is already too bloated.
This concept could easily go in its own class; moreover it would make it easier to e.g. implement caching of previously computed entries. This would also allow for [additional functionality|http://en.wikipedia.org/wiki/Pascal's_triangle].

                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "DI COSTANZO (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119358#comment-13119358 ] 

DI COSTANZO commented on MATH-682:
----------------------------------

Effectively, this is a way to get Pascal triangle elements. I didn't know this method was existing and it fulfil my need. 
Actually, I was thinking to create method to retrieve every element at once for  given order, but I can build it by myself from those binomial coefficient method. 
Thanks,
Regards,

Romain

                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Sébastien Brisard (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119284#comment-13119284 ] 

Sébastien Brisard commented on MATH-682:
----------------------------------------

Fine by me! I can have a go on this one if you want (as I said, I *need* to do it fairly soon anyway, as I'm completely giving up JScience).
Sébastien
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Issue Comment Edited] (MATH-682) Pascal triangle

Posted by "Sébastien Brisard (Issue Comment Edited JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119284#comment-13119284 ] 

Sébastien Brisard edited comment on MATH-682 at 10/3/11 1:10 PM:
-----------------------------------------------------------------

Fine by me! I can have a go on this one if you want (as I said, I *need* to do it fairly soon anyway, as I'm completely giving up JScience).
Sébastien

(except of course if Romain or anyone else has an implementation, I do not want to walk on anyone's feet!)
                
      was (Author: celestin):
    Fine by me! I can have a go on this one if you want (as I said, I *need* to do it fairly soon anyway, as I'm completely giving up JScience).
Sébastien
                  
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "DI COSTANZO (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119288#comment-13119288 ] 

DI COSTANZO commented on MATH-682:
----------------------------------

I'm sorry, I wrote my last post in french ! 
I was saying :

This is my implementation for the triangle pascal declared under the 'Utils' package. The class contains a cache system to save previous computed coefficients. I also put a test file to validate the implementation. Are you ok with it ?
Thanks,

Romain
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (MATH-682) Pascal triangle

Posted by "DI COSTANZO (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

DI COSTANZO updated MATH-682:
-----------------------------

    Attachment: PascalTriangle.java
                PascalTriangleTest.java

I agree with you. It could be important to prevent too large entries. 
In the files newly added, I add a static variable defining the maximum order at which a row can be computed (arbitrary set at 50). If the entry is superior to this maximum value, another method is called and only compute the individual row. The user can arbitrary call any one of the method.
I updated the previous test class.
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Gilles (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119311#comment-13119311 ] 

Gilles commented on MATH-682:
-----------------------------

We should probably add some way to prevent an unlimited filling of the memory. It seems that the possibility to compute a single row (cf. my previous comment) would be handy if the requested order is very large.

                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Sébastien Brisard (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119235#comment-13119235 ] 

Sébastien Brisard commented on MATH-682:
----------------------------------------

I have an implementation based on JScience which I need to port to Commons-Math for personal use. I use it for symbolic calcs on polynomials. I need it to return FieldElement<T>, but it could be easily adapted to double[] as requested.
So, if this indeed is found useful for 3.0 by others, and no one else has any ready piece of code for it, I'm happy to work on that.
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Gilles (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119286#comment-13119286 ] 

Gilles commented on MATH-682:
-----------------------------

Note also that the above link contains an algorithm to compute individual rows (i.e. not needing to first compute the one above it) and the diagonals. Maybe that this could speed up some types of requests.

                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Phil Steitz (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119349#comment-13119349 ] 

Phil Steitz commented on MATH-682:
----------------------------------

This is already available via the various binomial coefficient methods. What am I missing here?
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (MATH-682) Pascal triangle

Posted by "Luc Maisonobe (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe resolved MATH-682.
--------------------------------

    Resolution: Not A Problem

The existing binomial coefficients methods in MathUtils already provide this feature.
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (MATH-682) Pascal triangle

Posted by "Gilles (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119282#comment-13119282 ] 

Gilles commented on MATH-682:
-----------------------------

Given the API differences and style problems, I think that it would be better to start from scratch, and have a class "PascalTriangle" (in package "util" if there is no better place) implement the basic functionality . Then whatever functionality relates to "PolynomialFunction" should better go to package "analysis.polynomials".
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (MATH-682) Pascal triangle

Posted by "DI COSTANZO (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

DI COSTANZO updated MATH-682:
-----------------------------

    Attachment: PascalTriangleTest.java
                PascalTriangle.java

Bonjour,

Voici mon implémentation pour le triangle de pascal. Elle est déclarée pour le package Utils. 
La classe contient un système de cache permettant de sauvegarder les précédents coefficients calculés. 
J'y ai joint un fichier de test permettant de valider l'implémentation.
Cette dernière vous convient elle ?
Merci d'avance,

Romain
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java, PascalTriangle.java, PascalTriangleTest.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (MATH-682) Pascal triangle

Posted by "Sébastien Brisard (Updated JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sébastien Brisard updated MATH-682:
-----------------------------------

    Attachment: PascalTriangle.java

Please find attached what I have for the moment. It needs some polishing to meet the CM standards, I believe. Also, it is based on JScience, which has both concepts of Field (like CM, but less convenient, I think) and Variable (which allowed me to have a method to expand binomials. As this feature is absent from CM, this would probably go).
Previously computed lines are indeed cached.
Please let me know if you think it's a good start.
As for me, I need this class to work with FieldElement, but if this is far-fetched for CM, then I'm happy keeping this feature for the specific use I have.
                
> Pascal triangle 
> ----------------
>
>                 Key: MATH-682
>                 URL: https://issues.apache.org/jira/browse/MATH-682
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.0
>         Environment: All
>            Reporter: DI COSTANZO
>            Priority: Trivial
>         Attachments: PascalTriangle.java
>
>
> Create a method to get Pascal's triangle coefficient. This method could be implemented in MathUtils, in a static way, with the following signature :
> double[] getTriangleCoefficient(final int order)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira