As for the inverse, the function is inv(A), but I won't recommend using it, since for huge matrices it is very computationally costly and unstable. Instead, you should use an approximation to the inverse, or if you want to solve Ax = b you don't really need A-1.
In Python, the Scipy library can be used to convert the 2-D NumPy matrix into a Sparse matrix. SciPy 2-D sparse matrix package for numeric data is scipy.sparse
The scipy.sparse package provides different Classes to create the following types of Sparse matrices from the 2-dimensional matrix:
Block Sparse Row matrix
A sparse matrix in COOrdinate format.
Compressed Sparse Column matrix
Compressed Sparse Row matrix
Sparse matrix with DIAgonal storage
Dictionary Of Keys based sparse matrix.
Row-based list of lists sparse matrix
This class provides a base class for all sparse matrices.
CSR (Compressed Sparse Row) or CSC (Compressed Sparse Column) formats support efficient access and matrix operations.
Example code to Convert Numpy matrix into Compressed Sparse Column(CSC) matrix & Compressed Sparse Row (CSR) matrix using Scipy classes:
import sys # Return the size of an object in bytes
import numpy as np # To create 2 dimentional matrix
from scipy.sparse import csr_matrix, csc_matrix
# csr_matrix: used to create compressed sparse row matrix from Matrix
# csc_matrix: used to create compressed sparse column matrix from Matrix
create a 2-D Numpy matrix
A = np.array([[1, 0, 0, 0, 0, 0],\
[0, 0, 2, 0, 0, 1],\
[0, 0, 0, 2, 0, 0]])
print("Dense matrix representation: \n", A)
print("Memory utilised (bytes): ", sys.getsizeof(A))
print("Type of the object", type(A))