Returns the maximum value stored in this vector @return the maximum value in this vector
()
| 455 | * @return the maximum value in this vector |
| 456 | */ |
| 457 | public double max() |
| 458 | { |
| 459 | if (isSparse() && nnz() < length()) |
| 460 | { |
| 461 | double max = 0.0; |
| 462 | for (IndexValue iv : this) |
| 463 | max = Math.max(max, iv.getValue()); |
| 464 | return max; |
| 465 | } |
| 466 | else |
| 467 | { |
| 468 | double max = get(0); |
| 469 | for (int i = 1; i < length(); i++) |
| 470 | max = Math.max(max, get(i)); |
| 471 | return max; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * Computes the sum of the values in this vector |