Solved

matrix handling function

Posted on 1997-12-05
6
275 Views
Last Modified: 2010-04-02
how to determine the transpose and inverse of a matrix A and Matrix B using C language
0
Comment
Question by:latino
6 Comments
 

Author Comment

by:latino
ID: 1256518
ASAP
0
 
LVL 10

Expert Comment

by:rbr
ID: 1256519
It depends on the dimension of the matrix, because there exists
different algorithm. If you are interessted in such codes use
the book Numerical Recipes for C.
0
 

Author Comment

by:latino
ID: 1256520
I need some help about this online so if any info let me know
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 10

Expert Comment

by:rbr
ID: 1256521
Pls tell my what is the dimension of the matrix, is it a sparse matrix, ... This information is needed to determine which algorithm you should use.
0
 
LVL 5

Expert Comment

by:yonat
ID: 1256522
0
 

Accepted Solution

by:
hbadr earned 100 total points
ID: 1256523
latino

to do this you Dynamically allocate and then perform whatever operation you need using the operator [].
the example below transpotse a matrix of n,m dimention.

#include <conio.h>
#include <Stdio.h>
#include <alloc.h>

void getinput ( int **ArrayPtr , int raws , int cols );
int **transpose( int **ArrayPtr , int raws , int cols );
void display( int **ArrayPtr ,int raws ,int cols );

void main()
{
 int **ArrayIn;
 int raws,cols;
 int i,j;

 clrscr();

 printf("Enter Number Of Raws : ");       //Get Array Dimentions
 scanf("%d", &raws );
 printf("Enter Number Of Columns : ");
 scanf("%d", &cols );

 ArrayIn = calloc ( raws , sizeof(int *) );     //Dynamically Allocate The Array
 for ( j=0 ; j<raws ;j++ ){
     ArrayIn[j] = calloc( cols, sizeof(int) );
 }

 getinput( ArrayIn ,raws ,cols );      // Get the Array

 ArrayIn=transpose(ArrayIn ,raws,cols);            //Transpose the Array

 display(ArrayIn , raws , cols);          // Display After Transpose

 getch();

}

////////////////////////////////////
void getinput ( int **ArrayPtr , int raws , int cols ){
int i,j;

 for( j=0 ; j<raws ;j++ ){
     for( i=0 ; i<cols ; i++ ){
       printf("Enter Element #%d%d : ",j,i);
       scanf("%d",ArrayPtr[j]+i);
     }
 }
}
//////////////////////////////////////////////
int **transpose( int **ArrayPtr , int raws , int cols ){
 int **trans;
 int i,j;

 trans = calloc ( cols , sizeof(int *) ); // Allocate Transpose Array
 for ( j=0 ; j<cols ;j++ ){
     trans[j] = calloc( raws, sizeof(int) );
 }


 for( j=0 ; j<raws ;j++ ){
 printf("\n");
     for( i=0 ; i<cols ; i++ ){
      trans[i][j]=ArrayPtr[j][i];
     }

 }
 return (trans);

}
////////////////////////////
void display( int **ArrayPtr ,int raws , int cols ){
 int i,j;

 for( j=0 ; j<cols ;j++ ){
     printf("\n");
     for( i=0 ; i<raws ; i++ ){
       printf("#%d%d = %d  |",j,i,ArrayPtr[j][i]);
     }
 }
}

//////////

likewise you could do any operation you need by using a similar algorithm.

E-mail me at : hbadr@mailcity.com

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now