Skip to content

Commit 7c8068f

Browse files
committed
Deprecate ConjArray as part of the ConjRowVector/RowVector implementation.
1 parent d83dca9 commit 7c8068f

File tree

6 files changed

+65
-80
lines changed

6 files changed

+65
-80
lines changed

base/deprecated.jl

+61
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,67 @@ finalizer(f::Ptr{Cvoid}, o::Function) = invoke(finalizer, Tuple{Ptr{Cvoid}, Any}
22482248
Base.@deprecate_binding broadcast_t broadcast false ", broadcast_t(f, ::Type{ElType}, shape, iter, As...)` should become `broadcast(f, Broadcast.DefaultArrayStyle{N}(), ElType, shape, As...))` (see the manual chapter Interfaces)"
22492249
end
22502250

2251+
2252+
### deprecations for lazier, less jazzy linalg transition in the next several blocks ###
2253+
2254+
# deprecate ConjArray
2255+
# TODO: between 0.7 and 1.0 remove
2256+
# 1) the type definitions in base/linalg/conjarray.jl
2257+
# 2) the include("base/linalg/conjarray.jl") from base/linalg/linalg.jl
2258+
# 3) the file base/linalg/conjarray.jl itself
2259+
@eval Base.LinAlg begin
2260+
export ConjArray, ConjVector, ConjMatrix
2261+
2262+
function ConjArray(a::AbstractArray{T,N}) where {T,N}
2263+
Base.depwarn(_ConjArray_depstring(), :ConjArray)
2264+
return ConjArray{conj_type(T),N,typeof(a)}(a)
2265+
end
2266+
function ConjVector(v::AbstractVector{T}) where {T}
2267+
Base.depwarn(_ConjArray_depstring(), :ConjArray)
2268+
return ConjArray{conj_type(T),1,typeof(v)}(v)
2269+
end
2270+
function ConjMatrix(m::AbstractMatrix{T}) where {T}
2271+
Base.depwarn(_ConjArray_depstring(), :ConjArray)
2272+
return ConjArray{conj_type(T),2,typeof(m)}(m)
2273+
end
2274+
2275+
_ConjArray_depstring() = string("`ConjRowVector` and `RowVector` have been deprecated in favor ",
2276+
"of `Adjoint` and `Transpose`, and, as part of the implementation of `ConjRowVector`",
2277+
"/`RowVector`, `ConjArray`s have been deprecated as well. Please see 0.7's NEWS.md ",
2278+
"for a more detailed explanation of the associated changes.")
2279+
2280+
# This type can cause the element type to change under conjugation - e.g. an array of complex arrays.
2281+
@inline conj_type(x) = conj_type(typeof(x))
2282+
@inline conj_type(::Type{T}) where {T} = promote_op(conj, T)
2283+
2284+
@inline parent(c::ConjArray) = c.parent
2285+
@inline parent_type(c::ConjArray) = parent_type(typeof(c))
2286+
@inline parent_type(::Type{ConjArray{T,N,A}}) where {T,N,A} = A
2287+
2288+
@inline size(a::ConjArray) = size(a.parent)
2289+
IndexStyle(::CA) where {CA<:ConjArray} = IndexStyle(parent_type(CA))
2290+
IndexStyle(::Type{CA}) where {CA<:ConjArray} = IndexStyle(parent_type(CA))
2291+
2292+
@propagate_inbounds getindex(a::ConjArray{T,N}, i::Int) where {T,N} = conj(getindex(a.parent, i))
2293+
@propagate_inbounds getindex(a::ConjArray{T,N}, i::Vararg{Int,N}) where {T,N} = conj(getindex(a.parent, i...))
2294+
@propagate_inbounds setindex!(a::ConjArray{T,N}, v, i::Int) where {T,N} = setindex!(a.parent, conj(v), i)
2295+
@propagate_inbounds setindex!(a::ConjArray{T,N}, v, i::Vararg{Int,N}) where {T,N} = setindex!(a.parent, conj(v), i...)
2296+
2297+
@inline similar(a::ConjArray, ::Type{T}, dims::Dims{N}) where {T,N} = similar(parent(a), T, dims)
2298+
2299+
# Currently, this is default behavior for RowVector only
2300+
@inline conj(a::ConjArray) = parent(a)
2301+
2302+
# Helper functions, currently used by RowVector
2303+
@inline _conj(a::AbstractArray) = ConjArray(a)
2304+
@inline _conj(a::AbstractArray{T}) where {T<:Real} = a
2305+
@inline _conj(a::ConjArray) = parent(a)
2306+
@inline _conj(a::ConjArray{T}) where {T<:Real} = parent(a)
2307+
end
2308+
@eval Base begin
2309+
export ConjArray
2310+
end
2311+
22512312
# A[ct]_(mul|ldiv|rdiv)_B[ct][!] methods from base/operators.jl, to deprecate
22522313
@deprecate Ac_ldiv_Bt(a,b) (\)(Adjoint(a), Transpose(b))
22532314
@deprecate At_ldiv_Bt(a,b) (\)(Transpose(a), Transpose(b))

base/exports.jl

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export
4747
ComplexF64,
4848
ComplexF32,
4949
ComplexF16,
50-
ConjArray,
5150
ConjVector,
5251
ConjMatrix,
5352
DenseMatrix,

base/linalg/conjarray.jl

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
# TODO: remove this type stub between 0.7 and 1.0
4+
35
"""
46
ConjArray(array)
57
@@ -19,39 +21,5 @@ julia> ConjArray([1+im 0; 0 1-im])
1921
struct ConjArray{T,N,A<:AbstractArray} <: AbstractArray{T,N}
2022
parent::A
2123
end
22-
23-
@inline ConjArray(a::AbstractArray{T,N}) where {T,N} = ConjArray{conj_type(T),N,typeof(a)}(a)
24-
2524
const ConjVector{T,V<:AbstractVector} = ConjArray{T,1,V}
26-
@inline ConjVector(v::AbstractVector{T}) where {T} = ConjArray{conj_type(T),1,typeof(v)}(v)
27-
2825
const ConjMatrix{T,M<:AbstractMatrix} = ConjArray{T,2,M}
29-
@inline ConjMatrix(m::AbstractMatrix{T}) where {T} = ConjArray{conj_type(T),2,typeof(m)}(m)
30-
31-
# This type can cause the element type to change under conjugation - e.g. an array of complex arrays.
32-
@inline conj_type(x) = conj_type(typeof(x))
33-
@inline conj_type(::Type{T}) where {T} = promote_op(conj, T)
34-
35-
@inline parent(c::ConjArray) = c.parent
36-
@inline parent_type(c::ConjArray) = parent_type(typeof(c))
37-
@inline parent_type(::Type{ConjArray{T,N,A}}) where {T,N,A} = A
38-
39-
@inline size(a::ConjArray) = size(a.parent)
40-
IndexStyle(::CA) where {CA<:ConjArray} = IndexStyle(parent_type(CA))
41-
IndexStyle(::Type{CA}) where {CA<:ConjArray} = IndexStyle(parent_type(CA))
42-
43-
@propagate_inbounds getindex(a::ConjArray{T,N}, i::Int) where {T,N} = conj(getindex(a.parent, i))
44-
@propagate_inbounds getindex(a::ConjArray{T,N}, i::Vararg{Int,N}) where {T,N} = conj(getindex(a.parent, i...))
45-
@propagate_inbounds setindex!(a::ConjArray{T,N}, v, i::Int) where {T,N} = setindex!(a.parent, conj(v), i)
46-
@propagate_inbounds setindex!(a::ConjArray{T,N}, v, i::Vararg{Int,N}) where {T,N} = setindex!(a.parent, conj(v), i...)
47-
48-
@inline similar(a::ConjArray, ::Type{T}, dims::Dims{N}) where {T,N} = similar(parent(a), T, dims)
49-
50-
# Currently, this is default behavior for RowVector only
51-
@inline conj(a::ConjArray) = parent(a)
52-
53-
# Helper functions, currently used by RowVector
54-
@inline _conj(a::AbstractArray) = ConjArray(a)
55-
@inline _conj(a::AbstractArray{T}) where {T<:Real} = a
56-
@inline _conj(a::ConjArray) = parent(a)
57-
@inline _conj(a::ConjArray{T}) where {T<:Real} = parent(a)

base/linalg/linalg.jl

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export
2929
Adjoint,
3030
Transpose,
3131
RowVector,
32-
ConjArray,
33-
ConjVector,
34-
ConjMatrix,
3532
SymTridiagonal,
3633
Tridiagonal,
3734
Bidiagonal,
@@ -246,8 +243,8 @@ copy_oftype(A::AbstractArray{T}, ::Type{T}) where {T} = copy(A)
246243
copy_oftype(A::AbstractArray{T,N}, ::Type{S}) where {T,N,S} = convert(AbstractArray{S,N}, A)
247244

248245
include("adjtrans.jl")
249-
include("conjarray.jl")
250246
include("transpose.jl")
247+
include("conjarray.jl")
251248
include("rowvector.jl")
252249

253250
include("exceptions.jl")

test/choosetests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function choosetests(choices = [])
125125
"linalg/diagonal", "linalg/pinv", "linalg/givens",
126126
"linalg/cholesky", "linalg/lu", "linalg/symmetric",
127127
"linalg/generic", "linalg/uniformscaling", "linalg/lq",
128-
"linalg/hessenberg", "linalg/rowvector", "linalg/conjarray",
128+
"linalg/hessenberg", "linalg/rowvector",
129129
"linalg/blas", "linalg/adjtrans"]
130130

131131
if "linalg" in skip_tests

test/linalg/conjarray.jl

-40
This file was deleted.

0 commit comments

Comments
 (0)