Quote:
Originally Posted by newbieseos
I want to try solving system of linear algebraic equations in Shell bash but i have any problems Value input is matrix and I dont know how to input matrix in Shell because that is dont support 2-dimensional array Please help me. Thank you so much
|
Suppose your matrix is 3x3. As a one-dimensional array this requires 9 cells. So you can compute the one-dimensional array cell corresponding to M[a, b] by M[a*3+b], e.g.
Code:
~ $ x=(1 2 3 4 5 6 7 8 9)
~ $ a=2
~ $ b=2
~ $ echo ${x[$a*3+$b]} # the 9th cell
9
~ $ a=0
~ $ b=1
~ $ echo ${x[$a*3+$b]} # the 2nd cell
2