Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Hilbert/Banach space structures #27401

Merged
merged 17 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ This section lists changes that do not have deprecation warnings.
This change makes `@schedule` redundant with `@async`, so `@schedule` has been
deprecated ([#27164]).

* `norm(A::AbstractMatrix, p=2)` computes no longer the operator/matrix norm but the `norm` of `A`
as for other iterables, i.e. as if it were a vector. Especially, `norm(A::AbstractMatrix)` is the
Frobenius norm. To compute the operator/matrix norm, use the new function `opnorm` ([#27401]).

* `dot(u, v)` now acts recursively. Instead of `sum(u[i]' * v[i] for i in ...)`, it computes
`sum(dot(u[i], v[i]) for i in ...)`, similarly to `vecdot` before ([#27401]).

Library improvements
--------------------

Expand Down Expand Up @@ -1274,6 +1281,8 @@ Deprecated or removed

* The functions `eigs` and `svds` have been moved to the `Arpack.jl` package ([#27616]).

* `vecdot` and `vecnorm` are deprecated in favor of `dot` and `norm`, respectively ([#27401]).

Command-line option changes
---------------------------

Expand Down Expand Up @@ -1610,3 +1619,4 @@ Command-line option changes
[#27189]: https://github.com/JuliaLang/julia/issues/27189
[#27212]: https://github.com/JuliaLang/julia/issues/27212
[#27248]: https://github.com/JuliaLang/julia/issues/27248
[#27401]: https://github.com/JuliaLang/julia/issues/27401
3 changes: 1 addition & 2 deletions stdlib/LinearAlgebra/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ Linear algebra functions in Julia are largely implemented by calling functions f
Base.:*(::AbstractMatrix, ::AbstractMatrix)
Base.:\(::AbstractMatrix, ::AbstractVecOrMat)
LinearAlgebra.dot
LinearAlgebra.vecdot
LinearAlgebra.cross
LinearAlgebra.factorize
LinearAlgebra.Diagonal
Expand Down Expand Up @@ -358,7 +357,7 @@ LinearAlgebra.diag
LinearAlgebra.diagm
LinearAlgebra.rank
LinearAlgebra.norm
LinearAlgebra.vecnorm
LinearAlgebra.opnorm
LinearAlgebra.normalize!
LinearAlgebra.normalize
LinearAlgebra.cond
Expand Down
3 changes: 1 addition & 2 deletions stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export
qr!,
lq,
lq!,
opnorm,
rank,
rdiv!,
schur,
Expand All @@ -143,8 +144,6 @@ export
triu,
tril!,
triu!,
vecdot,
vecnorm,

# Operators
\,
Expand Down
16 changes: 8 additions & 8 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## BLAS cutoff threshold constants

const SCAL_CUTOFF = 2048
const DOT_CUTOFF = 128
#TODO const DOT_CUTOFF = 128
const ASUM_CUTOFF = 32
const NRM2_CUTOFF = 32

Expand Down Expand Up @@ -137,11 +137,11 @@ function norm(x::StridedVector{T}, rx::Union{UnitRange{TI},AbstractRange{TI}}) w
GC.@preserve x BLAS.nrm2(length(rx), pointer(x)+(first(rx)-1)*sizeof(T), step(rx))
end

vecnorm1(x::Union{Array{T},StridedVector{T}}) where {T<:BlasReal} =
length(x) < ASUM_CUTOFF ? generic_vecnorm1(x) : BLAS.asum(x)
norm1(x::Union{Array{T},StridedVector{T}}) where {T<:BlasReal} =
length(x) < ASUM_CUTOFF ? generic_norm1(x) : BLAS.asum(x)

vecnorm2(x::Union{Array{T},StridedVector{T}}) where {T<:BlasFloat} =
length(x) < NRM2_CUTOFF ? generic_vecnorm2(x) : BLAS.nrm2(x)
norm2(x::Union{Array{T},StridedVector{T}}) where {T<:BlasFloat} =
length(x) < NRM2_CUTOFF ? generic_norm2(x) : BLAS.nrm2(x)

"""
triu!(M, k::Integer)
Expand Down Expand Up @@ -509,7 +509,7 @@ function exp!(A::StridedMatrix{T}) where T<:BlasFloat
return copytri!(parent(exp(Hermitian(A))), 'U', true)
end
ilo, ihi, scale = LAPACK.gebal!('B', A) # modifies A
nA = norm(A, 1)
nA = opnorm(A, 1)
Inn = Matrix{T}(I, n, n)
## For sufficiently small nA, use lower order Padé-Approximations
if (nA <= 2.1)
Expand Down Expand Up @@ -1370,8 +1370,8 @@ function cond(A::AbstractMatrix, p::Real=2)
end
throw(ArgumentError("p-norm must be 1, 2 or Inf, got $p"))
end
_cond1Inf(A::StridedMatrix{<:BlasFloat}, p::Real) = _cond1Inf(lu(A), p, norm(A, p))
_cond1Inf(A::AbstractMatrix, p::Real) = norm(A, p)*norm(inv(A), p)
_cond1Inf(A::StridedMatrix{<:BlasFloat}, p::Real) = _cond1Inf(lu(A), p, opnorm(A, p))
_cond1Inf(A::AbstractMatrix, p::Real) = opnorm(A, p)*opnorm(inv(A), p)

## Lyapunov and Sylvester equation

Expand Down
6 changes: 6 additions & 0 deletions stdlib/LinearAlgebra/src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ using Base: @deprecate, depwarn

@deprecate cond(F::LinearAlgebra.LU, p::Integer) cond(convert(AbstractArray, F), p)

# deprecate vecnorm in favor of norm
@deprecate vecnorm norm

# deprecate vecdot in favor of dot
@deprecate vecdot dot

# PR #22188
export cholfact, cholfact!
@deprecate cholfact!(A::StridedMatrix, uplo::Symbol, ::Type{Val{false}}) cholesky!(Hermitian(A, uplo), Val(false))
Expand Down
Loading