transpose double[][] matrix with a java function?

后端 未结 6 1572
夕颜
夕颜 2020-12-03 05:55

Do anybody have a function with which I can transpose a Matrix in Java which has the following form:

double[][]

I have function like this:<

6条回答
  •  执念已碎
    2020-12-03 06:42

    If you would like to use an external library, Apache Commons Math provides the utility to transpose a matrix. Please refer to it official site.

    First, you have to create a double array double[][] arr, as you have already done. Then, the transposed 2d matrix can be achieved like this

    MatrixUtils.createRealMatrix(arr).transpose().getData()
    

提交回复
热议问题