Home > dal > spdiag.m

spdiag

PURPOSE ^

spdiag - sparse diagonal matrix

SYNOPSIS ^

function D = spdiag(d)

DESCRIPTION ^

 spdiag - sparse diagonal matrix

 Copyright(c) 2009 Ryota Tomioka
 This software is distributed under the MIT license. See license.txt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % spdiag - sparse diagonal matrix
0002 %
0003 % Copyright(c) 2009 Ryota Tomioka
0004 % This software is distributed under the MIT license. See license.txt
0005 
0006 function D = spdiag(d)
0007 
0008 if isempty(d)
0009   D = [];
0010   return;
0011 end
0012 
0013 if size(d,1)<size(d,2)
0014   d = d';
0015 end
0016 
0017 D = spdiags(d,0,size(d,1),size(d,1));

Generated on Sat 22-Aug-2009 22:15:36 by m2html © 2003