tequilahub / tequila

A High-Level Abstraction Framework for Quantum Algorithms
MIT License
369 stars 103 forks source link

added qtensor class #194

Closed gaurav-iiser closed 2 years ago

gaurav-iiser commented 2 years ago

In this PR, I have added a new file qtensor.py which contains the class QTensor. This class was needed to ease the implementation of mathematical objects like vectors, matrices, and tensors. This class has been derived from numpy.ndarray and thus, all the linear algebraic operations that can be performed on an ndarray can be performed on a QTensor object. Besides, applying any function on a QTensor object, compiling, simulating, or taking the grad of a QTensor object can be done in the same way as is done for a tequila objective. Apart from that, I have also added test_qtensor.py file which contains tests for this class.
For more details on the usage and implementation of QTensor, I have also added two notebooks in tequila-tutorials:

  1. Tutorial notebook: QTensorTutorial.ipynb - https://github.com/tequilahub/tequila-tutorials/blob/main/QTensorTutorial.ipynb
  2. Implementation notebook: QTensorImplementation.ipynb - https://github.com/tequilahub/tequila-tutorials/blob/main/QTensorImplementation.ipynb