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

11
LINES

< > BotCompany Repo | #1033125 // matrixToMNGrid

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

Libraryless. Click here for Pure Java version (4640L/26K).

static <A> Matrix<Matrix<A>> matrixToMNGrid(Matrix<A> m, int cols, int rows) {
  if (m == null) null;
  
  // make reasonable
  cols = clamp(cols, 1, m.getWidth());
  rows = clamp(rows, 1, m.getHeight());

  LL<Rect> rects = gridOfRects3(m.getWidth(), m.getHeight(), cols, rows);
  LL<Matrix<A>> matrices = mapLevelTwo(r -> new SubMatrix(m, r), rects);
  ret listOfListsToMatrix(matrices);
}

Author comment

Began life as a copy of #1033120

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033125
Snippet name: matrixToMNGrid
Eternal ID of this version: #1033125/3
Text MD5: 7c9370f0f63d4f82c879e4e2d7a5cbd0
Transpilation MD5: b7f4a245d8e4b6fc7306abba244cd82a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-15 22:56:55
Source code size: 401 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 106 / 159
Version history: 2 change(s)
Referenced in: [show references]