Skip to content

Wrong assignment between Array<TinyVector> and TinyVector expression #108

@AnderOne

Description

@AnderOne

There is a problem with to unwrap of expression templates when we use multicomponent Array on the left side and a vector expression on the right.

#include <blitz/array.h>
#include <iostream>

int main() {

	blitz::Array<blitz::TinyVector<double, 2>, 1> DAT(5);
	blitz::TinyVector<double, 2> TMP(3, 7);
#if false
	//Here we construct TinyVector from expression and fill Array. It's right!
	DAT = blitz::TinyVector<double, 2> (TMP * 2 - 1);
#else
	//This code leads to incorrect behavior!
	DAT = TMP * 2 - 1;
#endif
	std::cout << DAT << std::endl;

	return 0;
}

If N-dimensional array is used then it leads to compilation error:

#include <blitz/array.h>
#include <iostream>

int main() {

	blitz::Array<blitz::TinyVector<double, 2>, 2> DAT(5, 4);
	blitz::TinyVector<double, 2> TMP(3, 7);
#if false
	//Here we construct TinyVector from expression and fill Array. It's right!
	DAT = blitz::TinyVector<double, 2> (TMP * 2 - 1);
#else
	//This code leads to compilation error!
	/*./blitz/blitz/array/expr.h:194:81:
	error: no match for call to
	‘(const T_expr {aka const blitz::FastTV2Iterator<double, 2>})
	(const blitz::TinyVector<int, 2>&)’
	T_result operator()(const TinyVector<int, N_rank>& i) const
	{ return iter_(i); }
	*/
	DAT = TMP * 2 - 1;
#endif
	std::cout << DAT << std::endl;

	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions