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

cml::vector<const double *, cml::dynamic<>> problem #43

Closed
wzhy opened this issue May 29, 2024 · 6 comments
Closed

cml::vector<const double *, cml::dynamic<>> problem #43

wzhy opened this issue May 29, 2024 · 6 comments
Assignees
Labels

Comments

@wzhy
Copy link

wzhy commented May 29, 2024

Hi!
I wrote code like this in a header file:
typedef cml::vector<const double *, cml::dynamic<>> vector_pdd;
Then
cml::vector_cpdd pData;

I got some errors when compiling it :

error: invalid use of incomplete type 'cml::vector_traits<cml::vector<const double*, cml::allocated<> > >::element_traits' {aka 'struct cml::scalar_traits<const double*, void>'}
In template: implicit instantiation of undefined template 'cml::scalar_traits<const double *>'

How can I fix this ? I'm new in C++...
And [http://cmldev.net/] can not open. So is there any doc about CML?
Thank you very much!

@demianmnave demianmnave self-assigned this May 29, 2024
@demianmnave
Copy link
Owner

Hi wzhy,

I wrote code like this in a header file:
typedef cml::vector<const double *, cml::dynamic<>> vector_pdd;

The first template argument should be a basic numeric type; e.g. double or float. So, you will want something like this:

using vector_pdd = cml::vector<double, cml::dynamic<>>;

Alternatively, you can use the matching predefined vector type from cml/vector/types.h; e.g.:

using vector_pdd = cml::vectord;

And [http://cmldev.net/] can not open. So is there any doc about CML?

Unfortunately, I only have the in-source, Doxygen-formatted documentation right now. Apparently, real documentation has been on my list for some time (#7)! The tests may also be useful for seeing how things fit together.

Let me know if you have any more trouble with the compiler error.

@wzhy
Copy link
Author

wzhy commented May 29, 2024

Thanks for your reply, demianmnave!
I knew the /matrix/types.h and /vector/types.h there. Actually, I am immigrating one program(at least over 12 years old) using your CML^^ The version of CML this program used may be 1.0 as the files organization is the same with 1.0~1.0.4 which are downloaded from sourceforge.
codes like this work fine in this old program:

typedef cml::vector<const double *, cml::dynamic<>> vector_pdd;
cml::vector_pdd pData;
pData.data()
pData.resize(5)

Now I want to immigrate CML to V2.2.1 release. So problem occurs.
Any suggestion is welcomed.

BTW: CML_VERSION and CML_VERSION_STRING in /cml/version.h in the V2.2.1 release may be modified to 2.2.1^^

@demianmnave
Copy link
Owner

Actually, I am immigrating one program(at least over 12 years old) ...

Yikes, that sounds like a challenge! I don't know if CML2 will be the right fit since it keeps tighter control over the types it understands (essentially, numeric-like types).

That said, you could try specializing cml::scalar_traits as unsigned long long and see if that gets you further along:

namespace cml {

/** Specialization of scalar traits for pointer types. */
template<typename Base> struct scalar_traits<Base*, void>
: detail::default_integral_traits<unsigned long long>
{
  static constexpr Scalar sqrt_epsilon() { return 0; }
};

/** Specialization of scalar traits for pointer const types. */
template<typename Base> struct scalar_traits<const Base*, void>
: detail::default_integral_traits<unsigned long long>
{
  static constexpr Scalar sqrt_epsilon() { return 0; }
};

}

If the code does not rely on math operators, you might have better luck swapping out cml::vector<...> with std::vector<const double*>. If you were able to post a few examples of how the code is using cml::vector<>, I might be able to give you more specific advice.

@wzhy
Copy link
Author

wzhy commented Jun 29, 2024

Hi Demian,
The method you gave above is not working...
I read the code of my program carefully and found that the author used vector_pdd as a dynamic 2D Array (as C style)^^ So I used cml::vectord *pData and pData = new cml::vectord[DataNum] replace it. Maybe ugly and it worked!
Then I immigrated all the other codes using CML from v1.0 to v2.2.1. Only one function should be changed in my code: cml::T --> cml::transpose. And then the whole program worked well so far.
Thank you very much again!

@demianmnave
Copy link
Owner

Hi Will, glad you figured it out without having to do anything fancy!

Good luck with your project, and feel free to submit another issue if you run into any more problems.

@wzhy
Copy link
Author

wzhy commented Jun 29, 2024

Have a nice weekend^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants