typename Wavefunction<Rank>::Ptr Wavefunction<Rank>::CopyDeep() const { /* Set up representations and stuff */ Ptr newPsi = Ptr(new Wavefunction()); newPsi->SetRepresentation(this->Repr->Copy()); /* Allocate data */ for (size_t i = 0; i < this->WavefunctionData.size(); i++) { //Allocate data buffer in new wavefunction DataArray oldData ( GetData(i) ); int bufferName = newPsi->AllocateData(oldData.shape()); if (bufferName != (int)i) { throw std::runtime_error("What! something is wrong in Wavefunction::CopyDeep()"); } //Copy data buffer to new wavefunction DataArray newData ( newPsi->GetData(bufferName) ); newData = oldData; } //Set active buffer on the new wavefunction newPsi->SetActiveBuffer(this->GetActiveBufferName()); return newPsi; }
typename Wavefunction<Rank>::Ptr Wavefunction<Rank>::Copy() const { /* Set up representations and stuff */ Ptr newPsi = Ptr(new Wavefunction()); newPsi->SetRepresentation(this->Repr->Copy()); /* Allocate data */ int bufferName = newPsi->AllocateData(Data.shape()); newPsi->SetActiveBuffer(bufferName); /* Copy data */ newPsi->Data = this->Data; return newPsi; }