Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace old backend with new #67

Merged
merged 43 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5e24700
Update
trbromley Feb 26, 2021
2e0f9bb
swap
trbromley Feb 26, 2021
e467754
Remove benchmark (we can use benchmark suite)
trbromley Feb 26, 2021
21dd041
Remove
trbromley Feb 26, 2021
1623117
update setup
trbromley Feb 26, 2021
a02030d
Remove bench
trbromley Feb 26, 2021
4469b59
Rm old backend
trbromley Feb 26, 2021
f8dce78
Move location
trbromley Feb 26, 2021
b3d6575
Removals of eigen
trbromley Feb 26, 2021
483d173
Fix
trbromley Feb 26, 2021
08a95db
Fix typo in gate
trbromley Feb 26, 2021
a878052
Correct gate type
trbromley Feb 26, 2021
39f2509
Fix Tgate
trbromley Mar 1, 2021
a62245d
Fix PhaseGate
trbromley Mar 1, 2021
a1f74f5
Fix CRY
trbromley Mar 1, 2021
e8c70aa
Remove extra test
trbromley Mar 1, 2021
c7861cd
Hack in Hermitian support
trbromley Mar 1, 2021
81c158e
Merge branch 'master' into switch_backend
trbromley Mar 1, 2021
9ee0e31
Merge branch 'master' into switch_backend
trbromley Mar 2, 2021
f1e87c3
Rename
trbromley Mar 2, 2021
4cad99c
Add new test empty
trbromley Mar 2, 2021
b6df95c
Update makefile
trbromley Mar 2, 2021
5bfefcd
Merge branch 'master' into switch_backend
trbromley Mar 3, 2021
abb890f
Update
trbromley Mar 3, 2021
1d38abc
Move getIndicesAfterExclusion
trbromley Mar 3, 2021
37a9e4c
generateBitPatterns
trbromley Mar 3, 2021
a2750c1
Remove from apply
trbromley Mar 3, 2021
07b56a7
Move constructAndApplyOperation to Gates
trbromley Mar 3, 2021
2a91beb
Revert "Remove from apply"
trbromley Mar 3, 2021
f092d71
Merge branch 'master' into switch_backend
trbromley Mar 4, 2021
e53b5de
Re-add dependencies
trbromley Mar 4, 2021
86e2ff8
Remove eigen from deploy
trbromley Mar 4, 2021
b93e079
Remove eigen from wheels
trbromley Mar 4, 2021
bb61ea3
Update Changelog
trbromley Mar 4, 2021
2f3020f
Re-add dependency
trbromley Mar 4, 2021
79a7295
Typo
trbromley Mar 4, 2021
a80a7e9
Revert "generateBitPatterns"
trbromley Mar 4, 2021
fb7377c
Revert "Move getIndicesAfterExclusion"
trbromley Mar 4, 2021
69839e2
Remove
trbromley Mar 4, 2021
0b0aec6
Update setup
trbromley Mar 4, 2021
0200222
Fix CI
trbromley Mar 4, 2021
4f34cd5
Merge branch 'master' into switch_backend
trbromley Mar 4, 2021
322d80b
Update CHANGELOG.md
trbromley Mar 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move getIndicesAfterExclusion
  • Loading branch information
trbromley committed Mar 3, 2021
commit 1d38abc588b796843e420efad9fb99c8d2512b13
17 changes: 2 additions & 15 deletions pennylane_lightning/src/Apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,16 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <set>

#include "Apply.hpp"
#include "Gates.hpp"
#include "StateVector.hpp"
#include "Util.hpp"
#include "Util.cpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "Util.cpp"


using std::set;
using std::string;
using std::unique_ptr;
using std::vector;

vector<unsigned int> Pennylane::getIndicesAfterExclusion(const vector<unsigned int>& indicesToExclude, const unsigned int qubits) {
set<unsigned int> indices;
for (unsigned int i = 0; i < qubits; i++) {
indices.insert(indices.end(), i);
}
for (const unsigned int& excludedIndex : indicesToExclude) {
indices.erase(excludedIndex);
}
return vector<unsigned int>(indices.begin(), indices.end());
}

vector<size_t> Pennylane::generateBitPatterns(const vector<unsigned int>& qubitIndices, const unsigned int qubits) {
vector<size_t> indices;
indices.reserve(exp2(qubitIndices.size()));
Expand Down Expand Up @@ -63,7 +50,7 @@ void Pennylane::constructAndApplyOperation(

vector<size_t> internalIndices = generateBitPatterns(opWires, qubits);

vector<unsigned int> externalWires = getIndicesAfterExclusion(opWires, qubits);
vector<unsigned int> externalWires = Pennylane::getIndicesAfterExclusion(opWires, qubits);
vector<size_t> externalIndices = generateBitPatterns(externalWires, qubits);

vector<CplxType> inputVector(internalIndices.size());
Expand Down
9 changes: 0 additions & 9 deletions pennylane_lightning/src/Apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@

namespace Pennylane {

/**
* Produces the list of qubit indices that excludes a given set of indices.
*
* @param excludedIndices indices to exclude (must be in the range [0, qubits-1])
* @param qubits number of qubits
* @return Set difference of [0, ..., qubits-1] and excludedIndices, in ascending order
*/
std::vector<unsigned int> getIndicesAfterExclusion(const std::vector<unsigned int>& indicesToExclude, const unsigned int qubits);

/**
* Produces the decimal values for all possible bit patterns determined by a set of indices, taking other indices to be fixed at 0.
* The qubit indices are taken to be big-endian, i.e. qubit 0 is the most significant bit.
Expand Down
30 changes: 30 additions & 0 deletions pennylane_lightning/src/Util.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2021 Xanadu Quantum Technologies Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <set>

#include "Util.hpp"

using std::set;
using std::vector;

vector<unsigned int> Pennylane::getIndicesAfterExclusion(const vector<unsigned int>& indicesToExclude, const unsigned int qubits) {
set<unsigned int> indices;
for (unsigned int i = 0; i < qubits; i++) {
indices.insert(indices.end(), i);
}
for (const unsigned int& excludedIndex : indicesToExclude) {
indices.erase(excludedIndex);
}
return vector<unsigned int>(indices.begin(), indices.end());
}
9 changes: 9 additions & 0 deletions pennylane_lightning/src/Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@

namespace Pennylane {

/**
* Produces the list of qubit indices that excludes a given set of indices.
*
* @param excludedIndices indices to exclude (must be in the range [0, qubits-1])
* @param qubits number of qubits
* @return Set difference of [0, ..., qubits-1] and excludedIndices, in ascending order
*/
std::vector<unsigned int> getIndicesAfterExclusion(const std::vector<unsigned int>& indicesToExclude, const unsigned int qubits);

/**
* Calculates 2^n for some integer n > 0 using bitshifts.
*
Expand Down