Matrix inverse and lu decomposition using link list

Recommended Answers

Yes?
What about it?

Jump to Post

Daniweb is not a homework service. Please provide evidence that you've attempted a solution on your own.

Jump to Post

All 7 Replies

Yes?
What about it?

I don't have any idea how to do it using link list.Please give me some idea.

Daniweb is not a homework service. Please provide evidence that you've attempted a solution on your own.

Linked lists have nothing to do with matrices, as far as I know. And even if they did, it would be beyond idiotic to use them in that context.

And as Maritimo pointed out, we are not in the business of doing people's homeworks for them. We provide help in the form of explanations and hints to people who have shown genuine efforts towards solving the problem themselves.

As for matrix inversion and LU decomposition, I would suggest you just start with the wiki page on LU and the section on how to invert a matrix with it.

Sparse matrices usually have a linked list implementation, I think an Excel sheet is implemented that way.

Sorry i am not asking for the code please give me idea how to compare rows in row operation.

Here is the code for multiplication

matrix* Matrix_Multiplication (matrix* A,matrix* B)
{
    if(B->get_rows()!=A->get_col())
    {
        cout<<"\nInvalid dimensions, cannot multiply\n";
        return NULL;
    }
    else
    {
        matrix* C = new matrix;
        matC->set_row(A->get_rows());
        matC->set_col(B->get_col());
        for (int i=0;i < C->get_rows();i++)
        {
            C->row_head.push_back(NULL);
        }
        for (int i = 0; i<A->get_rows(); i++) 
        {
            //element* itC=matC->row_head[i];
            element* itC=NULL;
            for (int j = 0; j < B->get_col(); j++)
            {
                float sum = 0;
                for (int k = 0; k< A->get_col(); k++)
                {
                    sum =sum + (find_at_index(A,i+1,k+1) * find_at_index(B,k+1,j+1) );
                }
                //C[row][col] = sum;
                if(sum!=0)
                {
                    element* number=new element;
                    number->set_value(sum);
                    number->set_col(j+1);
                    if(matC->row_head[i]==NULL)
                    {
                        matC->row_head[i]=number;
                        itC=number;
                    }
                    else
                    {
                        itC->set_next(number);
                        itC=number;
                    }
                }

            }
        }
        return C;       
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.