MATH-1355

Use "DiagonalMatrix" class.
Thanks to Kazuhiro Koshino for the report.
This commit is contained in:
Gilles 2016-04-12 15:06:35 +02:00
parent 7a8dc00b8b
commit 350c477161
1 changed files with 7 additions and 10 deletions

View File

@ -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);
}
/**