def bidiag_unpack_diag(diag, superdiag): """ returns B This functions unpacks the bidiagonal matrix T of the diagonal and superdiagonal obtained from gsl_linalg_bidiag_unpack[_B] """ n = diag.shape[0] B = numx.identity(n) * diag sub = numx.identity(n - 1) * superdiag sub2 = numx.concatenate((numx.concatenate((zeros([n - 1, 1]), sub), 1), zeros([1, n]))) B = sub2 + B return B
def bidiag_unpack_diag(diag, superdiag): """ returns B This functions unpacks the bidiagonal matrix T of the diagonal and superdiagonal obtained from gsl_linalg_bidiag_unpack[_B] """ n = diag.shape[0] B = numx.identity(n)*diag sub = numx.identity(n-1)*superdiag sub2 = numx.concatenate( (numx.concatenate((zeros([n-1,1]),sub), 1), zeros([1,n]))) B = sub2 + B return B
def symmtd_unpack_diag(diag, subdiag): """ returns T This functions unpacks the tridiagonal matrix T of the diagonal and subdiagonal obtained from gsl_linalg_symmtd_unpack[_T] """ n = diag.shape[0] T = numx.identity(n) * diag sub = numx.identity(n - 1) * subdiag sub1 = numx.concatenate((zeros( (1, n)), numx.concatenate((sub, zeros((n - 1, 1))), 1))) sub2 = numx.concatenate((numx.concatenate((zeros([n - 1, 1]), sub), 1), zeros([1, n]))) T = sub1 + sub2 + T return T
def symmtd_unpack_diag(diag, subdiag): """ returns T This functions unpacks the tridiagonal matrix T of the diagonal and subdiagonal obtained from gsl_linalg_symmtd_unpack[_T] """ n = diag.shape[0] T = numx.identity(n)*diag sub = numx.identity(n-1)*subdiag sub1 = numx.concatenate( (zeros((1,n)), numx.concatenate((sub, zeros((n-1,1))), 1))) sub2 = numx.concatenate( (numx.concatenate((zeros([n-1,1]),sub), 1), zeros([1,n]))) T = sub1 + sub2 + T return T
def LU_unpack(LU): """ returns (L,U) This function splits the matrix LU into the the upper matrix U and the lower matrix L. The diagonal of L is the identity. """ code = get_typecode(LU) u = zeros(LU.shape, code) l = numx.identity(LU.shape[0], code) for i in range(LU.shape[0]): u[i, i:] = LU[i, i:] l[i, 0:i] = LU[i, :i] return (l, u)
def LU_unpack(LU): """ returns (L,U) This function splits the matrix LU into the the upper matrix U and the lower matrix L. The diagonal of L is the identity. """ code = get_typecode(LU) u = zeros(LU.shape, code) l = numx.identity(LU.shape[0], code) for i in range(LU.shape[0]): u[i, i: ] = LU[i, i:] l[i, 0:i] = LU[i, :i] return (l, u)