posted 2 years ago

Hello to everyone,

I know that can be a stupid question, but i kindly ask you if you have a code for matrix multiplication with thread. My problem is that i need to generate n thread one for each cells of the matrix result.

This is the function that i had produce, it works but it doesn't do what i need

Anyone can help me please? I know that probably i ll have less fast of the program, but it is an exercise.

Thanks a lot for your cooperation and looking forward into your answer

best Regards

I know that can be a stupid question, but i kindly ask you if you have a code for matrix multiplication with thread. My problem is that i need to generate n thread one for each cells of the matrix result.

This is the function that i had produce, it works but it doesn't do what i need

Anyone can help me please? I know that probably i ll have less fast of the program, but it is an exercise.

Thanks a lot for your cooperation and looking forward into your answer

best Regards

Lionel Rossi

Greenhorn

Posts: 9

posted 2 years ago

Hi Lionel, welcome to CodeRanch!

We don't hand out solutions here, but try to help you to get it on your own. I see you already made a topic about this that contains code, so I merged those two topics.

We don't hand out solutions here, but try to help you to get it on your own. I see you already made a topic about this that contains code, so I merged those two topics.

*The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.*

Stephan van Hulst

Saloon Keeper

Posts: 7993

143

posted 2 years ago

Can you explain to us what the problem is that you're experiencing? We can't help you if we don't know what's wrong.

Lionel Rossi

Greenhorn

Posts: 9

posted 2 years ago

I've got two different problems:

1) I need to create a software for calculate the product of two matrix in which i need to use n thread one for each cells of the matrix result (For this problem i posted a code that calculate the product of matrix but not using n thread for each cells of the matrix result)

2) I need to create a software for calculate the determinant of the matrix using thread (I don't have any idea to how to create a software that do this)

Stephan van Hulst wrote:Can you explain to us what the problem is that you're experiencing? We can't help you if we don't know what's wrong.

I've got two different problems:

1) I need to create a software for calculate the product of two matrix in which i need to use n thread one for each cells of the matrix result (For this problem i posted a code that calculate the product of matrix but not using n thread for each cells of the matrix result)

2) I need to create a software for calculate the determinant of the matrix using thread (I don't have any idea to how to create a software that do this)

Lionel Rossi

Greenhorn

Posts: 9

posted 2 years ago

Hi Campbell,

1) For the first point (Product of Matrix) it is the exercise that impose me to use n thread one for each cells i know that is not a good solution but i must do it

2) For calculate the matrix determinant i think that first i need to check the dimension of the matrix (If is 2x2 is simply). For matrix that have a dimension bigger than 2x2 i need to calculate minor complementary so for each step i need to eliminate one row and one column

Campbell Ritchie wrote:Welcome to the Ranch (again)

Why do you say you need several threads?

What is the algorithm for calculating a matrix determinant?

Hi Campbell,

1) For the first point (Product of Matrix) it is the exercise that impose me to use n thread one for each cells i know that is not a good solution but i must do it

2) For calculate the matrix determinant i think that first i need to check the dimension of the matrix (If is 2x2 is simply). For matrix that have a dimension bigger than 2x2 i need to calculate minor complementary so for each step i need to eliminate one row and one column

Stephan van Hulst

Saloon Keeper

Posts: 7993

143

posted 2 years ago

Okay, so before you start working with threads, why don't you start by creating a

Try getting this code to work (hint, use unit tests!) and then show us your code, or show us where you get stranded with an explanation of the problem. Don't worry about threads yet!

`Matrix`class that models a single matrix, which contains a`multiply(Matrix other)`method that returns a new`Matrix`. you should also add a method`determinant()`that returns an`int`.Try getting this code to work (hint, use unit tests!) and then show us your code, or show us where you get stranded with an explanation of the problem. Don't worry about threads yet!

Lionel Rossi

Greenhorn

Posts: 9

posted 2 years ago

I just finish the code of Matrix product

I don't have no idea to how implement the method of determinant

Stephan van Hulst wrote:Okay, so before you start working with threads, why don't you start by creating aMatrixclass that models a single matrix, which contains amultiply(Matrix other)method that returns a newMatrix. You should also add a methoddeterminant()that returns anint.

Try getting this code to work (hint, use unit tests!) and then show us your code, or show us where you get stranded with an explanation of the problem. Don't worry about threads yet!

I just finish the code of Matrix product

I don't have no idea to how implement the method of determinant

Stephan van Hulst

Saloon Keeper

Posts: 7993

143

posted 2 years ago

Like I said, you will benefit from implementing a Matrix class with some simple operations on it:

Lionel Rossi

Greenhorn

Posts: 9

posted 2 years ago

Thanks for your help! I understood what did you told to me

Maybe at the moment i'm looking only for write the correct methods that works without think about the correct way in which i need to write software but i've got exam in these days on Java and i must clear all doubt if i want pass. Then next week i ll start to write good code for the final test (I ll create a programm with all UML diagram).

Best Regards

Maybe at the moment i'm looking only for write the correct methods that works without think about the correct way in which i need to write software but i've got exam in these days on Java and i must clear all doubt if i want pass. Then next week i ll start to write good code for the final test (I ll create a programm with all UML diagram).

Best Regards

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |