# C++ version, complex matrix-vector multiplication

+1 vote
asked

I found that in C++ version, the function operator* for matrix-vector multiplication seems not implemented for complex matrix CMatrix and complex vector CVector. The sample code is as follows.

CMatrix a (2,2);
CVector v (2);
auto b = a * v;


The error message is

error: no match for ‘operator*’ (operand types are ‘itensor::CMatrix’ {aka ‘itensor::Ten<itensor::MatRangeT<0>, std::complex >’} and ‘itensor::CVector’ {aka ‘itensor::Ten<itensor::VecRangeT<0>, std::complex >’})

Is there a chance that it will be implemented?

commented by (70.1k points)
Hi Chiamin,
I reviewed the code for real-valued vector matrix multiplication and it should be pretty straightforward to add the complex case. Let me try to do this soon for you and please remind me if you don't hear back about it in a week or so.

Miles

## 1 Answer

+1 vote
answered by (70.1k points)
selected by

Best answer

After writing the comment above, I realized this feature could be added rather quickly so I just added it. Please see the following PR to see the lines of code that were changed (the important ones are in tensor/mat_impl.h) which I thought might interest you:
https://github.com/ITensor/ITensor/pull/409

Thanks for pointing this out -

Miles