-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BlockArrays in module and more efficient Conv
- Loading branch information
Showing
6 changed files
with
153 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
@printf("\nTesting BlockArrays\n") | ||
|
||
using AbstractOperators:BlockArrays | ||
|
||
T = Float64 | ||
x = [2.0; 3.0] | ||
xb = ([2.0; 3.0], Complex{T}[4.0; 5.0; 6.0], [1.0 2.0 3.0; 4.0 5.0 6.0]) | ||
|
||
x2 = randn(2) | ||
x2b = (randn(2), randn(3)+im.*randn(3), randn(2,3)) | ||
|
||
@test blocksize(x) == (2,) | ||
@test blocksize(xb) == ((2,),(3,),(2,3)) | ||
|
||
@test blockeltype(x) == T | ||
@test blockeltype(xb) == (T, Complex{T},T) | ||
|
||
@test blocklength(x) == 2 | ||
@test blocklength(xb) == 2+3+6 | ||
|
||
@test blockvecnorm(x) == vecnorm(x) | ||
@test blockvecnorm(xb) == sqrt(vecnorm(xb[1])^2+vecnorm(xb[2])^2+vecnorm(xb[3])^2) | ||
|
||
@test blockmaxabs(x) == 3.0 | ||
@test blockmaxabs(xb) == 6.0 | ||
|
||
@test typeof(blocksimilar(x)) == typeof(x) | ||
@test typeof(blocksimilar(xb)) == typeof(xb) | ||
|
||
@test blockcopy(x) == x | ||
@test blockcopy(xb) == xb | ||
|
||
y = blocksimilar(x) | ||
yb = blocksimilar(xb) | ||
blockcopy!(y,x) | ||
blockcopy!(yb,xb) | ||
|
||
@test y == x | ||
@test yb == xb | ||
|
||
y = blocksimilar(x) | ||
yb = blocksimilar(xb) | ||
blockset!(y,x) | ||
blockset!(yb,xb) | ||
|
||
@test y == x | ||
@test yb == xb | ||
|
||
z = blockvecdot(x,x2) | ||
zb = blockvecdot(xb,x2b) | ||
@test z == vecdot(x,x2) | ||
@test zb == vecdot(xb[1],x2b[1])+vecdot(xb[2],x2b[2])+vecdot(xb[3],x2b[3]) | ||
|
||
y = blockzeros(x) | ||
yb = blockzeros(xb) | ||
@test y == zeros(2) | ||
@test yb == (zeros(2),zeros(3)+im*zeros(3),zeros(2,3)) | ||
|
||
y = blockzeros(blocksize(x)) | ||
yb = blockzeros(blocksize(xb)) | ||
@test y == zeros(2) | ||
@test yb == (zeros(2),zeros(3)+im*zeros(3),zeros(2,3)) | ||
|
||
y = blockzeros(blockeltype(x),blocksize(x)) | ||
yb = blockzeros(blockeltype(xb),blocksize(xb)) | ||
@test y == zeros(2) | ||
@test yb == (zeros(2),zeros(3)+im*zeros(3),zeros(2,3)) | ||
|
||
blockaxpy!(y,x,2,x2) | ||
blockaxpy!(yb,xb,2,x2b) | ||
|
||
@test y == x .+ 2.*x2 | ||
@test yb == (xb[1] .+ 2.*x2b[1], xb[2] .+ 2.*x2b[2], xb[3] .+ 2.*x2b[3]) | ||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.