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

Method pascal

JSAT/src/jsat/linear/Matrix.java:1097–1108  ·  view source on GitHub ↗

Creates a new square matrix that is a pascal matrix. The pascal matrix of size n is n by n and symmetric. @param size the number of rows and columns for the matrix @return a pascal matrix of the desired size

(int size)

Source from the content-addressed store, hash-verified

1095 * @return a pascal matrix of the desired size
1096 */
1097 public static Matrix pascal(int size)
1098 {
1099 if(size <= 0 )
1100 throw new ArithmeticException();
1101 DenseMatrix P = new DenseMatrix(size, size);
1102 RowColumnOps.fillRow(P, 0, 0, size, 1.0);
1103 RowColumnOps.fillCol(P, 0, 0, size, 1.0);
1104 for(int i = 1; i < size; i++)
1105 for(int j = 1; j < size; j++)
1106 P.set(i, j, P.get(i-1, j) + P.get(i, j-1));
1107 return P;
1108 }
1109
1110 @Override
1111 abstract public Matrix clone();

Callers 3

setUpMethod · 0.95
testPascalMethod · 0.95
testMultiplyMethod · 0.95

Calls 4

fillRowMethod · 0.95
fillColMethod · 0.95
setMethod · 0.95
getMethod · 0.95

Tested by 3

setUpMethod · 0.76
testPascalMethod · 0.76
testMultiplyMethod · 0.76