Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1C67A97D2 for ; Fri, 9 Mar 2012 06:30:31 +0000 (UTC) Received: (qmail 56750 invoked by uid 500); 9 Mar 2012 06:30:30 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 56464 invoked by uid 500); 9 Mar 2012 06:30:26 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 56423 invoked by uid 99); 9 Mar 2012 06:30:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Mar 2012 06:30:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Mar 2012 06:30:23 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 5EEF21188E for ; Fri, 9 Mar 2012 06:30:03 +0000 (UTC) Date: Fri, 9 Mar 2012 06:30:03 +0000 (UTC) From: =?utf-8?Q?S=C3=A9bastien_Brisard_=28Updated=29_=28JIRA=29?= To: issues@commons.apache.org Message-ID: <949543790.42463.1331274603390.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2054829214.35035.1331143497658.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (MATH-765) Refactoring the vector and matrix classes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-765?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:all-tabpanel ] S=C3=A9bastien Brisard updated MATH-765: ----------------------------------- Description:=20 {panel:title=3DWarning|borderStyle=3Dsolid} This is not a bug report, but rather a summary of all discussions which hav= e taken place on the mailing list regarding the refactoring of the vector a= nd matrix classes. Indeed, it has been argued many times that the {{RealVec= tor}} and {{RealMatrix}} interfaces are really cluttered, and could benefit= from other approaches (like functional programming).=20 The description of this ticket will be updated as the discussion progresses= on the mailing-list, and new JIRA tickets will be created to carry out the= "real" work. {color:red}In order to keep this ticket tidy, contributors sh= ould refrain from commenting on this website. Instead, messages should be p= osted on the dev mailing-list{color}. {panel} h1. The current API (version 3.0) In this section, the current interfaces for vectors and matrices are compar= ed. Vectors and matrices are two mathematical objects which are very close = in nature. Their implementations should therefore be as similar as possible= . The methods will be sorted as follows * methods reflecting the mathematical structure of vector space: addition, = multiplication by a scalar, matrix-vector product, ... * methods reflecting the mathematical structure of euclidean space * ... h2. Methods reflecting the mathematical structure of vector space h3. List of the methods || {{RealVector}} || {{RealMatrix}} = || Comments || | {{RealVector add(RealVector v)}} | {{RealMatrix add(RealMatrix m)}} = | | | {{int getDimension()}} | {{int getRowDimension()}},\\ {{int= getColumnDimension()}} | | | {{RealVector mapMultiply(double d)}} | {{scalarMultiply(double d)}} = | (1) | | | {{double getTrace()}} = | | | | {{multiply(RealMatrix m)}} = | | | | {{double[] operate(double[])}} = | (2) | | | {{RealVector operate(RealVector)}}= | | | | {{RealMatrix power(int p)}} = | | | | {{double[] preMultiply(double[])}}= | (2) | | | {{RealMatrix preMultiply(RealMatri= x)}} | | | | {{RealVector preMultiply(RealVecto= r)}} | | | | {{RealMatrix transpose()}} = | | h3. Comments on the above methods h4. Comment (1) {{RealVector RealVector.mapMultiply(double)}} and {{RealMatrix RealMatrix.s= calarMultiply(double)}} perform essentially the same task. Readibility of t= he classes would be improved if they add the same name. This is very import= ant since these methods reflect the fact that the space of vectors as well = as the space of matrices are two vector spaces. h4. Comment (2) Prior to the release of version 3.0, all methods involving taking as argume= nt, or returning, {{double[]}} representing vectors were removed. The ratio= nale for this is that calling {{new ArrayRealVector(double[], false)}} is v= ery easy, and comes at virtually no cost (see MATH-653 and MATH-660). It mi= ght be worth considering the same simplification for the {{RealMatrix}} int= erface. h2. Methods reflecting the mathematical structure of euclidean space h3. List of the methods || {{RealVector}} || {{RealMatrix}} || Comments || | {{double cosine(RealVector v)}} | | | | {{double dotProduct(RealVector v)}} | | (3) | | {{double getDistance(RealVector v)}} | | | | {{double getNorm()}} | | | | {{RealVector projection(RealVector v)}} | | | | {{void unitize()}} | | (4) | | {{RealVector unitVector()}} | | | h3. Comments on the above methods h4. Comment (3) In a way, {{RealMatrix RealMatrix.transpose()}} could be seen as a method i= nherent to the euclidean structure, and the generalization of the dot produ= ct. For this reason, {{transpose()}} should probably _not_ be externalized. h4. Comment (4) This could be externalized with the visitor pattern (see below). h4. Comment (5) Could be externalized in a factory class. h2. Constructors, factory methods and related methods h2. Manipulation of entries h2. Various norms h2. Functional-programming-like methods was: {panel:title=3DWarning|borderStyle=3Dsolid} This is not a bug report, but rather a summary of all discussions which hav= e taken place on the mailing list regarding the refactoring of the vector a= nd matrix classes. Indeed, it has been argued many times that the {{RealVec= tor}} and {{RealMatrix}} interfaces are really cluttered, and could benefit= from other approaches (like functional programming).=20 The description of this ticket will be updated as the discussion progresses= on the mailing-list, and new JIRA tickets will be created to carry out the= "real" work. {color:red}In order to keep this ticket tidy, contributors sh= ould refrain from commenting on this website. Instead, messages should be p= osted on the dev mailing-list{color}. {panel} h1. The current API (version 3.0) In this section, the current interfaces for vectors and matrices are compar= ed. Vectors and matrices are two mathematical objects which are very close = in nature. Their implementations should therefore be as similar as possible= . The methods will be sorted as follows * methods reflecting the mathematical structure of vector space: addition, = multiplication by a scalar, matrix-vector product, ... * methods reflecting the mathematical structure of euclidean space * ... h2. Methods reflecting the mathematical structure of vector space h3. List of the methods || {{RealVector}} || {{RealMatrix}} = || Comments || | {{RealVector add(RealVector v)}} | {{RealMatrix add(RealMatrix m)}} = | | | {{int getDimension()}} | {{int getRowDimension()}},\\ {{int= getColumnDimension()}} | | | {{RealVector mapMultiply(double d)}} | {{scalarMultiply(double d)}} = | (1) | | | {{double getTrace()}} = | | | | {{multiply(RealMatrix m)}} = | | | | {{double[] operate(double[])}} = | (2) | | | {{RealVector operate(RealVector)}}= | | | | {{RealMatrix power(int p)}} = | | | | {{double[] preMultiply(double[])}}= | (2) | | | {{RealMatrix preMultiply(RealMatri= x)}} | | | | {{RealVector preMultiply(RealVecto= r)}} | | | | {{RealMatrix transpose()}} = | | h3. Comments on the above methods h4. Comment (1) {{RealVector RealVector.mapMultiply(double)}} and {{RealMatrix RealMatrix.s= calarMultiply(double)}} perform essentially the same task. Readibility of t= he classes would be improved if they add the same name. This is very import= ant since these methods reflect the fact that the space of vectors as well = as the space of matrices are two vector spaces. h4. Comment (2) Prior to the release of version 3.0, all methods involving taking as argume= nt, or returning, {{double[]}} representing vectors were removed. The ratio= nale for this is that calling {{new ArrayRealVector(double[], false)}} is v= ery easy, and comes at virtually no cost (see MATH-653 and MATH-660). It mi= ght be worth considering the same simplification for the {{RealMatrix}} int= erface. h2. Methods reflecting the mathematical structure of euclidean space h2. Constructors, factory methods and related methods h2. Manipulation of entries h2. Various norms h2. Functional-programming-like methods =20 > Refactoring the vector and matrix classes > ----------------------------------------- > > Key: MATH-765 > URL: https://issues.apache.org/jira/browse/MATH-765 > Project: Commons Math > Issue Type: Improvement > Affects Versions: 4.0 > Reporter: S=C3=A9bastien Brisard > Labels: api-change, linear > > {panel:title=3DWarning|borderStyle=3Dsolid} > This is not a bug report, but rather a summary of all discussions which h= ave taken place on the mailing list regarding the refactoring of the vector= and matrix classes. Indeed, it has been argued many times that the {{RealV= ector}} and {{RealMatrix}} interfaces are really cluttered, and could benef= it from other approaches (like functional programming).=20 > The description of this ticket will be updated as the discussion progress= es on the mailing-list, and new JIRA tickets will be created to carry out t= he "real" work. {color:red}In order to keep this ticket tidy, contributors = should refrain from commenting on this website. Instead, messages should be= posted on the dev mailing-list{color}. > {panel} > h1. The current API (version 3.0) > In this section, the current interfaces for vectors and matrices are comp= ared. Vectors and matrices are two mathematical objects which are very clos= e in nature. Their implementations should therefore be as similar as possib= le. The methods will be sorted as follows > * methods reflecting the mathematical structure of vector space: addition= , multiplication by a scalar, matrix-vector product, ... > * methods reflecting the mathematical structure of euclidean space > * ... > h2. Methods reflecting the mathematical structure of vector space > h3. List of the methods > || {{RealVector}} || {{RealMatrix}} = || Comments || > | {{RealVector add(RealVector v)}} | {{RealMatrix add(RealMatrix m)}}= | | > | {{int getDimension()}} | {{int getRowDimension()}},\\ {{i= nt getColumnDimension()}} | | > | {{RealVector mapMultiply(double d)}} | {{scalarMultiply(double d)}} = | (1) | > | | {{double getTrace()}} = | | > | | {{multiply(RealMatrix m)}} = | | > | | {{double[] operate(double[])}} = | (2) | > | | {{RealVector operate(RealVector)= }} | | > | | {{RealMatrix power(int p)}} = | | > | | {{double[] preMultiply(double[])= }} | (2) | > | | {{RealMatrix preMultiply(RealMat= rix)}} | | > | | {{RealVector preMultiply(RealVec= tor)}} | | > | | {{RealMatrix transpose()}} = | | > h3. Comments on the above methods > h4. Comment (1) > {{RealVector RealVector.mapMultiply(double)}} and {{RealMatrix RealMatrix= .scalarMultiply(double)}} perform essentially the same task. Readibility of= the classes would be improved if they add the same name. This is very impo= rtant since these methods reflect the fact that the space of vectors as wel= l as the space of matrices are two vector spaces. > h4. Comment (2) > Prior to the release of version 3.0, all methods involving taking as argu= ment, or returning, {{double[]}} representing vectors were removed. The rat= ionale for this is that calling {{new ArrayRealVector(double[], false)}} is= very easy, and comes at virtually no cost (see MATH-653 and MATH-660). It = might be worth considering the same simplification for the {{RealMatrix}} i= nterface. > h2. Methods reflecting the mathematical structure of euclidean space > h3. List of the methods > || {{RealVector}} || {{RealMatrix}} || Comments |= | > | {{double cosine(RealVector v)}} | | | > | {{double dotProduct(RealVector v)}} | | (3) | > | {{double getDistance(RealVector v)}} | | | > | {{double getNorm()}} | | | > | {{RealVector projection(RealVector v)}} | | | > | {{void unitize()}} | | (4) | > | {{RealVector unitVector()}} | | | > h3. Comments on the above methods > h4. Comment (3) > In a way, {{RealMatrix RealMatrix.transpose()}} could be seen as a method= inherent to the euclidean structure, and the generalization of the dot pro= duct. For this reason, {{transpose()}} should probably _not_ be externalize= d. > h4. Comment (4) > This could be externalized with the visitor pattern (see below). > h4. Comment (5) > Could be externalized in a factory class. > h2. Constructors, factory methods and related methods > h2. Manipulation of entries > h2. Various norms > h2. Functional-programming-like methods -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira