q.js icon indicating copy to clipboard operation
q.js copied to clipboard

Ltnln npm package

Open Altanali opened this issue 4 years ago • 1 comments

Create the quantum-js-util package which creates workspaces and rewrites Q.js files as CommonJS modules. No visualization included in this PR.

Altanali avatar Aug 01 '21 00:08 Altanali

While the PR shows a large amount of file deletions/additions and lines of code changes, this is mostly due to me copy pasting all the files in the Q/ folder into separate packages and them registering as new content entirely. Key differences will be listed below:

  • Functions in Q.js (all functions besides Q()) were split out into the following files: - Misc.js: createConstant/createConstants; shuffleNames$, getRandomName$, and their associated constants - Math-Functions.js: isUsefulNumber/Integer and related math functions and their associated constants - Logging.js: logging related functions such as warn(), help(), toTitleCase(), or error().

  • All other files in Q/ were changed to meet the requirements of node modules.

  • In Q.Gate: All instances of applyToQubit were removed; this is to maintain a one way dependency from Q-Gate.js to Q-Qubit.js; Q-Qubit.js will handle the application of a gate operation to a qubit object from now on. gate.updateMatrix$(...args); return new Qubit(gate.matrix.multiply(qubit));

  • In Q.Circuit: Changed the order of qubit Evaluation to reverse the probability output (see the following ticket: https://github.com/stewdio/q.js/issues/21#issuecomment-709317571) `for( let i = 0; i < qubitIndices.length; i ++ ){

      	//qubitIndices[ i ] = ( circuitBandwidth - 1 ) - qubitIndices[ i ]
      	qubitIndices[ i ] -= 1
      }`
    

Altanali avatar Aug 03 '21 00:08 Altanali