Test of pascal method, of class Matrix.
()
| 268 | * Test of pascal method, of class Matrix. |
| 269 | */ |
| 270 | @Test |
| 271 | public void testPascal() |
| 272 | { |
| 273 | System.out.println("pascal"); |
| 274 | |
| 275 | Matrix P = Matrix.pascal(6); |
| 276 | |
| 277 | for(int i = 0; i < P.rows(); i++) |
| 278 | { |
| 279 | assertEquals(1.0, P.get(i, 0), 0.0); |
| 280 | assertEquals(1.0, P.get(0, i), 0.0); |
| 281 | } |
| 282 | |
| 283 | for(int i = 1; i < P.rows(); i++) |
| 284 | for(int j = 1; j < P.cols(); j++) |
| 285 | assertEquals(P.get(i-1, j)+P.get(i, j-1), P.get(i, j), 0.0); |
| 286 | |
| 287 | } |
| 288 | |
| 289 | } |