I have the following matrix in javascript, modelled with the library math.js:
<script src='math.js' src='sylvester.js' type='text/javascript'></script>
var CN = math.matrix([[8], [7],[3],[1]])
I would like to change this matrix into a diagonal matrix:
<script src='math.js' src='sylvester.js' type='text/javascript'></script>
var CN = math.matrix([[8,0,0,0], [0,7,0,0],[0,0,3,0], [0,0,0,1]]);
I cannot find the appropriate code for this to do so.
Can someone help me with the appropriate code?