LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-03-2012, 03:49 AM   #1
newbieseos
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
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
 
Old 10-03-2012, 04:37 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,929

Rep: Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306
you would better try to use awk/perl or another language, bash does not really support it and is hard to implement.
 
Old 10-03-2012, 04:52 AM   #3
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch
Posts: 421

Rep: Reputation: 18
Quote:
Originally Posted by newbieseos View Post
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
 
Old 10-03-2012, 04:55 AM   #4
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,569
Blog Entries: 1

Rep: Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026
Another suggestion would be to use Python. It has lots of maths modules.
 
Old 10-03-2012, 05:34 AM   #5
newbieseos
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for all your replying
 
Old 10-03-2012, 05:57 AM   #6
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Or languages like MATLAB which are designed exactly for things such as this...
 
Old 10-05-2012, 10:45 PM   #7
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
Quote:
Originally Posted by newbieseos View Post
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
Abort now before you lose your sanity. Bash sucks at doing anything beside executing independent programs sequentially or tying together I/O streams. In particular, Bash does weird things with arrays that you will find harder to figure out than your original problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strace crashes shell/system when being used on current bash Valentin Linux - Software 1 06-08-2011 09:14 PM
plotting difference equations which are dependent on linear equations ta0kira Programming 6 11-22-2008 10:08 PM
LXer: Linear Optimization with the GNU Linear Programming Kit LXer Syndicated Linux News 0 08-12-2006 04:21 AM
How to solvle this 4th system of equations. ArthurHuang Programming 14 06-19-2006 02:00 AM


All times are GMT -5. The time now is 03:09 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration