Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some methods for CxxMatrix #14

Merged
merged 2 commits into from
Jun 21, 2024
Merged

Add some methods for CxxMatrix #14

merged 2 commits into from
Jun 21, 2024

Conversation

j-fu
Copy link
Collaborator

@j-fu j-fu commented Jun 21, 2024

No description provided.

@j-fu
Copy link
Collaborator Author

j-fu commented Jun 21, 2024

Regarding Regarding #13 (comment): Why not just keep CxxMatrix as is and add the missing methods to make it a full fledged AbstractMatrix ?

@TimSiebert1
Copy link
Owner

We could. I just wanted to copy the values from the C++ matrix (or vector, or tensor) to the Julia matrix automatically and thought a combined struct would be a "smooth" way to handle this. However, we could also accept pre-allocated C++ and Julia data as input for the derivative! driver and do data transfer inside. What do you think?

@j-fu
Copy link
Collaborator Author

j-fu commented Jun 21, 2024

For me it is not clear why the copy is needed. The finalize already works,
What would be a situation where a CxxMatrix would not work in place of a Matrix?
It is an AbstractMatrix and inherits all the methods of AbstractMatrix, e.g:

A=ADOLC.array_types.CxxMatrix{Cdouble}(rand(2,2))
2×2 ADOLC.array_types.CxxMatrix{Float64}:
0.825202  0.343862
0.855653  0.639062

julia> A\rand(2)
2-element Vector{Float64}:
0.6624650987529754
-0.1567069631504887

@j-fu
Copy link
Collaborator Author

j-fu commented Jun 21, 2024

https://github.com/JuliaArrays/ArrayInterface.jl seems to allow a more precise specification of what can be done with a specific array type.

@TimSiebert1
Copy link
Owner

Ooooh. Didn't know that it is enough to have an AbstractMatrix.

I will add the support of the CxxMatrix (and the other types) over the weekend.

@TimSiebert1 TimSiebert1 merged commit c33e696 into master Jun 21, 2024
9 of 10 checks passed
@TimSiebert1 TimSiebert1 deleted the cxxmatrix branch August 16, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants