0

I want to try solving system of linear algebraic equations using the bash shell but have had problems. The input value is a matrix, however I dont know how to input matrix in bash because that is doesn't support 2-dimensional arrays.

Thank you so much.

imp25
  • 2,327
  • 16
  • 23
denmodo
  • 41
  • 3

1 Answers1

0

I'm very new to bash and I'm not expert enough to provide you with some code, but I'll answer anyway since no one did in the past days.

First off, why would you use bash? It's probably much easier to research how to solve it with maxima or some tool devised esplicitly to do that.

If you want to use bash, though, you can just read a matrix from a file and treat it like an array of array, or an array of lists. Bash can handle it.

Anyway, you can do it with unidimensional array as well. Just read the whole file, put it in an array, and then the element on the i-th row and j-th column will be just

${array[i*l+j]}

where l is the size of your matrix.

Hope I helped!

Ferdinando Randisi
  • 4,068
  • 6
  • 32
  • 43