Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/qniapp/qni
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Jun 4, 2024
2 parents 6f5031d + adef200 commit 433143d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/simulator/test/matrix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ describe('Matrix', () => {
})

test('multMatrix', () => {
const mErr = squareMatrix(1, 2, 3, 4).mult(Matrix.col(0))
expect(mErr.isErr()).toBeTruthy()
expect(mErr._unsafeUnwrapErr().message).toBe('Incompatible sizes.')

expect(
squareMatrix(2, 3, 5, 7).mult(squareMatrix(11, 13, 17, 19))._unsafeUnwrap().eq(squareMatrix(73, 83, 174, 198)),
).toBeTruthy()
Expand Down Expand Up @@ -384,6 +388,13 @@ describe('Matrix', () => {
expect(equate(f(1, i).mult(0.5)._unsafeUnwrap().qubitDensityMatrixToBlochVector(), [0, 1, 0])).toBeTruthy()
expect(equate(f(1, mi).mult(0.5)._unsafeUnwrap().qubitDensityMatrixToBlochVector(), [0, -1, 0])).toBeTruthy()
})

test('clone', () => {
const m = squareMatrix(new Complex(2, 3), new Complex(5, 7), new Complex(11, 13), new Complex(17, 19))
const c = m.clone()

expect(m.eq(c))
})
})

function squareMatrix(...elements: Array<number | Complex>): Matrix {
Expand Down

0 comments on commit 433143d

Please sign in to comment.