I would like to make matrix which contains fraction numbers, say 1/4, as elements.
I made following matrix:
import numpy as np
alpha = 10
B = np.array([ [0, -0.25, -1/20, alpha/40], [1/(alpha+3), 0, -1/(alpha+3), -(alpha-1)/(alpha+3) ], [ 1/(2*alpha+2), 1/(alpha+1), 0, 1/(10*alpha+10) ], [ -1/2, -9/20, 0, 0 ] ])
print(B)
However, the output is such:
[[ 0. -0.25 -1. 0. ]
[ 0. 0. -1. -1. ]
[ 0. 0. 0. 0. ]
[-1. -1. 0. 0. ]]
My question is: How to keep fractions inside matrix for purpose of calculations and functions ? If it wasn't for variable alpha I would convert the values to decimals.
EDIT
The marked dublicate thread does not seem to give solution to this problem:
Here the elements in matrix are assigned from the beginning manually. Whereas in the linked thread elements are assigned to matrix in form of equation. Which makes things messy I think.