You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionTridiagonal{T}(dl::V, d::V, du::V) where {T,V<:AbstractVector{T}}
408
+
n =length(d)
409
+
if (length(dl) != n-1||length(du) != n-1)
410
+
throw(ArgumentError(string("cannot construct Tridiagonal from incompatible ",
411
+
"lengths of subdiagonal, diagonal and superdiagonal: ",
412
+
"($(length(dl)), $(length(d)), $(length(du)))")))
413
+
end
414
+
new{T,V}(dl, d, du)
415
+
end
416
+
# constructor used in lufact!
417
+
functionTridiagonal{T,V}(dl::V, d::V, du::V, du2::V) where {T,V<:AbstractVector{T}}
418
+
new{T,V}(dl, d, du, du2)
419
+
end
407
420
end
408
421
409
422
"""
410
-
Tridiagonal(dl, d, du)
423
+
Tridiagonal(dl::V, d::V, du::V) where V <: AbstractVector
411
424
412
425
Construct a tridiagonal matrix from the first subdiagonal, diagonal, and first superdiagonal,
413
-
respectively. The result is of type `Tridiagonal` and provides efficient specialized linear
426
+
respectively. The result is of type `Tridiagonal` and provides efficient specialized linear
414
427
solvers, but may be converted into a regular matrix with
415
428
[`convert(Array, _)`](@ref) (or `Array(_)` for short).
416
429
The lengths of `dl` and `du` must be one less than the length of `d`.
417
430
418
431
# Examples
419
432
```jldoctest
420
-
julia> dl = [1; 2; 3]
421
-
3-element Array{Int64,1}:
422
-
1
423
-
2
424
-
3
433
+
julia> dl = [1, 2, 3];
425
434
426
-
julia> du = [4; 5; 6]
427
-
3-element Array{Int64,1}:
428
-
4
429
-
5
430
-
6
435
+
julia> du = [4, 5, 6];
431
436
432
-
julia> d = [7; 8; 9; 0]
433
-
4-element Array{Int64,1}:
434
-
7
435
-
8
436
-
9
437
-
0
437
+
julia> d = [7, 8, 9, 0];
438
438
439
439
julia> Tridiagonal(dl, d, du)
440
-
4×4 Tridiagonal{Int64}:
440
+
4×4 Tridiagonal{Int64,Array{Int64,1}}:
441
441
7 4 ⋅ ⋅
442
442
1 8 5 ⋅
443
443
⋅ 2 9 6
444
444
⋅ ⋅ 3 0
445
445
```
446
446
"""
447
-
# Basic constructor takes in three dense vectors of same type
448
-
functionTridiagonal(dl::Vector{T}, d::Vector{T}, du::Vector{T}) where T
449
-
n =length(d)
450
-
if (length(dl) != n-1||length(du) != n-1)
451
-
throw(ArgumentError("cannot make Tridiagonal from incompatible lengths of subdiagonal, diagonal and superdiagonal: ($(length(dl)), $(length(d)), $(length(du))"))
452
-
end
453
-
Tridiagonal(dl, d, du, zeros(T,n-2))
454
-
end
455
-
456
-
# Construct from diagonals of any abstract vector, any eltype
457
-
functionTridiagonal(dl::AbstractVector{Tl}, d::AbstractVector{Td}, du::AbstractVector{Tu}) where {Tl,Td,Tu}
0 commit comments