The function 'diag' should work. To use it, you'll need to load "diag"
(%i6) load(diag)$
(%i7) m : diag([a,b]);
(%o7) matrix([a,0],[0,b])
Given a list of matrices, diag doesn't return a block matrix:
(%i8) diag([m,m]);
(%o8) matrix([a,0,0,0],[0,b,0,0],[0,0,a,0],[0,0,0,b])
The function diag_matrix should also work -- this function autoloads.
Unlike
'diag,' the function 'diag_matrix' n arguments (instead of a single list)
(%i9) diag_matrix(a,b);
(%o9) matrix([a,0],[0,b])
When the arguments to diag_matrix are matrices, it returns a block matrix:
(%i10) diag_matrix(m,m);
(%o10)
matrix([matrix([a,0],[0,b]),matrix([0,0],[0,0])],[matrix([0,0],[0,0]),matrix([a,0],[0,b])])
The function diag_matrix tries to detect problems:
(%i11) diag_matrix(m,1);
All arguments to 'diag_matrix' must either be unblocked matrices or
non-matrices
It's not good that Maxima has two functions for creating a diagonal matrix.
These things happen. Blame me :)
Barton
-----maxima-bounces at math.utexas.edu wrote: -----
but is there is a function in Maxima
>which allows (non-interactive) construction of a diagonal matrix with
>arbitrary values down the diagonal?