@@ -321,6 +321,70 @@ def test_conjugate_transpose():
321
321
assert A .conjugate_transpose () == DenseMatrix (2 , 2 , [1 , 3 , 2 , - I ])
322
322
323
323
324
+ def test_trace ():
325
+ A = DenseMatrix (2 , 2 , [1 , 2 , 3 , 4 ])
326
+ assert A .trace () == 5
327
+
328
+
329
+ def test_is_zero_matrix ():
330
+ A = DenseMatrix (2 , 2 , [1 , 2 , 3 , I ])
331
+ assert not A .is_zero_matrix
332
+ B = DenseMatrix (1 , 1 , [Symbol ('x' )])
333
+ assert B .is_zero_matrix is None
334
+ C = DenseMatrix (3 , 3 , [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ])
335
+ assert C .is_zero_matrix
336
+
337
+
338
+ def test_is_real_matrix ():
339
+ A = DenseMatrix (2 , 2 , [1 , 2 , 3 , I ])
340
+ assert not A .is_real_matrix
341
+ B = DenseMatrix (1 , 1 , [Symbol ('x' )])
342
+ assert B .is_real_matrix is None
343
+ C = DenseMatrix (3 , 3 , [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ])
344
+ assert C .is_real_matrix
345
+
346
+
347
+ def test_is_diagonal ():
348
+ A = DenseMatrix (2 , 2 , [1 , 0 , 0 , I ])
349
+ assert A .is_diagonal
350
+ B = DenseMatrix (1 , 1 , [Symbol ('x' )])
351
+ assert B .is_diagonal
352
+ C = DenseMatrix (3 , 3 , [0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 ])
353
+ assert not C .is_diagonal
354
+
355
+
356
+ def test_is_symmetric ():
357
+ A = DenseMatrix (2 , 2 , [1 , 3 , 2 , I ])
358
+ assert not A .is_symmetric
359
+ B = DenseMatrix (1 , 1 , [Symbol ('x' )])
360
+ assert B .is_symmetric
361
+ C = DenseMatrix (3 , 3 , [0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 ])
362
+ assert not C .is_symmetric
363
+
364
+
365
+ def test_is_hermitian ():
366
+ A = DenseMatrix (2 , 2 , [1 , 3 , 2 , I ])
367
+ assert not A .is_hermitian
368
+ B = DenseMatrix (1 , 1 , [Symbol ('x' )])
369
+ assert B .is_hermitian is None
370
+ C = DenseMatrix (3 , 3 , [0 , I , 0 , 0 , 0 , 0 , 0 , 2 , 0 ])
371
+ assert not C .is_hermitian
372
+
373
+
374
+ def test_is_weakly_diagonally_dominant ():
375
+ A = DenseMatrix (2 , 2 , [2 , 1 , 1 , 2 ])
376
+ assert A .is_weakly_diagonally_dominant
377
+ C = DenseMatrix (3 , 3 , [Symbol ('x' ), 0 , 0 , 0 , 3 , 0 , 0 , 0 , 4 ])
378
+ assert C .is_weakly_diagonally_dominant is None
379
+
380
+
381
+ def test_is_strongly_diagonally_dominant ():
382
+ A = DenseMatrix (2 , 2 , [2 , 1 , 1 , 2 ])
383
+ assert A .is_strongly_diagonally_dominant
384
+ C = DenseMatrix (3 , 3 , [Symbol ('x' ), 2 , 0 , 0 , 4 , 0 , 0 , 0 , 4 ])
385
+ assert C .is_strongly_diagonally_dominant is None
386
+
387
+
324
388
def test_LU ():
325
389
A = DenseMatrix (3 , 3 , [1 , 3 , 5 , 2 , 5 , 6 , 8 , 3 , 1 ])
326
390
L , U = A .LU ()
0 commit comments