Determinant matrix calculating in C through pipe function. revision code

This is a discussion on Determinant matrix calculating in C through pipe function. revision code within the C Programming forums, part of the General Programming Boards category; Hi guys. Need to d evelop a program is performed using IPC mechanisms one of the following problems: The way ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Location
    Sankt Petersburg, Sankt-Peterburg, Russia, Russia
    Posts
    2

    Determinant matrix calculating in C through pipe function. revision code

    Hi guys. Need to develop a program is performed using IPC mechanisms one of the following problems: The way - "Channels." Implement the computation of the determinant of a square matrix by expanding it on the determinants of lower order. The "master" process sends the job "driven" processes but the latter perform a calculation of determinants, and then calculates the result of the main process. In other words, need to use the pipe function. I have a working program but without IPC mechanisms. I don't know about pipe function and how it's working. Help please
    Code:
    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
     
    int determinant(int n, double mat[n][n])
    {
        int i,j,i_count,j_count, count=0;
        double array[n-1][n-1], det=0;
        if(n==1) return mat[0][0];
        if(n==2) return (mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0]);
     
        for(count=0; count<n; count++)
        {
            i_count=0;
            for(i=1; i<n; i++)
            {
                j_count=0;
                for(j=0; j<n; j++)
                {
                    if(j == count) continue;
                    array[i_count][j_count] = mat[i][j];
                    j_count++;
                }
                i_count++;
            }
            det += pow(-1, count) * mat[0][count] * determinant(n-1,array);
        }
        return det;
    }
     
    int main()
    {
        int i, j, dim;
        printf(" Enter n\n");
        scanf("%d", &dim);
        double matrix[dim][dim];
        printf("Enter matrix:\n");
        for(i = 0; i < dim; i++)
        {
            for(j = 0; j < dim; j++)
            {
                scanf("%lf \n", &matrix[i][j]);
            }
        }
        double x = determinant(dim, matrix);
        printf("Determinant = %g\n", x);
        return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by enemy View Post
    I don't know about pipe function and how it's working. Help please
    For *nix you could look at Beej's Guide to Unix IPC.

    Bye, Andreas

  3. #3
    Registered User
    Join Date
    Nov 2012
    Location
    Sankt Petersburg, Sankt-Peterburg, Russia, Russia
    Posts
    2
    Quote Originally Posted by AndiPersti View Post
    For *nix you could look at Beej's Guide to Unix IPC.

    Bye, Andreas
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Matrix Determinant
    By StateofMind in forum C Programming
    Replies: 4
    Last Post: 03-29-2011, 06:29 PM
  2. Replies: 2
    Last Post: 11-22-2010, 05:32 PM
  3. matrix determinant
    By roaan in forum C Programming
    Replies: 1
    Last Post: 06-30-2009, 12:44 PM
  4. Matrix determinant which libraries?
    By boyfarrell in forum C Programming
    Replies: 1
    Last Post: 09-25-2007, 07:04 AM
  5. Recursive algorithm to find the determinant of a matrix
    By mahesh.mach in forum C Programming
    Replies: 3
    Last Post: 06-07-2007, 09:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21