Skip to content

Commit 580cc97

Browse files
authored
Final piece for v3.0 (#114)
1 parent 867aa43 commit 580cc97

File tree

4 files changed

+103
-75
lines changed

4 files changed

+103
-75
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LinearMaps"
22
uuid = "7a12625a-238d-50fd-b39a-03d52299707e"
3-
version = "2.7.0"
3+
version = "3.0"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

docs/src/custom.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ mul!(similar(x)', x', A)
200200
# ## Application to matrices
201201

202202
# By default, applying a `LinearMap` `A` to a matrix `X` via `A*X` does
203-
# *not* aplly `A` to each column of `X` viewed as a vector, but interprets
203+
# *not* apply `A` to each column of `X` viewed as a vector, but interprets
204204
# `X` as a linear map, wraps it as such and returns `(A*X)::CompositeMap`.
205205
# Calling the in-place multiplication function `mul!(Y, A, X)` for matrices,
206206
# however, does compute the columnwise action of `A` on `X` and stores the

docs/src/history.md

Lines changed: 86 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,86 @@
1-
# What's new?
2-
3-
### What's new in v2.7
4-
* Potential reduction of memory allocations in multiplication of
5-
`LinearCombination`s, `BlockMap`s, and real- or complex-scaled `LinearMap`s.
6-
For the latter, a new internal type `ScaledMap` has been introduced.
7-
* Multiplication code for `CompositeMap`s has been refactored to facilitate to
8-
provide memory for storage of intermediate results by directly calling helper
9-
functions.
10-
11-
### What's new in v2.6
12-
* New feature: "lazy" Kronecker product, Kronecker sums, and powers thereof
13-
for `LinearMap`s. `AbstractMatrix` objects are promoted to `LinearMap`s if
14-
one of the first 8 Kronecker factors is a `LinearMap` object.
15-
* Compatibility with the generic multiply-and-add interface (a.k.a. 5-arg
16-
`mul!`) introduced in julia v1.3
17-
18-
### What's new in v2.5
19-
* New feature: concatenation of `LinearMap`s objects with `UniformScaling`s,
20-
consistent with (h-, v-, and hc-)concatenation of matrices. Note, matrices
21-
`A` must be wrapped as `LinearMap(A)`, `UniformScaling`s are promoted to
22-
`LinearMap`s automatically.
23-
24-
### What's new in v2.4
25-
* Support restricted to Julia v1.0+.
26-
27-
### What's new in v2.3
28-
* Fully Julia v0.7/v1.0/v1.1 compatible.
29-
* Full support of noncommutative number types such as quaternions.
30-
31-
### What's new in v2.2
32-
* Fully Julia v0.7/v1.0 compatible.
33-
* A `convert(SparseMatrixCSC, A::LinearMap)` function, that calls the `sparse`
34-
matrix generating function.
35-
36-
### What's new in v2.1
37-
* Fully Julia v0.7 compatible; dropped compatibility for previous versions of
38-
Julia from LinearMaps.jl v2.0.0 on.
39-
* A 5-argument version for `mul!(y, A::LinearMap, x, α=1, β=0)`, which
40-
computes `y := α * A * x + β * y` and implements the usual 3-argument
41-
`mul!(y, A, x)` for the default `α` and `β`.
42-
* Synonymous `convert(Matrix, A::LinearMap)` and `convert(Array, A::LinearMap)`
43-
functions, that call the `Matrix` constructor and return the matrix
44-
representation of `A`.
45-
* Multiplication with matrices, interpreted as a block row vector of vectors:
46-
* `mul!(Y::AbstractArray, A::LinearMap, X::AbstractArray, α=1, β=0)`:
47-
applies `A` to each column of `X` and stores the result in-place in the
48-
corresponding column of `Y`;
49-
* for the out-of-place multiplication, the approach is to compute
50-
`convert(Matrix, A * X)`; this is equivalent to applying `A` to each
51-
column of `X`. In generic code which handles both `A::AbstractMatrix` and
52-
`A::LinearMap`, the additional call to `convert` is a noop when `A` is a
53-
matrix.
54-
* Full compatibility with [Arpack.jl](https://github.com/JuliaLinearAlgebra/Arpack.jl)'s
55-
`eigs` and `svds`; previously only `eigs` was working. For more, nicely
56-
collaborating packages see the [Example](#example) section.
1+
# Version history
2+
3+
## What's new in v3.0
4+
5+
* BREAKING change: Internally, any dependence on former `A*_mul_B!` methods is abandonned.
6+
For custom `LinearMap` subtypes, there are now two options:
7+
1. In case your type is invariant under adjoint/transposition (i.e.,
8+
`adjoint(L::MyLinearMap)::MyLinearMap` similar to, for instance,
9+
`LinearCombination`s or `CompositeMap`s, `At_mul_B!` and `Ac_mul_B!` do
10+
not require any replacement! Rather, multiplication by `L'` is, in this case,
11+
handled by `mul!(y, L::MyLinearMap, x[, α, β])`.
12+
2. Otherwise, you will need to define `mul!` methods with the signature
13+
`mul!(y, L::TransposeMap{<:Any,MyLinearMap}, x[, α, β])` and
14+
`mul!(y, L::AdjointMap{<:Any,MyLinearMap}, x[, α, β])`.
15+
* Left multiplying by a transpose or adjoint vector (e.g., `y'*A`)
16+
produces a transpose or adjoint vector output, rather than a composite `LinearMap`.
17+
* Block concatenation now handles matrices and vectors directly by internal promotion
18+
to `LinearMap`s. For `[h/v/hc]cat` it suffices to have a `LinearMap` object anywhere
19+
in the list of arguments. For the block-diagonal concatenation via
20+
`SparseArrays.blockdiag`, a `LinearMap` object has to appear among the first 8 arguments.
21+
This restriction, however, does not apply to block-diagonal concatenation via
22+
`Base.cat(As...; dims=(1,2))`.
23+
* Introduction of more expressive and visually appealing `show` methods, replacing
24+
the fallback to the generic `show`.
25+
26+
## What's new in v2.7
27+
28+
* Potential reduction of memory allocations in multiplication of
29+
`LinearCombination`s, `BlockMap`s, and real- or complex-scaled `LinearMap`s.
30+
For the latter, a new internal type `ScaledMap` has been introduced.
31+
* Multiplication code for `CompositeMap`s has been refactored to facilitate to
32+
provide memory for storage of intermediate results by directly calling helper
33+
functions.
34+
35+
## What's new in v2.6
36+
37+
* New feature: "lazy" Kronecker product, Kronecker sums, and powers thereof
38+
for `LinearMap`s. `AbstractMatrix` objects are promoted to `LinearMap`s if
39+
one of the first 8 Kronecker factors is a `LinearMap` object.
40+
* Compatibility with the generic multiply-and-add interface (a.k.a. 5-arg
41+
`mul!`) introduced in julia v1.3
42+
43+
## What's new in v2.5
44+
45+
* New feature: concatenation of `LinearMap`s objects with `UniformScaling`s,
46+
consistent with (h-, v-, and hc-)concatenation of matrices. Note, matrices
47+
`A` must be wrapped as `LinearMap(A)`, `UniformScaling`s are promoted to
48+
`LinearMap`s automatically.
49+
50+
## What's new in v2.4
51+
52+
* Support restricted to Julia v1.0+.
53+
54+
## What's new in v2.3
55+
56+
* Fully Julia v0.7/v1.0/v1.1 compatible.
57+
* Full support of noncommutative number types such as quaternions.
58+
59+
## What's new in v2.2
60+
61+
* Fully Julia v0.7/v1.0 compatible.
62+
* A `convert(SparseMatrixCSC, A::LinearMap)` function, that calls the `sparse`
63+
matrix generating function.
64+
65+
## What's new in v2.1
66+
67+
* Fully Julia v0.7 compatible; dropped compatibility for previous versions of
68+
Julia from LinearMaps.jl v2.0.0 on.
69+
* A 5-argument version for `mul!(y, A::LinearMap, x, α=1, β=0)`, which
70+
computes `y := α * A * x + β * y` and implements the usual 3-argument
71+
`mul!(y, A, x)` for the default `α` and `β`.
72+
* Synonymous `convert(Matrix, A::LinearMap)` and `convert(Array, A::LinearMap)`
73+
functions, that call the `Matrix` constructor and return the matrix
74+
representation of `A`.
75+
* Multiplication with matrices, interpreted as a block row vector of vectors:
76+
* `mul!(Y::AbstractArray, A::LinearMap, X::AbstractArray, α=1, β=0)`:
77+
applies `A` to each column of `X` and stores the result in-place in the
78+
corresponding column of `Y`;
79+
* for the out-of-place multiplication, the approach is to compute
80+
`convert(Matrix, A * X)`; this is equivalent to applying `A` to each
81+
column of `X`. In generic code which handles both `A::AbstractMatrix` and
82+
`A::LinearMap`, the additional call to `convert` is a noop when `A` is a
83+
matrix.
84+
* Full compatibility with [Arpack.jl](https://github.com/JuliaLinearAlgebra/Arpack.jl)'s
85+
`eigs` and `svds`; previously only `eigs` was working. For more, nicely
86+
collaborating packages see the [Example](#example) section.

src/blockmap.jl

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -442,22 +442,20 @@ for k in 1:8 # is 8 sufficient?
442442
mapargs = ntuple(n ->:($(Symbol(:A, n))), Val(k-1))
443443
# yields (:LinearMap(A1), :LinearMap(A2), ..., :LinearMap(A(k-1)))
444444

445-
@eval begin
446-
function SparseArrays.blockdiag($(Is...), $L, As::MapOrVecOrMat...)
447-
return BlockDiagonalMap(convert_to_lmaps($(mapargs...))...,
448-
$(Symbol(:A, k)),
449-
convert_to_lmaps(As...)...)
450-
end
445+
@eval function SparseArrays.blockdiag($(Is...), $L, As::MapOrVecOrMat...)
446+
return BlockDiagonalMap(convert_to_lmaps($(mapargs...))...,
447+
$(Symbol(:A, k)),
448+
convert_to_lmaps(As...)...)
449+
end
450+
end
451451

452-
function Base.cat($(Is...), $L, As::MapOrVecOrMat...; dims::Dims{2})
453-
if dims == (1,2)
454-
return BlockDiagonalMap(convert_to_lmaps($(mapargs...))...,
455-
$(Symbol(:A, k)),
456-
convert_to_lmaps(As...)...)
457-
else
458-
throw(ArgumentError("dims keyword in cat of LinearMaps must be (1,2)"))
459-
end
460-
end
452+
# This method is more generic than Base._cat(catdims, A::AbstractArray...), and
453+
# therefore does not override Base/StdLib behavior
454+
function Base._cat(dims, As::MapOrVecOrMat...)
455+
if dims::Dims{2} == (1, 2)
456+
return BlockDiagonalMap(convert_to_lmaps(As...)...)
457+
else
458+
throw(ArgumentError("dims keyword in cat of LinearMaps must be (1,2)"))
461459
end
462460
end
463461

@@ -474,8 +472,8 @@ SparseArrays.blockdiag
474472
cat(As::Union{LinearMap,AbstractVecOrMat}...; dims=(1,2))::BlockDiagonalMap
475473
476474
Construct a (lazy) representation of the diagonal concatenation of the arguments.
477-
To avoid fallback to the generic `Base.cat`, there must be a `LinearMap`
478-
object among the first 8 arguments.
475+
To avoid fallback to the generic `Base.cat`, there must be a `LinearMap` object
476+
among the arguments, without any restriction on its position.
479477
"""
480478
Base.cat
481479

0 commit comments

Comments
 (0)