- Author:
- nima <nafs080@aucklanduni.ac.nz>
- Date:
- 2021-07-01 18:19:07+12:00
- Desc:
- matrix.jpg
- Permanent Source URI:
- https://models.cellml.org/workspace/6b9/rawfile/b49e1dec750a26af22616265fa6fea8a88838afe/inverse01.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#
# A = np.array([[6, 1, 1],
# [4, -2, 5],
# [2, 8, 7]])
#
# A_inverse = np.linalg.inv(A)
# # print(A_inverse)
B = np.array([[1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
[0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0],
[0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0],
[0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0],
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0]])
# [0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0]
# [0,0,0,0,0,1,1,0,0,0,1,-1,0,0,0,0]
BT = B.T
C = np.dot (BT,B)
print(C.shape)
print(C)
#forward and reverse kinetic rates from the original model
Y = np.log(np.array([[500],
[10],
[562],
[61],
[500],
[10],
[1980],
[10],
[135],
[1247],
[1980],
[10]]))
D = np.dot(BT,Y)
print(D.shape)
sol = np.dot(np.linalg.pinv(C),D)
print(sol.shape)
# print(sol)
# print(np.linalg.matrix_rank(C))
#
# # print(kinetic_rates)
# # #
# solution = kinetic_rates @ B_inv
# #
print("solution: ")
print(np.exp(sol))