Skip to content

Commit

Permalink
Replace primitive RowVector{T}(shape...) constructors with RowVector{…
Browse files Browse the repository at this point in the history
…T}(uninitialized, shape...) etc.
  • Loading branch information
Sacha0 committed Nov 26, 2017
1 parent b15024f commit 03a9c05
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions base/linalg/rowvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ const ConjRowVector{T,CV<:ConjVector} = RowVector{T,CV}
@inline RowVector{T}(vec::AbstractVector{T}) where {T} = RowVector{T,typeof(vec)}(vec)

# Constructors that take a size and default to Array
@inline RowVector{T}(n::Int) where {T} = RowVector{T}(Vector{transpose_type(T)}(uninitialized, n))
@inline RowVector{T}(n1::Int, n2::Int) where {T} = n1 == 1 ?
RowVector{T}(Vector{transpose_type(T)}(uninitialized, n2)) :
error("RowVector expects 1×N size, got ($n1,$n2)")
@inline RowVector{T}(n::Tuple{Int}) where {T} = RowVector{T}(Vector{transpose_type(T)}(uninitialized, n[1]))
@inline RowVector{T}(n::Tuple{Int,Int}) where {T} = n[1] == 1 ?
RowVector{T}(Vector{transpose_type(T)}(uninitialized, n[2])) :
error("RowVector expects 1×N size, got $n")
@inline RowVector{T}(::Uninitialized, n::Int) where {T} =
RowVector{T}(Vector{transpose_type(T)}(uninitialized, n))
@inline RowVector{T}(::Uninitialized, n1::Int, n2::Int) where {T} =
n1 == 1 ? RowVector{T}(Vector{transpose_type(T)}(uninitialized, n2)) :
error("RowVector expects 1×N size, got ($n1,$n2)")
@inline RowVector{T}(::Uninitialized, n::Tuple{Int}) where {T} =
RowVector{T}(Vector{transpose_type(T)}(uninitialized, n[1]))
@inline RowVector{T}(::Uninitialized, n::Tuple{Int,Int}) where {T} =
n[1] == 1 ? RowVector{T}(Vector{transpose_type(T)}(uninitialized, n[2])) :
error("RowVector expects 1×N size, got $n")
# to deprecate, RowVector{T}(shape...) constructors
@inline RowVector{T}(n::Int) where {T} = RowVector{T}(uninitialized, n)
@inline RowVector{T}(n1::Int, n2::Int) where {T} = RowVector{T}(uninitialized, n1, n2)
@inline RowVector{T}(n::Tuple{Int}) where {T} = RowVector{T}(uninitializd, n)
@inline RowVector{T}(n::Tuple{Int,Int}) where {T} = RowVector{T}(uninitialized, n)

# Conversion of underlying storage
convert(::Type{RowVector{T,V}}, rowvec::RowVector) where {T,V<:AbstractVector} =
Expand Down

0 comments on commit 03a9c05

Please sign in to comment.