MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / diag

Method diag

JSAT/src/jsat/linear/Matrix.java:1009–1019  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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>

Callers 4

testDiagMethod · 0.95
setUpTransformMethod · 0.95

Calls 7

setMethod · 0.95
getIndexMethod · 0.95
getValueMethod · 0.95
lengthMethod · 0.45
getNonZeroIteratorMethod · 0.45
hasNextMethod · 0.45
nextMethod · 0.45

Tested by 3

testDiagMethod · 0.76