matrix determinant code [submitted with no subject] 
Author Message
 matrix determinant code [submitted with no subject]

hi i got your address in the mail list can you take a look at this
coce and tell me why it won't read the data in so good       put in
these numbers in the same order                1 1 5.5 3 2 10 2 3 20.0
4 1 -30 4 4 5 4 3 - 60
this is a determinant matrix in recursion
please

[this is the first time I've ever seen "I got your address in the mail list"
 for something that I don't think is actually spam. -mod]

#include <stdio.h>
#include <stdlib.h>

.
 */
int matx[21][21];
int rowused[21];
int columnused[21];

void initialize(int size)
{
        int i,k;

        /*fill the matrix with 0s*/
        for(i=0;i<size;i++)
                for(k=0;k<size;k++)
             {
                        matx[i][k]=0;
         };    

Quote:
}

void print(int size)
{
        int i,k;

        for(i=0;i<size;i++)
        {
                for(k=0;k<size;k++)
                {

                printf("%.2f\t",matx[i][k]);
                };
                printf("\n");
        };

Quote:
}

int det(int size,int i,int j,int )
{
 int signof[2]={'-', '+'};
  int k=0, *value=0;
   if (size==1)
     return *value=matx[i][j];

      for(k=1; k<size; k++)

      {
      if(columnused)
      k=(i+j)%2==0;
      signof[0]=1;
      signof[1]=-1;
      *value=*value+signof[k] * matx[i][j];det(size-1, i,j,
matx[i][j]);
      return *value;

      }
        return 0;

Quote:
}

void main(void)
{
        /*number of non-zero entries*/
        int size;
        int value=0;
        int no0=0;
    int i, j;
        /*initialyzation of 2-dimentional array of size SIZE*SIZE
         *and fill with 0s. maximum size is 20 by 20.
         */
        size=0;
        while(size<1 || size>20)
        {
                printf("Enter array size: ");
                scanf("%d",&size);
        };
                        printf("i is out of range!\n");
        //initialize();

        /*read the elements into the matrix*/
        printf("\nEnter each non-zero element in the form:\n");
        printf("\ti, j, value\n");
        printf("\twhere i and j are integers in the range of 1 to %d\n",size);
        printf("\tvalue is a float number\n");
        printf("type control-d and enter to indicate the end of the data\n");
        //for(;readelement();no0++)

   while (scanf("%d %d %d",&i, &j, &value)>0)
           {  
                if(i>0 && i<=size)
                        if(j>0 && j<=size)
                                matx[i][j]=value;
                        else
                                printf("j is out of range!\n");
                else
                        printf("i is out of range!\n");
        /*print the matrix*/
        printf("\nMatrix by row:\n");
        print(size);
        printf("\nNumber of non-zero entries was %d\n", no0);

        /*calculate the determinant*/
        printf("\nDeterminant is %d\n", det(size,i,j,matx[i][j]));

        /*deallocate pointers and exit*/

Quote:
}       //release();
}

--



Thu, 06 Dec 2001 03:00:00 GMT  
 matrix determinant code [submitted with no subject]
<< it won't read the data in so good >>'

Oh, yes, we've all seen compilers issue the standard "won't read data so
good" error message.

1. Tell us what you program is meant to do. Be detailed and specific.
2. Tell us what your program does instead. Be detailed and specific. Include
the exact text of any error messages.
3. Tell us how (2) differs from (1). Leave nothing out.

Don't just post your entire program with a message that says, essentially,
"It doesn't work! Fix it!"

--

Paul Lutus
www.arachnoid.com

Quote:

>hi i got your address in the mail list can you take a look at this
>coce and tell me why it won't read the data in so good       put in
>these numbers in the same order                1 1 5.5 3 2 10 2 3 20.0
>4 1 -30 4 4 5 4 3 - 60
>this is a determinant matrix in recursion
>please

>[this is the first time I've ever seen "I got your address in the mail
list"
> for something that I don't think is actually spam. -mod]

>#include <stdio.h>
>#include <stdlib.h>

>.
> */
>int matx[21][21];
>int rowused[21];
>int columnused[21];

>void initialize(int size)
>{
> int i,k;

> /*fill the matrix with 0s*/
> for(i=0;i<size;i++)
> for(k=0;k<size;k++)
>      {
> matx[i][k]=0;
>         };

>}
>void print(int size)
>{
> int i,k;

> for(i=0;i<size;i++)
> {
> for(k=0;k<size;k++)
> {

> printf("%.2f\t",matx[i][k]);
> };
> printf("\n");
> };
>}

>int det(int size,int i,int j,int )
>{
> int signof[2]={'-', '+'};
>  int k=0, *value=0;
>   if (size==1)
>     return *value=matx[i][j];

>      for(k=1; k<size; k++)

>      {
>      if(columnused)
>      k=(i+j)%2==0;
>      signof[0]=1;
>      signof[1]=-1;
>      *value=*value+signof[k] * matx[i][j];det(size-1, i,j,
>matx[i][j]);
>      return *value;

>      }
> return 0;
>}

>void main(void)
>{
> /*number of non-zero entries*/
> int size;
> int value=0;
> int no0=0;
>    int i, j;
> /*initialyzation of 2-dimentional array of size SIZE*SIZE
> *and fill with 0s. maximum size is 20 by 20.
> */
> size=0;
> while(size<1 || size>20)
> {
> printf("Enter array size: ");
> scanf("%d",&size);
> };
> printf("i is out of range!\n");
> //initialize();

> /*read the elements into the matrix*/
> printf("\nEnter each non-zero element in the form:\n");
> printf("\ti, j, value\n");
> printf("\twhere i and j are integers in the range of 1 to %d\n",size);
> printf("\tvalue is a float number\n");
> printf("type control-d and enter to indicate the end of the data\n");
> //for(;readelement();no0++)

>   while (scanf("%d %d %d",&i, &j, &value)>0)

> if(i>0 && i<=size)
> if(j>0 && j<=size)
> matx[i][j]=value;
> else
> printf("j is out of range!\n");
> else
> printf("i is out of range!\n");
> /*print the matrix*/
> printf("\nMatrix by row:\n");
> print(size);
> printf("\nNumber of non-zero entries was %d\n", no0);

> /*calculate the determinant*/
> printf("\nDeterminant is %d\n", det(size,i,j,matx[i][j]));

> /*deallocate pointers and exit*/
>} //release();
>}
>--


--



Fri, 07 Dec 2001 03:00:00 GMT  
 matrix determinant code [submitted with no subject]
<< it won't read the data in so good >>'

Oh, yes, we've all seen compilers issue the standard "won't read data so
good" error message.

1. Tell us what you program is meant to do. Be detailed and specific.
2. Tell us what your program does instead. Be detailed and specific. Include
the exact text of any error messages.
3. Tell us how (2) differs from (1). Leave nothing out.

Don't just post your entire program with a message that says, essentially,
"It doesn't work! Fix it!"

--

Paul Lutus
www.arachnoid.com

Quote:

>hi i got your address in the mail list can you take a look at this
>coce and tell me why it won't read the data in so good       put in
>these numbers in the same order                1 1 5.5 3 2 10 2 3 20.0
>4 1 -30 4 4 5 4 3 - 60
>this is a determinant matrix in recursion
>please

>[this is the first time I've ever seen "I got your address in the mail
list"
> for something that I don't think is actually spam. -mod]

>#include <stdio.h>
>#include <stdlib.h>

>.
> */
>int matx[21][21];
>int rowused[21];
>int columnused[21];

>void initialize(int size)
>{
> int i,k;

> /*fill the matrix with 0s*/
> for(i=0;i<size;i++)
> for(k=0;k<size;k++)
>      {
> matx[i][k]=0;
>         };

>}
>void print(int size)
>{
> int i,k;

> for(i=0;i<size;i++)
> {
> for(k=0;k<size;k++)
> {

> printf("%.2f\t",matx[i][k]);
> };
> printf("\n");
> };
>}

>int det(int size,int i,int j,int )
>{
> int signof[2]={'-', '+'};
>  int k=0, *value=0;
>   if (size==1)
>     return *value=matx[i][j];

>      for(k=1; k<size; k++)

>      {
>      if(columnused)
>      k=(i+j)%2==0;
>      signof[0]=1;
>      signof[1]=-1;
>      *value=*value+signof[k] * matx[i][j];det(size-1, i,j,
>matx[i][j]);
>      return *value;

>      }
> return 0;
>}

>void main(void)
>{
> /*number of non-zero entries*/
> int size;
> int value=0;
> int no0=0;
>    int i, j;
> /*initialyzation of 2-dimentional array of size SIZE*SIZE
> *and fill with 0s. maximum size is 20 by 20.
> */
> size=0;
> while(size<1 || size>20)
> {
> printf("Enter array size: ");
> scanf("%d",&size);
> };
> printf("i is out of range!\n");
> //initialize();

> /*read the elements into the matrix*/
> printf("\nEnter each non-zero element in the form:\n");
> printf("\ti, j, value\n");
> printf("\twhere i and j are integers in the range of 1 to %d\n",size);
> printf("\tvalue is a float number\n");
> printf("type control-d and enter to indicate the end of the data\n");
> //for(;readelement();no0++)

>   while (scanf("%d %d %d",&i, &j, &value)>0)

> if(i>0 && i<=size)
> if(j>0 && j<=size)
> matx[i][j]=value;
> else
> printf("j is out of range!\n");
> else
> printf("i is out of range!\n");
> /*print the matrix*/
> printf("\nMatrix by row:\n");
> print(size);
> printf("\nNumber of non-zero entries was %d\n", no0);

> /*calculate the determinant*/
> printf("\nDeterminant is %d\n", det(size,i,j,matx[i][j]));

> /*deallocate pointers and exit*/
>} //release();
>}
>--


--



Fri, 07 Dec 2001 03:00:00 GMT  
 matrix determinant code [submitted with no subject]
howdy?
replace scanf("%d %d %d",&i, &j, &value) by
scanf("%d%d%d",&i, &j, &value)  // no spaces between two consecutive %d's

and check whether it works!

-Graul.

Quote:

> hi i got your address in the mail list can you take a look at this
> coce and tell me why it won't read the data in so good       put in
> these numbers in the same order                1 1 5.5 3 2 10 2 3 20.0
> 4 1 -30 4 4 5 4 3 - 60
> this is a determinant matrix in recursion
> please

> [this is the first time I've ever seen "I got your address in the mail list"
>  for something that I don't think is actually spam. -mod]

> #include <stdio.h>
> #include <stdlib.h>

> .
>  */
> int matx[21][21];
> int rowused[21];
> int columnused[21];

> void initialize(int size)
> {
>         int i,k;

>         /*fill the matrix with 0s*/
>         for(i=0;i<size;i++)
>                 for(k=0;k<size;k++)
>              {
>                         matx[i][k]=0;
>          };

> }
> void print(int size)
> {
>         int i,k;

>         for(i=0;i<size;i++)
>         {
>                 for(k=0;k<size;k++)
>                 {

>                 printf("%.2f\t",matx[i][k]);
>                 };
>                 printf("\n");
>         };
> }

> int det(int size,int i,int j,int )
> {
>  int signof[2]={'-', '+'};
>   int k=0, *value=0;
>    if (size==1)
>      return *value=matx[i][j];

>       for(k=1; k<size; k++)

>       {
>       if(columnused)
>       k=(i+j)%2==0;
>       signof[0]=1;
>       signof[1]=-1;
>       *value=*value+signof[k] * matx[i][j];det(size-1, i,j,
> matx[i][j]);
>       return *value;

>       }
>         return 0;
> }

> void main(void)
> {
>         /*number of non-zero entries*/
>         int size;
>         int value=0;
>         int no0=0;
>     int i, j;
>         /*initialyzation of 2-dimentional array of size SIZE*SIZE
>          *and fill with 0s. maximum size is 20 by 20.
>          */
>         size=0;
>         while(size<1 || size>20)
>         {
>                 printf("Enter array size: ");
>                 scanf("%d",&size);
>         };
>                         printf("i is out of range!\n");
>         //initialize();

>         /*read the elements into the matrix*/
>         printf("\nEnter each non-zero element in the form:\n");
>         printf("\ti, j, value\n");
>         printf("\twhere i and j are integers in the range of 1 to %d\n",size);
>         printf("\tvalue is a float number\n");
>         printf("type control-d and enter to indicate the end of the data\n");
>         //for(;readelement();no0++)

>    while (scanf("%d %d %d",&i, &j, &value)>0)
>            {
>                 if(i>0 && i<=size)
>                         if(j>0 && j<=size)
>                                 matx[i][j]=value;
>                         else
>                                 printf("j is out of range!\n");
>                 else
>                         printf("i is out of range!\n");
>         /*print the matrix*/
>         printf("\nMatrix by row:\n");
>         print(size);
>         printf("\nNumber of non-zero entries was %d\n", no0);

>         /*calculate the determinant*/
>         printf("\nDeterminant is %d\n", det(size,i,j,matx[i][j]));

>         /*deallocate pointers and exit*/
> }       //release();
> }
> --


--



Sat, 15 Dec 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. MATRIX DETERMINANT AND INVERSE

2. C library on computation of matrix determinants

3. Do my homework, I'm lazy [submitted without subject -mod]

4. C code for Determinants...

5. Subject: Top 10 subjects in comp.lang.c {From: mikey@ontek.com (Mike Lee)}

6. Subject: Top 10 subjects in comp.lang.c {From Mike Lee, via me}

7. DMA coding (no subject)

8. Subject: VC++5.0 generates buggy FP code with /Ot

9. How to compute covariance & determinant of matrices ?

10. Library or Source Code for Eigenvalue of Float matrix

11. matrix-matrix multiplication in ANSI C

12. Needed: Inverse Matrix Code

 

 
Powered by phpBB® Forum Software