From issuesreturn25683apmailcommonsissuesarchive=commons.apache.org@commons.apache.org Mon Mar 12 06:58:01 2012
ReturnPath:
XOriginalTo: apmailcommonsissuesarchive@minotaur.apache.org
DeliveredTo: apmailcommonsissuesarchive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 1871E9A93
for ; Mon, 12 Mar 2012 06:58:01 +0000 (UTC)
Received: (qmail 35943 invoked by uid 500); 12 Mar 2012 06:57:42 0000
DeliveredTo: apmailcommonsissuesarchive@commons.apache.org
Received: (qmail 35603 invoked by uid 500); 12 Mar 2012 06:57:35 0000
MailingList: contact issueshelp@commons.apache.org; run by ezmlm
Precedence: bulk
ListHelp:
ListUnsubscribe:
ListPost:
ListId:
ReplyTo: issues@commons.apache.org
DeliveredTo: mailing list issues@commons.apache.org
Received: (qmail 35524 invoked by uid 99); 12 Mar 2012 06:57:32 0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Mar 2012 06:57:32 +0000
XASFSpamStatus: No, hits=2000.0 required=5.0
tests=ALL_TRUSTED,T_RP_MATCHES_RCVD
XSpamCheckBy: 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; Mon, 12 Mar 2012 06:57:30 +0000
Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116])
by hel.zones.apache.org (Postfix) with ESMTP id 3687C1B7B0
for ; Mon, 12 Mar 2012 06:57:10 +0000 (UTC)
Date: Mon, 12 Mar 2012 06:57:10 +0000 (UTC)
From: =?utf8?Q?S=C3=A9bastien_Brisard_=28Updated=29_=28JIRA=29?=
To: issues@commons.apache.org
MessageID: <789978658.1238.1331535430283.JavaMail.tomcat@hel.zones.apache.org>
InReplyTo: <2054829214.35035.1331143497658.JavaMail.tomcat@hel.zones.apache.org>
Subject: [jira] [Updated] (MATH765) Refactoring the vector and matrix
classes
MIMEVersion: 1.0
ContentType: text/plain; charset=utf8
ContentTransferEncoding: quotedprintable
XJIRAFingerPrint: 30527f35849b9dde25b450d4833f0394
XVirusChecked: Checked by ClamAV on apache.org
[ https://issues.apache.org/jira/browse/MATH765?page=3Dcom.atlassian.=
jira.plugin.system.issuetabpanels:alltabpanel ]
S=C3=A9bastien Brisard updated MATH765:

