hi
i am muzamal.i have a assignment question .somebody can help me.
please send me code of this programme.i tried hard but not succeeded.please help me early.emergently send me please .because time is short for me .
thanks

I'd create a class to represent a matrix. At a minimum I'd use 3 data, two ints-one each for number of rows and number of columns to use and a pointer to pointer to type. I'd get the number of rows and columns for a given matrix and then use dynamic memory to declare a 2dimensional array using the pointer to pointer to type. Default and nondefault constructors in addition to explicit destructor, explicit assignment operator and explicit copy operator will be needed. Then I would declare either a class method or a friend function to implement the multiplication process. Multiplication of two matrixes A and B will be represented as A * B. The product of the multiplication will be a new matrix having the same number of rows as A and the same number of columns as B. The product matrix will be calculated in local variable declared with dynamic memory returned from the function similar to:

Matrix & operator *(const Matrix &);

so syntax of a call can be:

C = A * B.

By mathematical definition the product can only be generated if the number of columns of A equals the number of rows of B, so that will need to be tested before proceeding.

The basic mechanism for multiplication will follow the traditional mathematical model where each element of the product matrix, Cij, will be the sum of the products of the elements in the operands multiplied together such that:

C[j] += A[w] * B[w][j];

where w can vary from zero to the number of columns in A. Then to generate each element of C you can use a three level nested loop where:

a) the outer loop keeps track of an int variable, call it i, that represents the row of C, which can vary from zero to less than the number of rows in C,

b) the middle loop keeps track of an int variable, call it j, that represents the column of C, which can vary from zero to less than the number of columns in C, and

c) the innermost loop keeps track of an int variable, call it w to be consistent with the above discussion, which varies from 0 to less than the number of columns in A.

Edited 6 Years Ago by Lerner: n/a

This article has been dead for over six months. Start a new discussion instead.