Defa Lukman

Greenhorn

Posts: 4

posted 3 years ago

I have a 2x2 matrix and a 2 dimensional array.

Let's say, my matrix is

I need to multiply each 1 dimensional array in above array with the matrix.

For instance,

So, each 1 dimensional array in there will be multiplied with matrix [a b]

(same with matrix multiplication).

I can figure out how to do that multiplication in java. But I confuse how to 'release' each 1 dimensional array from the first array so I can do multiplication.

How to do that in java?

Let's say, my matrix is

**[a b]**and array is**[[1, 2], [3, 4], [5, 6],[23, 11]]**I need to multiply each 1 dimensional array in above array with the matrix.

For instance,

**[1, 2] multiply with [a b]**

[3, 4] multiply with [a b]

[5, 6] multiply with [a b]

[23, 11] multiply with [a b][3, 4] multiply with [a b]

[5, 6] multiply with [a b]

[23, 11] multiply with [a b]

So, each 1 dimensional array in there will be multiplied with matrix [a b]

(same with matrix multiplication).

I can figure out how to do that multiplication in java. But I confuse how to 'release' each 1 dimensional array from the first array so I can do multiplication.

How to do that in java?

Campbell Ritchie

Marshal

Posts: 56600

172

Campbell Ritchie

Marshal

Posts: 56600

172

posted 3 years ago

I'm not quite sure what you mean by 'release'. If you want to keep a copy of the original array (maybe a good idea), then you need to copy it

HIH

Winston

Speaky Share wrote:I can figure out how to do that multiplication in java. But I confuse how to 'release' each 1 dimensional array from the first array so I can do multiplication.

I'm not quite sure what you mean by 'release'. If you want to keep a copy of the original array (maybe a good idea), then you need to copy it

*first*(have a look at

`Arrays.deepCopy()`). If not, then arrays are mutable, so simply assign the result to the original element.

HIH

Winston

"Leadership is nature's way of removing morons from the productive flow" - Dogbert

Articles by Winston can be found here

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |