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)
| 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(); |