Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1035366 // ejmlMatrixToVector

JavaX fragment (include) [tags: use-pretranspiled]

Uses 652K of libraries. Click here for Pure Java version (7933L/44K).

!include once #1035331 // EJML Include (Matrix library)

static double[] ejmlMatrixToVector(DMatrixRMaj matrix) {
  int w = matrix.getNumCols(), h = matrix.getNumRows();
  if (w == 1) {
    double[] vector = new double[h];
    for i to h:
      vector[i] = matrix.get(i, 0);
    ret vector;
  } else if (h == 1) {
    double[] vector = new double[w];
    for i to w:
      vector[i] = matrix.get(0, i);
    ret vector;
  } else
    fail("Matrix is not a vector: " + w + "*" + h);
}

Author comment

Began life as a copy of #1035364

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035366
Snippet name: ejmlMatrixToVector
Eternal ID of this version: #1035366/1
Text MD5: 21fd961da1d9f0974d2363a20ecc403c
Transpilation MD5: 9494b475cd94ff7d1c8eb373765370ce
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-02 13:19:45
Source code size: 497 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 124 / 175
Referenced in: [show references]