commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [46/53] [abbrv] [math] MATH-1355
Date Thu, 21 Apr 2016 23:15:32 GMT
MATH-1355

Use "DiagonalMatrix" class.
Thanks to Kazuhiro Koshino for the report.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/350c4771
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/350c4771
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/350c4771

Branch: refs/heads/develop
Commit: 350c477161a0d1df94efa02109ae07e6acbc527e
Parents: 7a8dc00
Author: Gilles <erans@apache.org>
Authored: Tue Apr 12 15:06:35 2016 +0200
Committer: Gilles <erans@apache.org>
Committed: Tue Apr 12 15:06:35 2016 +0200

----------------------------------------------------------------------
 .../apache/commons/math4/linear/MatrixUtils.java   | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/350c4771/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
index 19ff724..86d74d6 100644
--- a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
+++ b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
@@ -204,19 +204,16 @@ public class MatrixUtils {
     }
 
     /**
-     * Returns a diagonal matrix with specified elements.
+     * Creates a diagonal matrix with the specified diagonal elements.
+     *
+     * @param diagonal Diagonal elements of the matrix.
+     * The array elements will be copied.
+     * @return a diagonal matrix instance.
      *
-     * @param diagonal diagonal elements of the matrix (the array elements
-     * will be copied)
-     * @return diagonal matrix
      * @since 2.0
      */
-    public static RealMatrix createRealDiagonalMatrix(final double[] diagonal) {
-        final RealMatrix m = createRealMatrix(diagonal.length, diagonal.length);
-        for (int i = 0; i < diagonal.length; ++i) {
-            m.setEntry(i, i, diagonal[i]);
-        }
-        return m;
+    public static DiagonalMatrix createRealDiagonalMatrix(final double[] diagonal) {
+        return new DiagonalMatrix(diagonal, true);
     }
 
     /**


Mime
View raw message