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

Document return types of custom c functions #292

Open
CGMossa opened this issue May 5, 2023 · 2 comments
Open

Document return types of custom c functions #292

CGMossa opened this issue May 5, 2023 · 2 comments

Comments

@CGMossa
Copy link

CGMossa commented May 5, 2023

In order to circumvent #291, I decided to try to make a c-function, that takes a rectangular matrix, and performs some calculation on an array.
But there must be a LHS to all lines;
And thus I need a return type that means "2-d array" or even "1-D array".

Is it possible to know how this could look like?
I've tried double* and double**, but that gave complaints.

@CGMossa CGMossa closed this as completed May 5, 2023
@CGMossa CGMossa reopened this May 6, 2023
@CGMossa
Copy link
Author

CGMossa commented May 6, 2023

I'm reopening this because I have a hard time figuring out what is allowed and not.
In C, we cannot return arrays.
An idea would be to use void c_function(size_t len, const double* input, double* output), but that doesn't work because odin expects a LHS to every line.
I want to do an operation on a long array $M × 3$, and then use that to fill out vectors.
But to do so, I'm expected to use i for the output vector $N ×1$. But then how can I perform the calculation on the former, store it, and then use its content on filling out N×1. if I just have a dummy <- c_function(...) it doesn't appear in the odin.c file generated, as in doesn't appear when things are happening.

@CGMossa
Copy link
Author

CGMossa commented May 7, 2023

It is as if I'm unable to pass a double** arr to a custom c-function..

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

No branches or pull requests

1 participant