Try solver System of linear algebraic equations in Shell Bash

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

ksh93 supports multidimensional arrays. Here is a simple example.

#!/bin/ksh93

for i in 1 2 3
do
   for j in 4 5 6
   do
       for k in 7 8 9
       do
           array[$i][$j][$k]=$(( i + j + k ))
#          echo ${array[$i][$j][$k]}
       done
   done
done

for i in 1 2 3
do
   echo ${array[$i][4][7]}
done                   

outputs

12
13
14

I think, but have not verified, that zsh also supports multidimensional arrays.

1 Like

This is not an apt place to discuss mathematics. But here's a hint. Try converting a 2D matrix into a linear matrix. Think of some way to map each element of a 2D array to a 1D array. Cheers :cool:

Thanks for all your replying