Skip to content

Commit 1152f4c

Browse files
authored
check mul bounds (#149)
* check bounds in simplified mul * check_mul_axes in simplify * Update Project.toml * Update runtests.jl
1 parent 040ec5d commit 1152f4c

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ContinuumArrays"
22
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
3-
version = "0.12.5"
3+
version = "0.12.6"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/ContinuumArrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using IntervalSets, DomainSets, LinearAlgebra, LazyArrays, FillArrays, BandedMat
33
import Base: @_inline_meta, @_propagate_inbounds_meta, axes, size, getindex, convert, prod, *, /, \, +, -, ==, ^,
44
IndexStyle, IndexLinear, ==, OneTo, tail, similar, copyto!, copy, diff,
55
first, last, show, isempty, findfirst, findlast, findall, Slice, union, minimum, maximum, sum, _sum,
6-
getproperty, isone, iszero, zero, abs, <, , >, , string, summary, to_indices, view
6+
getproperty, isone, iszero, zero, abs, <, , >, , string, summary, to_indices, view, @propagate_inbounds
77
import Base.Broadcast: materialize, BroadcastStyle, broadcasted, Broadcasted
88
import LazyArrays: MemoryLayout, Applied, ApplyStyle, flatten, _flatten, colsupport, combine_mul_styles, AbstractArrayApplyStyle,
99
adjointlayout, arguments, _mul_arguments, call, broadcastlayout, layout_getindex, UnknownLayout,
@@ -13,7 +13,7 @@ import LinearAlgebra: pinv, inv, dot, norm2, ldiv!, mul!
1313
import BandedMatrices: AbstractBandedLayout, _BandedMatrix
1414
import BlockArrays: block, blockindex, unblock, blockedrange, _BlockedUnitRange, _BlockArray
1515
import FillArrays: AbstractFill, getindex_value, SquareEye
16-
import ArrayLayouts: mul, ZerosLayout, ScalarLayout, AbstractStridedLayout
16+
import ArrayLayouts: mul, ZerosLayout, ScalarLayout, AbstractStridedLayout, check_mul_axes
1717
import QuasiArrays: cardinality, checkindex, QuasiAdjoint, QuasiTranspose, Inclusion, SubQuasiArray,
1818
QuasiDiagonal, MulQuasiArray, MulQuasiMatrix, MulQuasiVector, QuasiMatMulMat, QuasiArrayLayout,
1919
ApplyQuasiArray, ApplyQuasiMatrix, LazyQuasiArrayApplyStyle, AbstractQuasiArrayApplyStyle, AbstractQuasiLazyLayout,

src/operators.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ macro simplify(qt)
2929
if length(qt.args[1].args) == 3
3030
ret = quote
3131
ContinuumArrays.simplifiable(::typeof(*), A::$Atyp, B::$Btyp) = Val(true)
32-
function ContinuumArrays.mul($Aname::$Atyp, $Bname::$Btyp)
32+
Base.@propagate_inbounds function ContinuumArrays.mul($Aname::$Atyp, $Bname::$Btyp)
33+
@boundscheck ContinuumArrays.check_mul_axes($Aname, $Bname)
3334
$mat
3435
end
3536
end
@@ -38,7 +39,7 @@ macro simplify(qt)
3839
ret = quote
3940
$ret
4041
ContinuumArrays.simplifiable(::typeof(*), ::$Badj, A::$Aadj) = Val(true)
41-
ContinuumArrays.mul(Bc::$Badj, Ac::$Aadj) = ContinuumArrays.mul(Ac', Bc')'
42+
Base.@propagate_inbounds ContinuumArrays.mul(Bc::$Badj, Ac::$Aadj) = ContinuumArrays.mul(Ac', Bc')'
4243
end
4344
end
4445

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import LazyArrays: MemoryLayout, ApplyStyle, Applied, colsupport, arguments, App
4242
@test D^2 * x QuasiZeros(x)
4343
@test D*[x D*x] == [D*x D^2*x]
4444
@test stringmime("text/plain", D) == "Derivative(Inclusion(-1..1))"
45+
@test_throws DimensionMismatch Derivative(Inclusion(0..1)) * x
4546
end
4647
end
4748

0 commit comments

Comments
 (0)