Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> shell script from c
noobie
post Dec 10 2008, 08:41 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 10-December 08
Member No.: 13,789



Hallo i am totally new with linux and i am trying to make a shell script for gaussian elimination.I have written the code in c because it is easier for me to understand.But i have some problems when trying to write it in a shell script.
here is the c code

CODE
#include <stdio.h>
#include<conio.h>


int main()
{
        int n;
        float a[10][11],t;
    int i, j,k,max;

    
    for(i = 0; i < n; ++i)
        for (j = 0; j < n + 1; ++j)
            scanf("%f", &a[i][j]);

            for (i = 0; i < n; ++i)
                {
                max = i;
                  for (j = i + 1; j < n; ++j)
                  if (a[j][i] > a[max][i])
                     max = j;

                 for (j = 0; j < n + 1; ++j)
                  {
            t = a[max][j];
            a[max][j] = a[i][j];
            a[i][j] = t;
          }
                }
        for (j = n; j >= i; --j)
            for (k = i + 1; k < n; ++k)
                a[k][j] -= a[k][i]/a[i][i] * a[i][j];


                                for (i = n - 1; i >= 0; --i) {
        a[i][n] = a[i][n] / a[i][i];
        a[i][i] = 1;
        for (j = i - 1; j >= 0; --j) {
            a[j][n] -= a[j][i] * a[i][n];
            a[j][i] = 0;
        }
    }
            for (i = 0; i < n; ++i) {
        for (j = 0; j < n + 1; ++j)
            printf("%.2f\t", a[i][j]);
        printf("\n");
    }
        getch();
    return 0;
}



i cannot find out how to create a table in my script for reading the matrix...
Any help appreciated...


Go to the top of the page
 
+Quote Post
michaelk
post Dec 10 2008, 05:10 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,797
Joined: 23-January 03
Member No.: 360



AFAIK bash only supports one dimensional arrays. However I did find the following information.
http://codeandfury.blogspot.com/2006/12/ba...-delimited.html

Another limitation is bash can only perform integer math.

Obviously bash is extremely limited compared to c.

And here is a good link to bash scripting.
http://tldp.org/LDP/abs/html/

And why do you have to use bash? Homework assignment?
Go to the top of the page
 
+Quote Post
noobie
post Dec 11 2008, 05:41 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 10-December 08
Member No.: 13,789



Thanks a lot for your help...i did not know that bash supports only one dimension array...
It is a project for university and it counts 30% for the final grade for this lesson so i have to find a solution ...
I tried to use awk but i didnt figure out how to do it...
The time has come and i have to give the project until tomorrow..so i guess i have to hurry....
Go to the top of the page
 
+Quote Post
noobie
post Dec 17 2008, 03:57 PM
Post #4


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 10-December 08
Member No.: 13,789



after a lot of trying and searching,i am sure now that i cannot do it using arrays..but how am i going to do it?does anyone has an idea of creating this script?
our deadline has moved to january so i have still the time to do this..
Go to the top of the page
 
+Quote Post
michaelk
post Dec 17 2008, 07:29 PM
Post #5


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,797
Joined: 23-January 03
Member No.: 360



Most forums do not allow homework questions unless they ask specific questions.
At the moment I do not have any good ideas.
Go to the top of the page
 
+Quote Post
edwardthompson
post Jan 6 2009, 04:45 AM
Post #6


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 6-January 09
Member No.: 13,839



I think its a very poor script.

Where is the retention?

What happen with the writing in HD?. You have to be careful with your HD and the bigs databases.

And the bandwith? Why not use a temporal directory and make a synchronization to a final directory to save some of bandwith in the ftp connection? Or much more better.... why ftp?? you can save more time an bandwith if you make rsync

What happen with big databases? You spend more time, CPU and bandwith in make the dumps all hours and move it to the ftp that let the applications runs through db

I think that is a script that make the job but.... is very poor


--------------------
If there is something good in the world then we copy with pride.
UnlockiPhonesoftware
Go to the top of the page
 
+Quote Post
michaelk
post Jan 6 2009, 10:44 AM
Post #7


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,797
Joined: 23-January 03
Member No.: 360



edwardthompson
I do not understand your post and how it relates to the OP questions.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th October 2017 - 07:55 AM