@@ -113,23 +113,18 @@ function ipiv2perm{T}(v::AbstractVector{T}, maxi::Integer)
113
113
return p
114
114
end
115
115
116
- function getindex {T,S<:StridedMatrix} (A :: LU{T,S} , d:: Symbol )
117
- m, n = size (A )
116
+ function getindex {T,S<:StridedMatrix} (F :: LU{T,S} , d:: Symbol )
117
+ m, n = size (F )
118
118
if d == :L
119
- L = tril! (A . factors[1 : m, 1 : min (m,n)])
119
+ L = tril! (F . factors[1 : m, 1 : min (m,n)])
120
120
for i = 1 : min (m,n); L[i,i] = one (T); end
121
121
return L
122
122
elseif d == :U
123
- return triu! (A . factors[1 : min (m,n), 1 : n])
123
+ return triu! (F . factors[1 : min (m,n), 1 : n])
124
124
elseif d == :p
125
- return ipiv2perm (A . ipiv, m)
125
+ return ipiv2perm (F . ipiv, m)
126
126
elseif d == :P
127
- p = A[:p ]
128
- P = zeros (T, m, m)
129
- for i in 1 : m
130
- P[i,p[i]] = one (T)
131
- end
132
- return P
127
+ return eye (T, m)[:,invperm (F[:p ])]
133
128
else
134
129
throw (KeyError (d))
135
130
end
263
258
264
259
factorize (A:: Tridiagonal ) = lufact (A)
265
260
261
+ function getindex {T} (F:: Base.LinAlg.LU{T,Tridiagonal{T}} , d:: Symbol )
262
+ m, n = size (F)
263
+ if d == :L
264
+ L = full (Bidiagonal (ones (T, n), F. factors. dl, false ))
265
+ for i = 2 : n
266
+ tmp = L[F. ipiv[i], 1 : i - 1 ]
267
+ L[F. ipiv[i], 1 : i - 1 ] = L[i, 1 : i - 1 ]
268
+ L[i, 1 : i - 1 ] = tmp
269
+ end
270
+ return L
271
+ elseif d == :U
272
+ U = full (Bidiagonal (F. factors. d, F. factors. du, true ))
273
+ for i = 1 : n - 2
274
+ U[i,i + 2 ] = F. factors. du2[i]
275
+ end
276
+ return U
277
+ elseif d == :p
278
+ return ipiv2perm (F. ipiv, m)
279
+ elseif d == :P
280
+ return eye (T, m)[:,invperm (F[:p ])]
281
+ end
282
+ throw (KeyError (d))
283
+ end
284
+
266
285
# See dgtts2.f
267
286
function A_ldiv_B! {T} (A:: LU{T,Tridiagonal{T}} , B:: AbstractVecOrMat )
268
287
n = size (A,1 )
0 commit comments