Skip to content

Commit

Permalink
impl transform function
Browse files Browse the repository at this point in the history
  • Loading branch information
terasakisatoshi committed May 12, 2024
1 parent 49f8e78 commit 2a05cdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion barnsley_fern/src/MyCxxWrap4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ module CxxFern
end

@reexport using .CxxAffine: Affine
export transform!
export transform!, transform

function transform(aff::Affine, x::T, y::T) where T<:AbstractFloat
refx = Ref(x)
refy = Ref(y)
CxxAffine.transform(aff, refx, refy)
return (refx[], refy[])
end

function transform!(aff::Affine, refx::Ref{T}, refy::Ref{T}) where T<:AbstractFloat
CxxAffine.transform(aff, refx, refy)
Expand Down
17 changes: 16 additions & 1 deletion barnsley_fern/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
using Test

using MyCxxWrap4: Affine, transform!, BarnsleyCategoricalDistribution
using MyCxxWrap4: Affine, transform, transform!, BarnsleyCategoricalDistribution

@testset "Affine/transform" begin
w11 = 1.0
w12 = 0.0
w21 = 0.0
w22 = 1.0
b1 = 1.
b2 = -1.

aff = Affine(w11, w12, w21, w22, b1 ,b2)

x = 1.
y = 1.
@test transform(aff, x ,y) == (2.0, 0.0)
end

@testset "Affine/transform!" begin
w11 = 1.0
Expand Down

0 comments on commit 2a05cdb

Please sign in to comment.