Problem/Changes to basic linear algebra in C++

Hello,

I recently updated my ngsolve installation and noticed, that something must have changed regarding the implementation of basic linear algebra in ngsolve. In a C++ add-on I wrote it used to be possible to assign to FlatVectors like this:

void SomeFunction(FlatVector<> point, const FlatVector<>& res) 
{ \\some calculations with point
	res = point;
}

Now this results in:

error: no match for ‘operator=’ (operand types are
‘ngbla::FlatVector’ {aka ‘const ngbla::VectorView<double, long unsigned int, std::integral_constant<int, 1> >’} and
‘ngbla::FlatVector’ {aka ‘ngbla::VectorView<double, long unsigned int, std::integral_constant<int, 1> >’})

Has anybody else had a similar problem and knows how to fix this? And what change actually caused this problem? I am grateful for any help.
Best regards,
Florian Oberender

Hi Florian,

we are in the process of cleaning up the basic linear algebra, we think it is counter-intuitive to assign to a const object, as it was possible before. Remove the const for the result vector.

To allow rvalue objects use

void SomeFunction(FlatVector<> point, FlatVector<> res) 

or

void SomeFunction(FlatVector<> point, FlatVector<> && res) 

Joachim

1 Like

Hello Joachim,

thank you for the fast reply. Now that I think about it it is indeed strange that it worked before and nice, that it doesn’t work anymore. Thank you for your additional suggestions. For now I could simply remove the const and everything works fine again.

Best regards,
Florian