Skip to content

Commit

Permalink
adding low level reverse + utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSiebert1 committed Jan 7, 2024
1 parent 5b3b8ca commit 13035a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/AdoubleModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ JLCXX_MODULE Adouble_module(jlcxx::Module &types)
types.method("fov_forward", fov_forward);
types.method("hov_forward", hov_forward);

types.method("fos_reverse", fos_reverse);
types.method("hos_reverse", hos_reverse);

types.method("fov_reverse", fov_reverse);
types.method("hov_reverse", hov_reverse);

// pointwise-smooth functions
types.method("enableMinMaxUsingAbs", enableMinMaxUsingAbs);
types.method("get_num_switches", get_num_switches);
Expand Down
1 change: 1 addition & 0 deletions src/AdoubleModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ end

# more low level function
export zos_forward, fos_forward, hos_forward, fov_forward, hov_forward
export fos_reverse, hos_reverse, fov_reverse, hov_reverse



Expand Down
12 changes: 12 additions & 0 deletions src/array_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ JLCXX_MODULE julia_module_array_types(jlcxx::Module &types)
types.method("alloc_vec_double", myalloc1);
types.method("alloc_vec_short", [](int i)
{ return new short[i]; });
types.method("alloc_mat_short", [](int const rows, int const cols)
{ short ** A = new short*[rows];
for(int i=0; i<rows; i++)
{
A[i] = new short[cols];
}
return A; });
types.method("myalloc2", myalloc2);
types.method("myalloc3", myalloc3);

// utils for accessing matrices or vectors
types.method("getindex_tens", [](double ***A, const int &dim, const int &row, const int &col)
{ return A[dim - 1][row - 1][col - 1]; });
types.method("setindex_tens", [](double ***A, const double val, const int &dim, const int &row, const int &col)
{ A[dim - 1][row - 1][col - 1] = val; });
types.method("getindex_mat", [](double **A, const int &row, const int &col)
{ return A[row - 1][col - 1]; });
types.method("setindex_mat", [](double **A, const double val, const int &row, const int &col)
Expand Down
6 changes: 5 additions & 1 deletion src/array_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module array_types

##### raw CxxPtr utilities ###################

Base.getindex(X::CxxPtr{CxxPtr{CxxPtr{Cdouble}}}, dim::Int64, row::Int64, col::Int64) = getindex_tens(X, dim, row, col)
Base.setindex!(X::CxxPtr{CxxPtr{CxxPtr{Cdouble}}}, val::Cdouble, dim::Int64, row::Int64, col::Int64) = setindex_tens(X, val, dim, row, col)


Base.getindex(X::CxxPtr{CxxPtr{Cdouble}}, row::Int64, col::Int64) = getindex_mat(X, row, col)
Base.setindex!(X::CxxPtr{CxxPtr{Cdouble}}, val::Cdouble, row::Int64, col::Int64) = setindex_mat(X, val, row, col)

Expand Down Expand Up @@ -117,6 +121,6 @@ Base.size(X::CxxVector{T}) where T <: Real = X.n
Base.getindex(X::CxxVector{T}, row::Int64) where T <: Real = getindex(X.data, row)
Base.setindex!(X::CxxVector{T}, val::T, row::Int64) where T <: Real = setindex!(X.data, val, row)

export CxxMatrix, CxxVector, myalloc2, myalloc1, alloc_vec_double, alloc_vec_short, alloc_vec
export CxxMatrix, CxxVector, myalloc3, myalloc2, myalloc1, alloc_vec_double, alloc_vec_short, alloc_vec, alloc_mat_short

end # module arry_types

0 comments on commit 13035a2

Please sign in to comment.