How can I multiply a matrix by a vector using JAMA?

Here is simple example of wanted operation.

Here is simple example of wanted operation: double array = {{1. ,2. ,3},{1.

,2. ,3. },{1.

,2. ,3. }}; Matrix a = new Matrix(array); Matrix be = new Matrix(new double{1.

, 1. , 1. }, 1); Matrix c = b.

Times(a); System.out. Println(Arrays. DeepToString(c.getArray())); Result: 3.0, 6.0, 9.0 In other words that is.

This seems to work perfectly - thank you for your help! – The Crazy Chimp Jul 13 at 19:23 @Jon: Note that Matrix class API (math.nist. Gov/javanumerics/jama/doc/Jama/Matrix.

Html) is your friend to get more options :) – Grzegorz Szpetkowski Jul 13 at 19:34.

How about this: double vals = {{1. ,2. ,3},{4.

,5. ,6. },{7.

,8. ,10. }}; Matrix A = new Matrix(vals); From math.nist.gov/javanumerics/jama/doc/Jama....

Matrix a = new Matrix( 1,2,3,1,2,3,1,2,3 ); Matrix be = new Matrix( 1,2,3 ); // this is a vector Matrix c = a. ArrayTimes(b. Transpose); // transpose so that the inner dimensions agree This is what I think would work from reading the doc.

1 I just tried out your idea, however it seems to want the matrix dimensions to agree (ie. Same number of rows and cols). However since the vector only has one row it throws an exception.

– The Crazy Chimp Jul 13 at 19:19 Ah my mistake! Multiplying matrices is a little tricky. It's not that both dimensions have to agree (that would be boring) it's just that the inner dimensions have to agree.

You can still multiply a and be above, but you need to transpose b. I've edited the answer. – Ziggy Jul 13 at 20:00.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions