Returns a new dense square matrix such that the main diagonal contains the values given in a @param a the diagonal values of a matrix @return the diagonal matrix represent by a
(Vec a)
| 1007 | * @return the diagonal matrix represent by <i>a</i> |
| 1008 | */ |
| 1009 | public static Matrix diag(Vec a) |
| 1010 | { |
| 1011 | DenseMatrix A = new DenseMatrix(a.length(), a.length()); |
| 1012 | for(Iterator<IndexValue> iter = a.getNonZeroIterator(); iter.hasNext();) |
| 1013 | { |
| 1014 | IndexValue iv = iter.next(); |
| 1015 | A.set(iv.getIndex(), iv.getIndex(), iv.getValue()); |
| 1016 | } |
| 1017 | |
| 1018 | return A; |
| 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * Alters the matrix <i>A</i> so that it contains the result of <i>A</i> |