Obtains a vector that is backed by this , at very little memory cost. Mutations to this vector will alter the values stored in the matrix, and vice versa. @param j the column to obtain a view of @return a vector backed by the specified row of the matrix
(final int j)
| 626 | * @return a vector backed by the specified row of the matrix |
| 627 | */ |
| 628 | public Vec getColumnView(final int j) |
| 629 | { |
| 630 | final Matrix M = this; |
| 631 | return new Vec() |
| 632 | { |
| 633 | /** |
| 634 | * |
| 635 | */ |
| 636 | private static final long serialVersionUID = 7107290189250645384L; |
| 637 | |
| 638 | @Override |
| 639 | public int length() |
| 640 | { |
| 641 | return rows(); |
| 642 | } |
| 643 | |
| 644 | @Override |
| 645 | public double get(int index) |
| 646 | { |
| 647 | return M.get(index, j); |
| 648 | } |
| 649 | |
| 650 | @Override |
| 651 | public void set(int index, double val) |
| 652 | { |
| 653 | M.set(index, j, val); |
| 654 | } |
| 655 | |
| 656 | @Override |
| 657 | public boolean isSparse() |
| 658 | { |
| 659 | return M.isSparce(); |
| 660 | } |
| 661 | |
| 662 | @Override |
| 663 | public Vec clone() |
| 664 | { |
| 665 | if(M.isSparce()) |
| 666 | return new SparseVector(this); |
| 667 | else |
| 668 | return new DenseVector(this); |
| 669 | } |
| 670 | }; |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * Creates a vector that has a copy of the values in row <i>i</i> of this |
no outgoing calls
no test coverage detected