MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / changeSize

Method changeSize

JSAT/src/jsat/linear/SparseMatrix.java:426–448  ·  view source on GitHub ↗
(int newRows, int newCols)

Source from the content-addressed store, hash-verified

424 }
425
426 @Override
427 public void changeSize(int newRows, int newCols)
428 {
429 if(newRows <= 0)
430 throw new ArithmeticException("Matrix must have a positive number of rows");
431 if(newCols <= 0)
432 throw new ArithmeticException("Matrix must have a positive number of columns");
433 final int oldRows = rows.length;
434 if(newCols != cols())
435 {
436 for(int i = 0; i < rows.length; i++)
437 {
438 final SparseVector row_i = rows[i];
439 while(row_i.getLastNonZeroIndex() >= newCols)
440 row_i.set(row_i.getLastNonZeroIndex(), 0);
441 row_i.setLength(newCols);
442 }
443 }
444 //update new rows
445 rows = Arrays.copyOf(rows, newRows);
446 for(int i = oldRows; i < newRows; i++)
447 rows[i] = new SparseVector(newCols);
448 }
449
450 @Override
451 public void multiplyTranspose(Matrix B, Matrix C)

Callers

nothing calls this directly

Calls 5

colsMethod · 0.95
getLastNonZeroIndexMethod · 0.95
setMethod · 0.95
setLengthMethod · 0.95
copyOfMethod · 0.80

Tested by

no test coverage detected