Visit Jeremy's Blog.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Try solver System of linear algebraic equations in Shell Bash
 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

 10-03-2012, 03:49 AM #1 newbieseos LQ Newbie   Registered: Oct 2012 Posts: 2 Rep: 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
 10-03-2012, 04:37 AM #2 pan64 LQ Guru   Registered: Mar 2012 Location: Hungary Distribution: debian/ubuntu/suse ... Posts: 9,435 Rep: you would better try to use awk/perl or another language, bash does not really support it and is hard to implement.
10-03-2012, 04:52 AM   #3
porphyry5
Member

Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch
Posts: 447

Rep:
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```

 10-03-2012, 04:55 AM #4 sycamorex LQ Veteran   Registered: Nov 2005 Location: London Distribution: Slackware64-current Posts: 5,823 Blog Entries: 1 Rep: Another suggestion would be to use Python. It has lots of maths modules.
 10-03-2012, 05:34 AM #5 newbieseos LQ Newbie   Registered: Oct 2012 Posts: 2 Original Poster Rep: Thanks for all your replying
 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: Or languages like MATLAB which are designed exactly for things such as this...
10-05-2012, 10:45 PM   #7
hydraMax
Member

Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep:
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
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.

 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 Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Valentin Linux - Software 1 06-08-2011 09:14 PM ta0kira Programming 6 11-22-2008 10:08 PM LXer Syndicated Linux News 0 08-12-2006 04:21 AM ArthurHuang Programming 14 06-19-2006 02:00 AM

LinuxQuestions.org

All times are GMT -5. The time now is 04:02 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -