Solved

matrix handling function

Posted on 1997-12-05
6
279 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 how to use strings and some functions related to them in the C programming language.

821 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