|
1 | 1 | using LinearAlgebra: mul! |
2 | | -using Test: @test, @testset, @test_broken |
| 2 | +using Test: @test, @testset, @test_broken, @test_throws |
3 | 3 |
|
4 | 4 | using BlockSparseArrays: BlockSparseArray |
5 | 5 | using FusionTensors: |
6 | | - FusionMatrix, FusionTensor, FusionTensorAxes, domain_axes, codomain_axes |
7 | | -using GradedArrays: U1, dual, gradedrange |
8 | | -using TensorAlgebra: contract, matricize, permmortar, tuplemortar, unmatricize, unmatricize! |
| 6 | + FusionMatrix, FusionTensor, FusionTensorAxes, domain_axes, codomain_axes, to_fusiontensor |
| 7 | +using GradedArrays: SU2, U1, dual, gradedrange |
| 8 | +using TensorAlgebra: |
| 9 | + TensorAlgebra, contract, matricize, permmortar, tuplemortar, unmatricize, unmatricize! |
9 | 10 |
|
10 | 11 | include("setup.jl") |
11 | 12 |
|
@@ -33,6 +34,54 @@ include("setup.jl") |
33 | 34 | @test ft1 ≈ ft2 |
34 | 35 | end |
35 | 36 |
|
| 37 | +@testset "Matrix functions" begin |
| 38 | + sds22 = [ |
| 39 | + 0.25 0.0 0.0 0.0 |
| 40 | + 0.0 -0.25 0.5 0.0 |
| 41 | + 0.0 0.5 -0.25 0.0 |
| 42 | + 0.0 0.0 0.0 0.25 |
| 43 | + ] |
| 44 | + t = reshape(sds22, (2, 2, 2, 2)) |
| 45 | + g2 = gradedrange([SU2(1//2) => 1]) |
| 46 | + ft = to_fusiontensor(t, (g2, g2), (dual(g2), dual(g2))) |
| 47 | + for f in [ |
| 48 | + :exp, |
| 49 | + :cis, |
| 50 | + :log, |
| 51 | + :sqrt, |
| 52 | + :cbrt, |
| 53 | + :cos, |
| 54 | + :sin, |
| 55 | + :tan, |
| 56 | + :csc, |
| 57 | + :sec, |
| 58 | + :cot, |
| 59 | + :cosh, |
| 60 | + :sinh, |
| 61 | + :tanh, |
| 62 | + :csch, |
| 63 | + :sech, |
| 64 | + :coth, |
| 65 | + :acos, |
| 66 | + :asin, |
| 67 | + :atan, |
| 68 | + :acsc, |
| 69 | + :asec, |
| 70 | + :acot, |
| 71 | + :acosh, |
| 72 | + :asinh, |
| 73 | + :atanh, |
| 74 | + :acsch, |
| 75 | + :asech, |
| 76 | + ] |
| 77 | + t2 = @eval reshape(Base.$f(sds22), (2, 2, 2, 2)) |
| 78 | + ft2 = to_fusiontensor(t2, (g2, g2), (dual(g2), dual(g2))) |
| 79 | + @test (@eval TensorAlgebra.$f(ft, (1, 2, 3, 4), (1, 2), (3, 4))) ≈ ft2 |
| 80 | + end |
| 81 | + @test_throws ArgumentError TensorAlgebra.exp(ft, (1, 2, 3, 4), (1, 2, 3), (4,)) |
| 82 | + @test_throws ArgumentError TensorAlgebra.exp(ft, (1, 2, 3, 4), (1, 3), (2, 4)) |
| 83 | +end |
| 84 | + |
36 | 85 | @testset "contraction" begin |
37 | 86 | g1 = gradedrange([U1(0) => 1, U1(1) => 2, U1(2) => 3]) |
38 | 87 | g2 = gradedrange([U1(0) => 2, U1(1) => 2, U1(3) => 1]) |
|
0 commit comments