Recipe: How to Calculate Trace of a Matrix?
DATA MUNGING PYTHON MATRIX DATA CLEANING PYTHON

How to Calculate Trace of a Matrix?

This recipe helps you Calculate Trace of a Matrix
In [1]:
## How to Calculate Trace of a Matrix
def Kickstarter_Example_7():
    print()
    print(format('How to Calculate Trace of a Matrix', '*^72'))
    # Load library
    import numpy as np
    # Create matrix
    matrix = np.array([[1, 2, 3],
                       [4, 5, 6],
                       [7, 8, 9],
                       [10, 11, 12]])
    # Calculate the tracre of the matrix
    print()
    print('Calculate the tracre of the matrix: ',
           matrix.diagonal().sum())
Kickstarter_Example_7()
*******************How to Calculate Trace of a Matrix*******************

Calculate the tracre of the matrix:  15


Stuck at work?
Can't find the recipe you are looking for. Let us know and we will find an expert to create the recipe for you. Click here
Companies using this Recipe
1 developer from KPMG
1 developer from Vodafone
1 developer from Altimetrik
1 developer from LTI
1 developer from YASH Technologies
1 developer from ANAC
1 developer from MudraCircle
1 developer from HvH
1 developer from New Delhi DataPoint