diff --git a/.gitignore b/.gitignore index 723e68cb800c3637bda99e5df67f2676154a0a7b..1bcf8c19407ea6b0366dfc86fc384718177188be 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ *.jar .project .classpath -export.jardesc \ No newline at end of file +export.jardesc +target/ +.idea/ +*.iml \ No newline at end of file diff --git a/pom.xml b/pom.xml index a9c418c590a959481bcae5be9bc73fab20320c2f..eb846fb5d9b1e949959aff3759ba8c5988fdc779 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>icy-nherve-matrix</artifactId> + <parent> + <artifactId>pom-icy</artifactId> + <groupId>org.bioimageanalysis.icy</groupId> + <version>1.0.4</version> + </parent> + + <artifactId>nherve-matrix</artifactId> <version>1.1</version> <packaging>jar</packaging> @@ -46,32 +51,4 @@ </plugin> </plugins> </build> - - <dependencies> - <dependency> - <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>icy-kernel</artifactId> - <version>2.1.0</version> - </dependency> - </dependencies> - - <repositories> - <repository> - <id>icy</id> - <url>https://icy-nexus.pasteur.fr/repository/Icy/</url> - </repository> - </repositories> - - <distributionManagement> - <snapshotRepository> - <id>icy-dev</id> - <name>icy-dev</name> - <url>https://icy-nexus-dev.pasteur.cloud/repository/icy-core/</url> - </snapshotRepository> - <repository> - <id>icy-prod</id> - <name>icy-prod</name> - <url>https://icy-nexus.pasteur.fr/repository/icy-core/</url> - </repository> - </distributionManagement> </project> \ No newline at end of file diff --git a/src/main/java/plugins/nherve/matrix/CholeskyDecomposition.java b/src/main/java/plugins/nherve/matrix/CholeskyDecomposition.java index d8ccd0272519e70eea2916a888acd1ee33300a12..fc8b7ed11389a0c3459b890bd71afa0fa6cc7d04 100644 --- a/src/main/java/plugins/nherve/matrix/CholeskyDecomposition.java +++ b/src/main/java/plugins/nherve/matrix/CholeskyDecomposition.java @@ -39,8 +39,7 @@ public class CholeskyDecomposition implements java.io.Serializable { * ------------------------ */ /** Cholesky algorithm for symmetric and positive definite matrix. - @param A Square, symmetric matrix. - @return Structure to access L and isspd flag. + @param Arg Square, symmetric matrix. */ public CholeskyDecomposition (Matrix Arg) { diff --git a/src/main/java/plugins/nherve/matrix/EigenvalueDecomposition.java b/src/main/java/plugins/nherve/matrix/EigenvalueDecomposition.java index 35cf0dd583998362389b003210e1cd552e7b3aab..de318325ed64a174a865c3355911e592ce0f762a 100644 --- a/src/main/java/plugins/nherve/matrix/EigenvalueDecomposition.java +++ b/src/main/java/plugins/nherve/matrix/EigenvalueDecomposition.java @@ -858,8 +858,7 @@ public class EigenvalueDecomposition implements java.io.Serializable { * ------------------------ */ /** Check for symmetry, then construct the eigenvalue decomposition - @param A Square matrix - @return Structure to access D and V. + @param Arg Square matrix */ public EigenvalueDecomposition (Matrix Arg) { diff --git a/src/main/java/plugins/nherve/matrix/LUDecomposition.java b/src/main/java/plugins/nherve/matrix/LUDecomposition.java index b7b536f4fb4bdcb84388ea4a8090681c15cf85b3..e4b248527e661650f093e4ababc291caa42c9dba 100644 --- a/src/main/java/plugins/nherve/matrix/LUDecomposition.java +++ b/src/main/java/plugins/nherve/matrix/LUDecomposition.java @@ -3,10 +3,10 @@ package plugins.nherve.matrix; /** LU Decomposition. <P> - For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n + For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length m so that A(piv,:) = L*U. - If m < n, then L is m-by-m and U is m-by-n. + If m < n, then L is m-by-m and U is m-by-n. <P> The LU decompostion with pivoting always exists, even if the matrix is singular, so the constructor will never fail. The primary use of the @@ -45,7 +45,6 @@ public class LUDecomposition implements java.io.Serializable { /** LU Decomposition @param A Rectangular matrix - @return Structure to access L, U and piv. */ public LUDecomposition (Matrix A) { diff --git a/src/main/java/plugins/nherve/matrix/Matrix.java b/src/main/java/plugins/nherve/matrix/Matrix.java index b38d648064c411376609d4fd85e75a2aeaf421ab..ee62bedb44c68830749cd6995e45fc299cf908e2 100644 --- a/src/main/java/plugins/nherve/matrix/Matrix.java +++ b/src/main/java/plugins/nherve/matrix/Matrix.java @@ -26,13 +26,12 @@ import plugins.nherve.matrix.util.Maths; * printing matrices are also included. All the operations in this version of * the Matrix Class involve real matrices. Complex matrices may be handled in a * future version. - * <P> + * * Five fundamental matrix decompositions, which consist of pairs or triples of * matrices, permutation vectors, and the like, produce results in five * decomposition classes. These decompositions are accessed by the Matrix class * to compute solutions of simultaneous linear equations, determinants, inverses * and other matrix functions. The five decompositions are: - * <P> * <UL> * <LI>Cholesky Decomposition of symmetric, positive definite matrices. * <LI>LU Decomposition of rectangular matrices. @@ -43,9 +42,7 @@ import plugins.nherve.matrix.util.Maths; * </UL> * <DL> * <DT><B>Example of use:</B></DT> - * <P> * <DD>Solve a linear system A x = b and compute the residual norm, ||b - A x||. - * <P> * * <PRE> * double[][] vals = { { 1., 2., 3 }, { 4., 5., 6. }, { 7., 8., 10. } }; @@ -202,7 +199,7 @@ public class Matrix implements Cloneable, java.io.Serializable { */ /** - * Construct a matrix from a copy of a 2-D array. + * @return Construct a matrix from a copy of a 2-D array. * * @param A * Two-dimensional array of doubles. @@ -227,7 +224,7 @@ public class Matrix implements Cloneable, java.io.Serializable { } /** - * Make a deep copy of a matrix + * @return Make a deep copy of a matrix */ public Matrix copy() { @@ -335,7 +332,7 @@ public class Matrix implements Cloneable, java.io.Serializable { * @param j * Column index. * @return A(i,j) - * @exception ArrayIndexOutOfBoundsException + * @throws ArrayIndexOutOfBoundsException Array out of bounds */ public double get(int i, int j) { @@ -434,9 +431,9 @@ public class Matrix implements Cloneable, java.io.Serializable { * * @param r * Array of row indices. - * @param i0 + * @param j0 * Initial column index - * @param i1 + * @param j1 * Final column index * @return A(r(:),j0:j1) * @exception ArrayIndexOutOfBoundsException @@ -467,7 +464,7 @@ public class Matrix implements Cloneable, java.io.Serializable { * Column index. * @param s * A(i,j). - * @exception ArrayIndexOutOfBoundsException + * @throws ArrayIndexOutOfBoundsException array out of bounds */ public void set(int i, int j, double s) { @@ -1207,13 +1204,14 @@ public class Matrix implements Cloneable, java.io.Serializable { } /** - * Read a matrix from a stream. The format is the same the print method, so + * @return Read a matrix from a stream. The format is the same the print method, so * printed matrices can be read back in (provided they were printed using US * Locale). Elements are separated by whitespace, all the elements for each * row appear on a single line, the last row is followed by a blank line. * * @param input * the input stream. + * @throws java.io.IOException IO Exception */ public static Matrix read(BufferedReader input) throws java.io.IOException { diff --git a/src/main/java/plugins/nherve/matrix/QRDecomposition.java b/src/main/java/plugins/nherve/matrix/QRDecomposition.java index fc79248bd2abebe0dc941a9f4ddddbe8367b6203..7188d08731abb8e3883a0d414c0ecf0850da715e 100644 --- a/src/main/java/plugins/nherve/matrix/QRDecomposition.java +++ b/src/main/java/plugins/nherve/matrix/QRDecomposition.java @@ -4,7 +4,7 @@ import plugins.nherve.matrix.util.Maths; /** QR Decomposition. <P> - For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n + For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n orthogonal matrix Q and an n-by-n upper triangular matrix R so that A = Q*R. <P> @@ -45,7 +45,6 @@ public class QRDecomposition implements java.io.Serializable { /** QR Decomposition, computed by Householder reflections. @param A Rectangular matrix - @return Structure to access R and the Householder vectors and compute Q. */ public QRDecomposition (Matrix A) { diff --git a/src/main/java/plugins/nherve/matrix/SingularValueDecomposition.java b/src/main/java/plugins/nherve/matrix/SingularValueDecomposition.java index 70d26c85db944e745fb7f49ad765e572dccb5c5c..58ba5723ea3954bcd524e2883da5a586e444bc28 100644 --- a/src/main/java/plugins/nherve/matrix/SingularValueDecomposition.java +++ b/src/main/java/plugins/nherve/matrix/SingularValueDecomposition.java @@ -4,12 +4,12 @@ import plugins.nherve.matrix.util.Maths; /** Singular Value Decomposition. <P> - For an m-by-n matrix A with m >= n, the singular value decomposition is + For an m-by-n matrix A with m >= n, the singular value decomposition is an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and an n-by-n orthogonal matrix V so that A = U*S*V'. <P> The singular values, sigma[k] = S[k][k], are ordered so that - sigma[0] >= sigma[1] >= ... >= sigma[n-1]. + sigma[0] >= sigma[1] >= ... >= sigma[n-1]. <P> The singular value decompostion always exists, so the constructor will never fail. The matrix condition number and the effective numerical @@ -46,8 +46,7 @@ public class SingularValueDecomposition implements java.io.Serializable { * ------------------------ */ /** Construct the singular value decomposition - @param A Rectangular matrix - @return Structure to access U, S and V. + @param Arg Rectangular matrix */ public SingularValueDecomposition (Matrix Arg) { diff --git a/src/main/java/plugins/nherve/matrix/util/Maths.java b/src/main/java/plugins/nherve/matrix/util/Maths.java index 46ff5b81b6033f646290f383d2ba7c07c60bd107..4e77dff75b0764eb0dff34c936f5187d8aee735d 100644 --- a/src/main/java/plugins/nherve/matrix/util/Maths.java +++ b/src/main/java/plugins/nherve/matrix/util/Maths.java @@ -1,20 +1 @@ -package plugins.nherve.matrix.util; - -public class Maths { - - /** sqrt(a^2 + b^2) without under/overflow. **/ - - public static double hypot(double a, double b) { - double r; - if (Math.abs(a) > Math.abs(b)) { - r = b/a; - r = Math.abs(a)*Math.sqrt(1+r*r); - } else if (b != 0) { - r = a/b; - r = Math.abs(b)*Math.sqrt(1+r*r); - } else { - r = 0.0; - } - return r; - } -} +package plugins.nherve.matrix.util; public class Maths { /** * @return sqrt(a^2 + b^2) without under/overflow. * @param a double * @param b double * **/ public static double hypot(double a, double b) { double r; if (Math.abs(a) > Math.abs(b)) { r = b/a; r = Math.abs(a)*Math.sqrt(1+r*r); } else if (b != 0) { r = a/b; r = Math.abs(b)*Math.sqrt(1+r*r); } else { r = 0.0; } return r; } } \ No newline at end of file