[Show all top banners]

raju2005
Replies to this thread:

More by raju2005
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 MATRIX
[VIEWED 5534 TIMES]
SAVE! for ease of future access.
Posted on 01-10-10 10:04 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

does n e body have any idea how to find the determinant of (A^100) ?

|A^100| = ?

thanks in advance

 
Posted on 01-10-10 10:12 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Below is the program in C++ to find the determinant of matrix

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>

typedef struct
{
       int order;
       int **ar;        //for a 2-d array

}matrix;

int create( matrix *a,int order)
{
      if(order<1)
        return 0;             //checks for invalid order

      a->order=order;

      a->ar= (int**) malloc(order*sizeof(int *)); //allocate space for each row

      if(!a->ar)
        return 0;            //checks if memory is allocated

     for(int i=0;i<order;i++)
      { a->ar[i]=(int*) malloc(order*sizeof(int));
        if(!a->ar)
         return 0;
      }
       return 1;
}

void input(matrix *a )
{
        int i,j;
        for( i = 0; i < a->order; i++ )
         for( j = 0; j < a->order; j++ )
            {
                printf("Enter element at ( %d, %d ): ", i+1, j+1 );
                scanf("%d", &a->ar[i][j] );
             }
}

void display( matrix *a )
{
            int i,j;
           
            if( a->order < 1 )
            return;
           
            for( i = 0; i < a->order; i++ )
                {
                for( j = 0; j < a->order; j++ )
                printf("%5d ", a->ar[i][j] );
               
                printf("\n");
                }
}
int calcminor(matrix *a, matrix *minor, int row,int column)

{
       int p,q;

       if(a->order<=1||row>=a->order||column>=a->order)
     return 0;

       if(!create(minor,a->order-1))
     return 0;

       p=q=0;

       for(int i=0;i<a->order;i++)
         if(i!=row)
     {
           q=0;
         for(int j=0;j<a->order;j++)
           { if(j!=column)
           minor->ar[p][q]=a->ar[i][j];
           q++;
           }
        p++;
     }
     return 1;
}

void destroy(matrix *a)

{
     if(a->order<1)
       return;

       for(int i=0;i<a->order;i++)
         free(a->ar[i]);         // free space for the column

         free(a->ar);       //free memory  for rows
         a->order=0;
}

int calcdet(matrix *a)

{
       int result=0;

       matrix minor;

       if(a->order<1)
         return 0;

       if(a->order==1)      // stopping condition
         return a->ar[0][0];     //returns 0,0 element

       for(int i=0;i<a->order;i++)

     {
          if(!calcminor(a,&minor,0,i))
             return 0;
          result+=( pow(-1,i)*a->ar[0][i]*calcdet(&minor));

          destroy(&minor);
     }

       return result;
}


int main()

{
    matrix a;
    int order;
    cout<<"\nEnter The Order of The Square Matrix :";
    cin>>order;

    if(!create(&a,order))
       {
           cout<<"\n The Matrix Could Not Be Created !!!! ";
           getch();
          return 0;
       }
       input(&a);
       cout<<"The Matrix Is :\n";
       display(&a); 


    cout<<"\n The Determinant Of The Matrix Is : "<<calcdet(&a);

    getch();
    return 0;
}


 
Posted on 01-10-10 10:34 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

You are one hell of a nerd.

 
Posted on 01-10-10 11:41 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

@salam namaste, 
Please don't hesitate to provide the source from next time....

http://www.dreamincode.net/code/snippet406.htm
 
Posted on 01-11-10 12:13 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

thanks full_maya..

 
Posted on 01-11-10 1:18 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Sorry guy's, for not providing the source.
Also don't be so offensive....i never mentioned abt writing the program myself (that also in C++...i hate this language)just trying to help raju2005.

 
Posted on 01-11-10 11:48 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

thanks salam namaste... i appreciate it.
actually |A^100| = (|A|)^100  so u can just find the determinant of A and then power it by 100.

Seems like MATLAB is way easier  for matrix and other calculation compared to other prog lang.

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 200 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration
What are your first memories of when Nepal Television Began?
निगुरो थाहा छ ??
ChatSansar.com Naya Nepal Chat
Basnet or Basnyat ??
TPS Re-registration case still pending ..
Sajha has turned into MAGATs nest
NRN card pros and cons?
Do nepalese really need TPS?
कता जादै छ नेपाली समाज ??
Will MAGA really start shooting people?
Democrats are so sure Trump will win
मन भित्र को पत्रै पत्र!
Top 10 Anti-vaxxers Who Got Owned by COVID
I regret not marrying a girl at least for green card. do you think TPS will remain for a long time?
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
TPS Work Permit/How long your took?
Breathe in. Breathe out.
3 most corrupt politicians in the world
Dementia Joe has been selected to become the next President
Nas and The Bokas: Coming to a Night Club near you
Mr. Dipak Gyawali-ji Talk is Cheap. US sends $ 200 million to Nepal every year.
Harvard Nepali Students Association Blame Israel for hamas terrorist attacks
TPS Update : Jajarkot earthquake
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters