Help with using refactored Vector class

I am preparing a large PR on ISAPT and I noticed that some of the things that I’ve done with psi::Vector half a year ago no longer work in my hands, most likely as a result of PR #2628. Could someone please point out to me the correct way to copy one Vector onto another now?

Here’s what I’m doing right now: the FISAPT class defines
std::map<std::string, std::shared_ptr<Vector> > vectors_;
and then I use it like this:
vectors_["ZA"] = std::make_shared<Vector>("ZA", nA);
(and then some time later)
std::shared_ptr<Vector> ZA = std::make_shared<Vector>("ZA2", nA);
ZA->copy(vectors_["ZA"]);

Here’s the complete compiler error:
/home/kjp0013/psi4_gitisapt/psi4/psi4/src/psi4/fisapt/fisapt.cc:1078:32: error: no matching function for call to 'psi::Vector::copy(std::map<std::__cxx11::basic_string<char>, std::shared_ptr<psi::Vector> >::mapped_type&)'
ZA->copy(vectors_["ZA"]);
^
In file included from /home/kjp0013/psi4_gitisapt/psi4/psi4/src/psi4/libmints/factory.h:32:0,
from /home/kjp0013/psi4_gitisapt/psi4/psi4/src/psi4/fisapt/fisapt.cc:48:
/home/kjp0013/psi4_gitisapt/psi4/psi4/src/psi4/libmints/vector.h:170:10: note: candidate: void psi::IrreppedVector<T>::copy(const psi::IrreppedVector<T>&) [with T = double]
void copy(const IrreppedVector<T>& vector) {
^~~~
/home/kjp0013/psi4_gitisapt/psi4/psi4/src/psi4/libmints/vector.h:170:10: note: no known conversion for argument 1 from 'std::map<std::__cxx11::basic_string<char>, std::shared_ptr<psi::Vector>>::mapped_type {aka std::shared_ptr<psi::Vector>}' to 'const psi::IrreppedVector<double>&'

What am I doing wrong and what should I be doing instead? I do a lot of the same things with psi::Matrix that work just fine.

Thank you,
Konrad

Hi, Konrad.

You’re one character off. ZA->copy(vectors_["ZA"]); should be ZA->copy(*vectors_["ZA"]);. The difference is the asterisk. The function signature of copy changed so that it now required a Vector and not a pointer to a Vector.

As the developer responsible for that PR, I’ll be happy to take any questions relating to it. Feel free to ping me, message me here, message me on Slack, etc.

Thank you Jonathon, that’s very helpful (and it solved my issue). Just out of curiosity, are similar changes coming up for the Matrix class?

Glad to hear it!

Not anytime in the next six months. I have other priorities for the next release. Beyond that, maybe. I’d like to see it happen, but I’d need to talk with other developers.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.