First version - #1
Conversation
|
Notice that |
|
Even if the PR looks huge, a lot of the code has been copied. The only files that should be reviewed are the CMakelists and the "code" files, except |
When installing the config file, the path given to OVERRIDE_MODULE_PATH is saved as relative to the install prefix.
|
|
||
| if (other.isComplex()) | ||
| { | ||
| std::cerr << "[matioCpp::Vector::fromOther] The input variable is complex, this is not." << std::endl; |
There was a problem hiding this comment.
Ahhh, this in the C++ sense, that was not super clear for me.
There was a problem hiding this comment.
I have opened an issue for fixing this #4
There was a problem hiding this comment.
@S-Dafarra, that's really cool! Just two curiosities:
- Does it work with matrices?
- Does it handle eigen vectors/matrices? As far as I understood the vectors can be converted in
spanbut the matrices not
| * @param imaginaryData A void pointer to the (flattened) imaginary data. Check the documentation of initializeVariable for understanding how to obtain/interpret this vector. | ||
| * @return true in case the variable was correctly initialized. | ||
| */ | ||
| bool initializeComplexVariable(const std::string& name, const VariableType& variableType, const ValueType& valueType, const std::vector<size_t>& dimensions, void *realData, void *imaginaryData); |
There was a problem hiding this comment.
With complex do you mean variables containing std::complex numbers?
There was a problem hiding this comment.
Yes, matio supports the definition of complex numbers by returning separate arrays for the real and the imaginary part.
| * @param data A void pointer to the (flattened) data. | ||
| * @return true in case the variable was correctly initialized. | ||
| */ | ||
| bool initializeVariable(const std::string &name, const VariableType &variableType, const ValueType &valueType, const std::vector<size_t> &dimensions, void *data); |
There was a problem hiding this comment.
Just a curiosity, do you decide to handle the VariableType with a variable rather than a template because it simplifies the interface?
There was a problem hiding this comment.
With this method, I need to call stuff in the pimpl, so it cannot be templated. For the same reason, I have that ugly void* at the end. Nevertheless, this is also the way matvar_t stores data inside. Its type is not known at compile time.
| template<typename T> | ||
| matioCpp::Vector<T>::Vector() | ||
| { | ||
| static_assert (!std::is_same<T, bool>::value, "Vector<bool> is not supported." ); |
There was a problem hiding this comment.
It is a pity that std::vector<bool> does not have the data() method
Probably |
Yes, I am working on its implementation now. I am not considering matrices, but generic multidimensional arrays (i.e. with the number of dimensions >= 2). In principle, also vectors could be considered as multidimensional arrays, but I wanted to leverage the use of For what concerns conversions to Eigen, I am avoiding them since I want to keep C++14 for the time being. Nevertheless, it should be pretty easy to define maps from |
|
For multidimensional array, you may have a look at Interesting link: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0009r10.html |
Thanks, I'll take a look, even though it seems still a little far compared to |
|
@S-Dafarra May I still do a review of this PR? |
|
It has already been merged, but feel free to comment if something is not clear. I can try to address the comments in another PR. |
It adds the skeleton, a basic interface to a generic variable, and the interface to a Vector.
What is missing:
DocumentationI may start adding some documentation in the next few days. Any help is welcome.