Copies the values of this Vector into another vector @param destination the vector to store the values in. @throws ArithmeticException if the vectors are not of the same length
(Vec destination)
| 624 | * @throws ArithmeticException if the vectors are not of the same length |
| 625 | */ |
| 626 | public void copyTo(Vec destination) |
| 627 | { |
| 628 | if(this.length() != destination.length()) |
| 629 | throw new ArithmeticException("Source and destination must be the same size"); |
| 630 | if (this.isSparse()) |
| 631 | { |
| 632 | destination.zeroOut(); |
| 633 | for (IndexValue iv : this) |
| 634 | destination.set(iv.getIndex(), iv.getValue()); |
| 635 | } |
| 636 | else |
| 637 | { |
| 638 | for (int i = 0; i < length(); i++) |
| 639 | destination.set(i, this.get(i)); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * Copies the values of this vector into a row of another Matrix |