-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathbasis.jl
More file actions
25 lines (23 loc) · 909 Bytes
/
basis.jl
File metadata and controls
25 lines (23 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using DifferentiationInterface: basis, multibasis
using LinearAlgebra
using StaticArrays, JLArrays
using Test
@testset "Basis" begin
b_ref = [0, 1, 0]
@test basis(rand(3), 2) isa Vector
@test basis(rand(3), 2) == b_ref
@test basis(jl(rand(3)), 2) isa JLArray
@test Array(basis(jl(rand(3)), 2)) == [0, 1, 0]
@test multibasis(jl(rand(3)), [1, 2]) isa JLArray
@test Array(multibasis(jl(rand(3)), [1, 2])) == [1, 1, 0]
@test all(basis(jl(rand(3)), 2) .== b_ref)
@test basis(@SVector(rand(3)), 2) isa SVector
@test basis(@SVector(rand(3)), 2) == b_ref
b_ref = [0 1 0; 0 0 0; 0 0 0]
@test basis(rand(3, 3), 4) isa Matrix
@test basis(rand(3, 3), 4) == b_ref
@test basis(jl(rand(3, 3)), 4) isa JLArray
@test all(basis(jl(rand(3, 3)), 4) .== b_ref)
@test basis(@SMatrix(rand(3, 3)), 4) isa SMatrix
@test basis(@SMatrix(rand(3, 3)), 4) == b_ref
end