Skip to content

Commit

Permalink
Fix #83
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Aug 26, 2014
1 parent b4595c7 commit 744aaba
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/linpred.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


## Return the linear predictor vector
linpred(p::LinPred, f::Real=1.) = p.X * (f == 0. ? p.beta0 : fma(p.beta0, p.delbeta, f))

Expand All @@ -24,8 +22,6 @@ type DensePredQR{T<:BlasReal} <: DensePred
end
DensePredQR{T<:BlasReal}(X::Matrix{T}) = DensePredQR{T}(X, zeros(T,size(X,2)))

cholfact{T<:FP}(p::DensePredQR{T}) = Cholesky{T}(p.qr[:R],'U')

delbeta!{T<:BlasReal}(p::DensePredQR{T}, r::Vector{T}) = (p.delbeta = p.qr\r; p)

type DensePredChol{T<:BlasReal} <: DensePred
Expand All @@ -40,9 +36,17 @@ type DensePredChol{T<:BlasReal} <: DensePred
end
DensePredChol{T<:BlasReal}(X::Matrix{T}) = DensePredChol{T}(X, zeros(T,size(X,2)))

solve!{T<:BlasReal}(C::Cholesky{T}, B::StridedVecOrMat{T}) = potrs!(C.uplo, C.UL, B)
solve!{T<:BlasReal}(C::Cholesky{T}, B::StridedVecOrMat{T}) = potrs!(uplo(C), C.UL, B)

cholfact{T<:FP}(p::DensePredChol{T}) = (c = p.chol; Cholesky{T}(copy(c.UL),c.uplo))
if VERSION >= v"0.4.0-dev+122"
uplo{T,S,U}(::Cholesky{T,S,U}) = ifelse(U == :U, 'U', 'L')
cholfact{T<:FP}(p::DensePredQR{T}) = Cholesky{T,Matrix{T},:U}(p.qr[:R])
cholfact{T<:FP}(p::DensePredChol{T}) = (c = p.chol; typeof(c)(copy(c.UL)))
else
uplo(c::Cholesky) = c.uplo
cholfact{T<:FP}(p::DensePredQR{T}) = Cholesky{T}(p.qr[:R],'U')
cholfact{T<:FP}(p::DensePredChol{T}) = (c = p.chol; Cholesky{T}(copy(c.UL),c.uplo))
end

function delbeta!{T<:BlasReal}(p::DensePredChol{T}, r::Vector{T})
solve!(p.chol, gemv!('T', 1.0, p.X, r, 0.0, p.delbeta))
Expand Down

0 comments on commit 744aaba

Please sign in to comment.