File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -345,14 +345,21 @@ Space(sp::ProductDomain) = TensorSpace(sp)
345
345
setdomain (sp:: TensorSpace , d:: ProductDomain ) = TensorSpace (setdomain .(factors (sp), factors (d)))
346
346
347
347
* (A:: Space , B:: Space ) = A ⊗ B
348
- function ^ (A :: Space , p:: Integer )
348
+ @inline function _powspace (A , p)
349
349
p >= 1 || throw (ArgumentError (" exponent must be >= 1, received $p " ))
350
350
# Enumerate common cases to help with constant propagation
351
351
p == 1 ? A :
352
352
p == 2 ? A * A :
353
353
p == 3 ? A * A * A :
354
354
foldl (* , ntuple (_ -> A, p))
355
355
end
356
+ @static if VERSION >= v " 1.8"
357
+ Base. @constprop :aggressive function ^ (A:: Space , p:: Integer )
358
+ _powspace (A, p)
359
+ end
360
+ else
361
+ ^ (A:: Space , p:: Integer ) = _powspace (A, p)
362
+ end
356
363
357
364
358
365
# # TODO : generalize
Original file line number Diff line number Diff line change @@ -71,9 +71,15 @@ using LinearAlgebra
71
71
end
72
72
@test ApproxFunBase. intpow (f,- 2 ) == f^- 2 == 1 / (f* f)
73
73
74
- @test sp^ 1 == sp
75
- @test sp^ 2 == sp * sp
76
- @test sp^ 3 == sp * sp * sp
74
+ if VERSION >= v " 1.8"
75
+ @test (@inferred (x -> x^ 1 )(sp)) == sp
76
+ @test (@inferred (x -> x^ 2 )(sp)) == sp * sp
77
+ @test (@inferred (x -> x^ 3 )(sp)) == sp * sp * sp
78
+ else
79
+ @test sp^ 1 == sp
80
+ @test sp^ 2 == sp * sp
81
+ @test sp^ 3 == sp * sp * sp
82
+ end
77
83
@test sp^ 4 == sp * sp * sp * sp
78
84
@test sp^ 5 == sp * sp * sp * sp * sp
79
85
end
You can’t perform that action at this time.
0 commit comments