Description:=20
{panel:title=3DWarningborderStyle=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 mailinglist, 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 mailinglist{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, matrixvector 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) 
 {{RealVector outerProduct(RealVector v)}}  =
 
  {{double getTrace()}} =
 
  {{multiply(RealMatrix m)}} =
 
  {{double[] operate(double[])}=
}  (2) 
  {{RealVector operate(RealVect=
or)}}  
  {{RealMatrix power(int p)}} =
 
  {{double[] preMultiply(double=
[])}}  (2) 
  {{RealMatrix preMultiply(Real=
Matrix)}}  
  {{RealVector preMultiply(Real=
Vector)}}  
  {{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 taking as argument, or ret=
urning, {{double[]}} as a representation of 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 MATH653 and MATH660). 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
h3. List of the methods
 {{RealVector}}  {{RealMatrix}} =
=
 Comments 
 {{RealVector append(double d)}}  =
=
 
 {{RealVector append(RealVector v)}}  =
=
 
 {{RealVector copy()}}  {{RealMatrix copy()}} =
=
 
  {{void copySubMatrix(int=
[] selectedRows, int[] selectedColumns, double[][] destination)}} =
 (6), (7) 
  {{void copySubMatrix(int=
startRow, int endRow, int startColumn, int endColumn, double[][] destinati=
on)}}  (7) 
  {{createMatrix(int rowDi=
mension, int columnDimension)}} =
 (9) 
  {{double[] getColumn(int=
column)}} =
 (6) 
  {{RealMatrix getColumnMa=
trix(int column)}} =
 
  {{RealVector getColumnVe=
ctor(int column)}} =
 
  {{double[] getRow(int ro=
w)}} =
 (6) 
  {{RealMatrix getRowMatri=
x(int row)}} =
 
  {{RealVector getRowVecto=
r(int row)}} =
 
  {{RealMatrix getSubMatri=
x(int[] selectedRows, int[] selectedColumns)}} =
 
 {{RealVector getSubVector(int index, int n)}}  {{RealMatrix getSubMatri=
x(int startRow, int endRow, int startColumn, int endColumn)}} =
 (8) 
  {{void setColumn(int col=
umn, double[] array)}} =
 (6) 
  {{void setColumnMatrix(i=
nt column, RealMatrix matrix)}} =
 
  {{void setColumnVector(i=
nt column, RealVector vector)}} =
 
  {{void setRow(int row, d=
ouble[] array)}} =
 (6) 
  {{void setRowMatrix(int =
row, RealMatrix matrix)}} =
 
  {{void setRowVector(int =
row, RealVector vector)}} =
 
 {{void setSubVector(int index, RealVector v)}}  {{void setSubMatrix(doub=
le[][] subMatrix, int row, int column)}} =
 (6) 
 {{unmodifiableRealVector(RealVector v)}}  =
=
 
h3. Comments on the above methods
h4. Comment (6)
Prior to the release of version 3.0, all methods taking as argument, or ret=
urning, {{double[]}} as a representation of 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 MATH653 and MATH660). It mi=
ght be worth considering the same simplification for the {{RealMatrix}} int=
erface.
h4. Comment (7)
The signature of this method is rather unusual in CommonsMath, as one of t=
he parameters is modified, and nothing is returned.
h4. Comment (8)
Inconsistency: in {{getSubVector(int, int)}}, the second parameter is the n=
umber of entries to be copied, while in {{getSubMatrix(int, int, int, int)}=
} the second (resp. fourth) parameters are the indices of the last row (res=
p. column).
h4. Comment (9)
This is a very useful method: one often needs to create a new vector/matrix=
with same data layout as an existing vector/matrix. This method should pro=
bably be generalized to {{RealVector}} as well.
h2. Manipulation of entries
h2. Various norms
h2. Functionalprogramminglike methods
was:
{panel:title=3DWarningborderStyle=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 mailinglist, 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 mailinglist{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, matrixvector 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 MATH653 and MATH660). 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. Functionalprogramminglike methods
=20
> Refactoring the vector and matrix classes
> 
>
> Key: MATH765
> URL: https://issues.apache.org/jira/browse/MATH765
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 4.0
> Reporter: S=C3=A9bastien Brisard
> Labels: apichange, linear
>
> {panel:title=3DWarningborderStyle=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 mailinglist, 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 mailinglist{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, matrixvector 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) 
>  {{RealVector outerProduct(RealVector v)}}  =
 
>   {{double getTrace()}} =
 
>   {{multiply(RealMatrix m)}} =
 
>   {{double[] operate(double[]=
)}}  (2) 
>   {{RealVector operate(RealVe=
ctor)}}  
>   {{RealMatrix power(int p)}}=
 
>   {{double[] preMultiply(doub=
le[])}}  (2) 
>   {{RealMatrix preMultiply(Re=
alMatrix)}}  
>   {{RealVector preMultiply(Re=
alVector)}}  
>   {{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 taking as argument, or r=
eturning, {{double[]}} as a representation of 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 MATH653 and MATH660). 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
> h3. List of the methods
>  {{RealVector}}  {{RealMatrix}} =
=
 Comments 
>  {{RealVector append(double d)}}  =
=
 
>  {{RealVector append(RealVector v)}}  =
=
 
>  {{RealVector copy()}}  {{RealMatrix copy()}} =
=
 
>   {{void copySubMatrix(i=
nt[] selectedRows, int[] selectedColumns, double[][] destination)}} =
 (6), (7) 
>   {{void copySubMatrix(i=
nt startRow, int endRow, int startColumn, int endColumn, double[][] destina=
tion)}}  (7) 
>   {{createMatrix(int row=
Dimension, int columnDimension)}} =
 (9) 
>   {{double[] getColumn(i=
nt column)}} =
 (6) 
>   {{RealMatrix getColumn=
Matrix(int column)}} =
 
>   {{RealVector getColumn=
Vector(int column)}} =
 
>   {{double[] getRow(int =
row)}} =
 (6) 
>   {{RealMatrix getRowMat=
rix(int row)}} =
 
>   {{RealVector getRowVec=
tor(int row)}} =
 
>   {{RealMatrix getSubMat=
rix(int[] selectedRows, int[] selectedColumns)}} =
 
>  {{RealVector getSubVector(int index, int n)}}  {{RealMatrix getSubMat=
rix(int startRow, int endRow, int startColumn, int endColumn)}} =
 (8) 
>   {{void setColumn(int c=
olumn, double[] array)}} =
 (6) 
>   {{void setColumnMatrix=
(int column, RealMatrix matrix)}} =
 
>   {{void setColumnVector=
(int column, RealVector vector)}} =
 
>   {{void setRow(int row,=
double[] array)}} =
 (6) 
>   {{void setRowMatrix(in=
t row, RealMatrix matrix)}} =
 
>   {{void setRowVector(in=
t row, RealVector vector)}} =
 
>  {{void setSubVector(int index, RealVector v)}}  {{void setSubMatrix(do=
uble[][] subMatrix, int row, int column)}} =
 (6) 
>  {{unmodifiableRealVector(RealVector v)}}  =
=
 
> h3. Comments on the above methods
> h4. Comment (6)
> Prior to the release of version 3.0, all methods taking as argument, or r=
eturning, {{double[]}} as a representation of 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 MATH653 and MATH660). It =
might be worth considering the same simplification for the {{RealMatrix}} i=
nterface.
> h4. Comment (7)
> The signature of this method is rather unusual in CommonsMath, as one of=
the parameters is modified, and nothing is returned.
> h4. Comment (8)
> Inconsistency: in {{getSubVector(int, int)}}, the second parameter is the=
number of entries to be copied, while in {{getSubMatrix(int, int, int, int=
)}} the second (resp. fourth) parameters are the indices of the last row (r=
esp. column).
> h4. Comment (9)
> This is a very useful method: one often needs to create a new vector/matr=
ix with same data layout as an existing vector/matrix. This method should p=
robably be generalized to {{RealVector}} as well.
> h2. Manipulation of entries
> h2. Various norms
> h2. Functionalprogramminglike 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