wichtounet / etl

Blazing-fast Expression Templates Library (ETL) with GPU support, in C++
MIT License
216 stars 17 forks source link

Expression constructor not working #2

Closed yixuan closed 7 years ago

yixuan commented 7 years ago

Great library. 👍

However I encountered some issues with the example on README page. The code below does not compile:

etl::dyn_vector<double> a({1.0,2.0,3.0});
etl::dyn_vector<double> b({3.0,2.0,1.0});
etl::dyn_vector<double> c(1.4 * (a + b) / b + b + a / 1.2);

However this works:

etl::dyn_vector<double> a({1.0,2.0,3.0});
etl::dyn_vector<double> b({3.0,2.0,1.0});
etl::dyn_vector<double> c;
c = 1.4 * (a + b) / b + b + a / 1.2;

I haven't investigated the code carefully, but it seems that the assignment operator is well defined but not the expression constructor. Since the example is taken from README, I suppose this is not by design. Any thoughts?

wichtounet commented 7 years ago

Hi,

Thanks :)

Indeed, the README is not correct. For now, it's not possible anymore to use the constructor for this.

A shorter way of doing it, is:

auto c = s(1.4 * (a + b) / b + b + a / 1.2);

but I think the c = expression is the best way to go.

If you think it should work directly with the constructor, feel free to say it and we'll discuss it :)

The README is fixed in 113fc097256012bc9ea9202095add6c5fd1eee13

Baptiste

yixuan commented 7 years ago

Personally I have no preference, so the suggested way works for me.

It is nice that you fixed the documentation. The examples are actually very important for users' first impression. :D

wichtounet commented 7 years ago

It is nice that you fixed the documentation. The examples are actually very important for users' first impression. :D

Agreed :P I'm quite happy you mentioned that ;)